diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/.project b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/.project deleted file mode 100644 index 53c59d1be1..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - org.eclipse.m2e.maven.indexer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature - - diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/build.properties b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/build.properties deleted file mode 100644 index c5172d108a..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -source.. = src/main/java/,\ - src/main/resources/ -output.. = target/classes -bin.includes = META-INF/,\ - .,\ - jars/ -bin.excludes = jars/sources/ diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/pom.xml b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/pom.xml deleted file mode 100644 index c2ae63b370..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - 4.0.0 - - - org.eclipse.m2e - m2e-maven-runtime - 1.16.0-SNAPSHOT - - - org.eclipse.m2e.maven.indexer - 1.18.2-SNAPSHOT - eclipse-plugin - - M2E Maven/Nexus Indexer - - - 6.0.0 - - - - - org.apache.maven.indexer - indexer-core - ${maven-indexer.version} - - - - org.apache.maven - maven-model - - - org.apache.maven.resolver - maven-resolver-api - - - org.apache.maven.resolver - maven-resolver-util - - - com.google.inject - guice - - - com.google.guava - guava - - - org.slf4j - slf4j-api - - - javax.inject - javax.inject - - - javax.annotation - javax.annotation-api - - - - - - - - - - org.eclipse.sisu - sisu-maven-plugin - 0.3.5 - - - - index-project - prepare-package - - index - - - ${project.basedir} - - - - - - - - - org.apache.felix - maven-bundle-plugin - - - <_exportcontents> - META-INF.sisu;-noimport:=true;x-internal:=true, - org.apache.lucene.*;provider=m2e;mandatory:=provider, - org.apache.maven.*;provider=m2e;mandatory:=provider, - - - org.slf4j;resolution:=optional;version="[1.6.2,2.0.0)", - javax.inject;version="1.0.0" - - - org.eclipse.m2e.maven.runtime;bundle-version="[1.18.0,1.19.0)", - org.eclipse.m2e.archetype.common;bundle-version="[1.18.0,1.19.0)", - com.google.guava - - - - - - - - diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java deleted file mode 100644 index c0d4c0e5f3..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.index; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.StringField; -import org.apache.lucene.index.IndexableField; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopDocs; -import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator; -import org.codehaus.plexus.logging.AbstractLogEnabled; - -/** - * A default {@link IndexerEngine} implementation. - * - * @author Tamas Cservenak - */ -@Singleton -@Named -public class DefaultIndexerEngine - extends AbstractLogEnabled - implements IndexerEngine -{ - - public void index( IndexingContext context, ArtifactContext ac ) - throws IOException - { - // skip artifacts not obeying repository layout (whether m1 or m2) - if ( ac != null && ac.getGav() != null ) - { - Document d = ac.createDocument( context ); - - if ( d != null ) - { - context.getIndexWriter().addDocument( d ); - - context.updateTimestamp(); - } - } - } - - public void update( IndexingContext context, ArtifactContext ac ) - throws IOException - { - if ( ac != null && ac.getGav() != null ) - { - Document d = ac.createDocument( context ); - - if ( d != null ) - { - Document old = getOldDocument( context, ac ); - - if ( !equals( d, old ) ) - { - IndexWriter w = context.getIndexWriter(); - - w.updateDocument( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ), d ); - - updateGroups( context, ac ); - - context.updateTimestamp(); - } - } - } - } - - private boolean equals( Document d1, Document d2 ) - { - if ( d1 == null && d2 == null ) - { - return true; - } - if ( d1 == null || d2 == null ) - { - return false; - } - - Map m1 = toMap( d1 ); - Map m2 = toMap( d2 ); - - m1.remove( MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey() ); - m2.remove( MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey() ); - - return m1.equals( m2 ); - } - - private Map toMap( Document d ) - { - final HashMap result = new HashMap<>(); - - for ( IndexableField f : d.getFields() ) - { - if ( f.fieldType().stored() ) - { - result.put( f.name(), f.stringValue() ); - } - } - - return result; - } - - private Document getOldDocument( IndexingContext context, ArtifactContext ac ) - { - try - { - IndexSearcher indexSearcher = context.acquireIndexSearcher(); - try - { - TopDocs result = indexSearcher - .search(new TermQuery(new Term(ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo())), 2); - - if ( result.totalHits == 1 ) - { - return indexSearcher.doc( result.scoreDocs[0].doc ); - } - } - finally - { - context.releaseIndexSearcher( indexSearcher ); - } - } - catch ( IOException e ) - { - } - return null; - } - - private void updateGroups( IndexingContext context, ArtifactContext ac ) - throws IOException - { - String rootGroup = ac.getArtifactInfo().getRootGroup(); - Set rootGroups = context.getRootGroups(); - if ( !rootGroups.contains( rootGroup ) ) - { - rootGroups.add( rootGroup ); - context.setRootGroups( rootGroups ); - } - - Set allGroups = context.getAllGroups(); - if ( !allGroups.contains( ac.getArtifactInfo().getGroupId() ) ) - { - allGroups.add( ac.getArtifactInfo().getGroupId() ); - context.setAllGroups( allGroups ); - } - } - - public void remove( IndexingContext context, ArtifactContext ac ) - throws IOException - { - if ( ac != null ) - { - String uinfo = ac.getArtifactInfo().getUinfo(); - // add artifact deletion marker - Document doc = new Document(); - doc.add( new StringField( ArtifactInfo.DELETED, uinfo, Field.Store.YES ) ); - doc.add( new StringField( ArtifactInfo.LAST_MODIFIED, // - Long.toString( System.currentTimeMillis() ), Field.Store.YES ) ); - IndexWriter w = context.getIndexWriter(); - w.addDocument( doc ); - w.deleteDocuments( new Term( ArtifactInfo.UINFO, uinfo ) ); - w.commit(); - context.updateTimestamp(); - } - } - -} diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/NexusArchetypeDataSource.java b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/NexusArchetypeDataSource.java deleted file mode 100644 index afa58caf05..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/java/org/apache/maven/index/NexusArchetypeDataSource.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - *******************************************************************************/ - -package org.apache.maven.index; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.archetype.source.ArchetypeDataSource; -import org.apache.maven.index.archetype.AbstractArchetypeDataSource; -import org.apache.maven.index.context.IndexingContext; - -/** - * Trivial implementation of a Nexus indexer-based data source for archetypes. - * - * The maven-indexer used to ship such a class, but it is now an abstract helper - * class that consumers have to extend themselves in order to implement - * maven-archetype's {@link ArchetypeDataSource} interface. This allows - * maven-indexer to avoid having a hard dep on maven-archetype at the cost of us - * having to provide our own concrete implementation. - */ -@Singleton -@Named("nexus") -public class NexusArchetypeDataSource extends AbstractArchetypeDataSource implements ArchetypeDataSource { - - private final NexusIndexer nexusIndexer; - - @Inject - public NexusArchetypeDataSource(Indexer indexer, NexusIndexer nexusIndexer) { - super(indexer); - this.nexusIndexer = nexusIndexer; - } - - @Override - protected List getIndexingContexts() { - return new ArrayList<>(nexusIndexer.getIndexingContexts().values()); - } -} \ No newline at end of file diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about.html b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about.html deleted file mode 100644 index 340da6e557..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - -About - - -

About This Content

- -

November 30, 2017

-

License

- -

- The Eclipse Foundation makes available all content in this plug-in - ("Content"). Unless otherwise indicated below, the Content - is provided to you under the terms and conditions of the Eclipse - Public License Version 2.0 ("EPL"). A copy of the EPL is - available at http://www.eclipse.org/legal/epl-2.0. - For purposes of the EPL, "Program" will mean the Content. -

- -

- If you did not receive this Content directly from the Eclipse - Foundation, the Content is being redistributed by another party - ("Redistributor") and different terms and conditions may - apply to your use of any object code in the Content. Check the - Redistributor's license that was provided with the Content. If no such - license exists, contact the Redistributor. Unless otherwise indicated - below, the terms and conditions of the EPL still apply to any source - code in the Content and such source code may be obtained at http://www.eclipse.org. -

- -

Third Party Content

- -

-The Content includes items that have been sourced from third parties as set out below. If you -did not receive this Content directly from the Eclipse Foundation, the following is provided -for informational purposes only, and you should look to the Redistributor’s license for -terms and conditions of use. -

- -

Maven Indexer 3.1.0

-

-The plug-in includes software developed by The Apache Software Foundation as part of the Maven project. -Your use of Maven Indexer 3.1.0 in binary code form contained in the plug-in is subject to the terms and conditions of the -The Apache Software License, Version 2.0 ("ASL"). -A copy of the ASL is available at http://maven.apache.org/license.html. -(a local copy can be found here) -

-

The original binaries and source are available at the Maven Central Repository.

- - - -

Lucene 2.4.1

-

-The plug-in includes software developed by The Apache Software Foundation as part of the Lucene project. -Your use of Lucene 2.4.1 in binary code form contained in the plug-in is subject to the terms and conditions of the -The Apache Software License, Version 2.0 ("ASL"). -A copy of the ASL is available at http://www.apache.org/licenses/LICENSE-2.0. -(a local copy can be found here) -

-

The original binaries and source are available at the Maven Central Repository.

- - - - \ No newline at end of file diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about_files/LICENSE-2.0.txt b/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about_files/LICENSE-2.0.txt deleted file mode 100644 index d645695673..0000000000 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.indexer/src/main/resources/about_files/LICENSE-2.0.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/m2e-maven-runtime/pom.xml b/m2e-maven-runtime/pom.xml index b0cff0d22c..fdc4815081 100644 --- a/m2e-maven-runtime/pom.xml +++ b/m2e-maven-runtime/pom.xml @@ -31,7 +31,6 @@ org.eclipse.m2e.archetype.common - org.eclipse.m2e.maven.indexer org.eclipse.m2e.maven.runtime org.eclipse.m2e.maven.runtime.slf4j.simple diff --git a/org.eclipse.m2e.apt.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.apt.tests/META-INF/MANIFEST.MF index f7a91c620a..883785a280 100644 --- a/org.eclipse.m2e.apt.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.apt.tests/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Require-Bundle: org.eclipse.m2e.tests.common;bundle-version="[1.0.0,2.0)", org.junit;bundle-version="3.8.2", org.eclipse.jdt.core;bundle-version="3.7.0", org.eclipse.jdt.apt.core;bundle-version="3.3.500", - org.eclipse.m2e.core;bundle-version="[1.0.0,2.0)", + org.eclipse.m2e.core, org.eclipse.core.resources;bundle-version="3.6.0", org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.m2e.apt.core, diff --git a/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF index ebbdead3bf..424e035728 100644 --- a/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF @@ -4,14 +4,14 @@ Bundle-Name: M2E Binary Project Core Tests Bundle-SymbolicName: org.eclipse.m2e.binaryproject.tests;singleton:=true Bundle-Version: 1.16.0.qualifier Bundle-Vendor: Eclipse.org - m2e -Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.binaryproject;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.tests.common;bundle-version="[1.16.0,2.0.0)", +Require-Bundle: org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.binaryproject;bundle-version="1.16.0", + org.eclipse.m2e.tests.common;bundle-version="1.16.0", org.junit;bundle-version="4.0.0", org.eclipse.equinox.common;bundle-version="3.6.100", org.eclipse.core.resources;bundle-version="3.8.0", - org.eclipse.m2e.jdt;bundle-version="[1.16.0,2.0.0)", + org.eclipse.m2e.jdt;bundle-version="1.16.0", org.eclipse.jdt.core;bundle-version="3.8.1", org.eclipse.core.runtime;bundle-version="3.8.0" Import-Package: org.slf4j;version="[1.6.2,2.0.0)" diff --git a/org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF b/org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF index b937b3ada4..4f2966e547 100644 --- a/org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.binaryproject.ui/META-INF/MANIFEST.MF @@ -1,17 +1,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.m2e.binaryproject.ui;singleton:=true -Bundle-Version: 1.18.1.qualifier +Bundle-Version: 1.18.2.qualifier Bundle-Activator: org.eclipse.m2e.binaryproject.ui.internal.BinaryprojectUIActivator Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor Bundle-Name: %Bundle-Name Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.m2e.core.ui;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.binaryproject;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)" + org.eclipse.m2e.core.ui;bundle-version="1.16.0", + org.eclipse.m2e.binaryproject;bundle-version="1.16.0", + org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0" Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.m2e.binaryproject.ui diff --git a/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF b/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF index 984534d6f2..d22966c741 100644 --- a/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF @@ -1,13 +1,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.m2e.binaryproject;singleton:=true -Bundle-Version: 1.17.4.qualifier +Bundle-Version: 1.17.5.qualifier Bundle-Vendor: Eclipse.org - m2e Bundle-Name: M2E Binary Project Core -Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.sourcelookup;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.jdt;bundle-version="[1.16.0,2.0.0)", +Require-Bundle: org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.sourcelookup;bundle-version="1.16.0", + org.eclipse.m2e.jdt;bundle-version="1.16.0", org.eclipse.equinox.common;bundle-version="3.6.0", org.eclipse.core.resources;bundle-version="3.7.0", org.eclipse.jdt.core;bundle-version="3.7.0", diff --git a/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF index e91700b0be..d66af2c947 100644 --- a/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF @@ -1,12 +1,12 @@ Manifest-Version: 1.0 -Fragment-Host: org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)" +Fragment-Host: org.eclipse.m2e.core;bundle-version="1.16.0" Bundle-ManifestVersion: 2 Bundle-Name: M2E Maven Integration for Eclipse Core Tests Bundle-SymbolicName: org.eclipse.m2e.core.tests Bundle-Version: 1.16.1.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Vendor: Eclipse.org - m2e -Require-Bundle: org.eclipse.m2e.tests.common;bundle-version="[1.16.0,2.0.0)", +Require-Bundle: org.eclipse.m2e.tests.common;bundle-version="1.16.0", org.junit;bundle-version="4.12.0", org.eclipse.core.resources, org.eclipse.core.runtime, diff --git a/org.eclipse.m2e.core.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.core.ui.tests/META-INF/MANIFEST.MF index f96343ace5..be9a3466c4 100644 --- a/org.eclipse.m2e.core.ui.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core.ui.tests/META-INF/MANIFEST.MF @@ -1,12 +1,12 @@ Manifest-Version: 1.0 -Fragment-Host: org.eclipse.m2e.core.ui;bundle-version="[1.16.0,2.0.0)" +Fragment-Host: org.eclipse.m2e.core.ui;bundle-version="1.16.0" Bundle-ManifestVersion: 2 Bundle-Name: M2E Maven Integration for Eclipse UI Tests Bundle-SymbolicName: org.eclipse.m2e.core.ui.tests Bundle-Version: 1.19.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Vendor: Eclipse.org - m2e -Require-Bundle: org.eclipse.m2e.tests.common;bundle-version="[1.16.0,2.0.0)", +Require-Bundle: org.eclipse.m2e.tests.common;bundle-version="1.16.0", org.junit;bundle-version="4.12.0", org.eclipse.core.runtime, org.eclipse.m2e.launching;bundle-version="1.17.2", diff --git a/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF b/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF index 1839d2c172..da50c21713 100644 --- a/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.m2e.core.ui;singleton:=true -Bundle-Version: 1.19.0.qualifier +Bundle-Version: 1.20.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor @@ -22,13 +22,12 @@ Export-Package: org.eclipse.m2e.core.ui.internal;x-internal:=true, org.eclipse.m2e.core.ui.internal.wizards;x-friends:="org.eclipse.m2e.editor" Bundle-Activator: org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", +Require-Bundle: org.eclipse.m2e.core;bundle-version="1.16.0", org.eclipse.core.resources;bundle-version="3.5.2", org.eclipse.core.runtime;bundle-version="3.5.0", - org.eclipse.m2e.model.edit;bundle-version="[1.16.0,2.0.0)";visibility:=reexport, - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.archetype.common;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.indexer;bundle-version="[1.17.1,2.0.0)", + org.eclipse.m2e.model.edit;bundle-version="1.16.0";visibility:=reexport, + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.archetype.common;bundle-version="1.16.0", org.eclipse.ui.console;bundle-version="3.4.0", org.eclipse.ui.ide;bundle-version="3.5.2", org.eclipse.core.filesystem;bundle-version="1.2.1", diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java index 45c298c318..790b49348c 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/M2EUIPluginActivator.java @@ -21,7 +21,6 @@ import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; @@ -31,13 +30,10 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; -import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.internal.IMavenConstants; -import org.eclipse.m2e.core.internal.index.filter.FilteredIndex; import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscovery; import org.eclipse.m2e.core.ui.internal.console.MavenConsoleImpl; import org.eclipse.m2e.core.ui.internal.project.MavenUpdateConfigurationChangeListener; -import org.eclipse.m2e.core.ui.internal.search.util.IndexSearchEngine; import org.eclipse.m2e.core.ui.internal.search.util.SearchEngine; import org.eclipse.m2e.core.ui.internal.wizards.IMavenDiscoveryUI; @@ -127,8 +123,8 @@ public boolean hasMavenConsoleImpl() { return console != null; } - public SearchEngine getSearchEngine(IProject project) throws CoreException { - return new IndexSearchEngine(new FilteredIndex(project, MavenPlugin.getIndexManager().getIndex(project))); + public SearchEngine getSearchEngine(IProject project) { + return null; // used to be only Index based search, need to hook other engines } public synchronized IMavenDiscovery getMavenDiscovery() { diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java index 4b5140c55c..c328887fe7 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java @@ -435,8 +435,6 @@ public class Messages extends NLS { public static String MavenProjectWizardArchetypePage_btnSnapshots; - public static String MavenProjectWizardArchetypePage_error_emptyNexusIndexer; - public static String MavenProjectWizardArchetypePage_error_emptyCatalog; public static String MavenProjectWizardArchetypePage_error_noEnabledCatalogs; diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties index 369aca11d4..e71a4f2db0 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties @@ -248,7 +248,6 @@ MavenProjectWizardArchetypePage_btnAdd=&Add Archetype... MavenProjectWizardArchetypePage_btnConfigure=&Configure... MavenProjectWizardArchetypePage_btnLast=&Show the last version of Archetype only MavenProjectWizardArchetypePage_btnSnapshots=&Include snapshot archetypes -MavenProjectWizardArchetypePage_error_emptyNexusIndexer=No archetypes currently available. The archetype list will refresh when the indexes finish updating. MavenProjectWizardArchetypePage_error_emptyCatalog=No archetypes available for this catalog. MavenProjectWizardArchetypePage_error_noEnabledCatalogs=There are no enabled archetype catalogs. Click the 'Configure...' button. MavenProjectWizardArchetypePage_error_read=Unable to read catalog factory. diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java index 4078f6b258..f28d57856f 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenSettingsPreferencePage.java @@ -23,7 +23,6 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -66,7 +65,6 @@ import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.embedder.IMaven; import org.eclipse.m2e.core.embedder.IMavenConfiguration; -import org.eclipse.m2e.core.internal.index.IndexManager; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.MavenUpdateRequest; import org.eclipse.m2e.core.ui.internal.Messages; @@ -151,10 +149,6 @@ protected IStatus run(IProgressMonitor monitor) { mavenConfiguration.setUserSettingsFile(userSettings); File newRepositoryDir = new File(maven.getLocalRepository().getBasedir()); - if(!newRepositoryDir.equals(localRepositoryDir)) { - IndexManager indexManager = MavenPlugin.getIndexManager(); - indexManager.getWorkspaceIndex().updateIndex(true, monitor); - } if(updateProjects[0]) { IMavenProjectFacade[] projects = MavenPlugin.getMavenProjectRegistry().getProjects(); ArrayList allProjects = new ArrayList<>(); @@ -257,19 +251,6 @@ protected Control createContents(Composite parent) { localRepositoryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); localRepositoryText.setData("name", "localRepositoryText"); //$NON-NLS-1$ //$NON-NLS-2$ localRepositoryText.setEditable(false); - Button reindexButton = new Button(composite, SWT.NONE); - reindexButton.setLayoutData(new GridData(SWT.FILL, SWT.RIGHT, false, false, 1, 1)); - reindexButton.setText(Messages.preferencesReindexButton); - reindexButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { - new WorkspaceJob(Messages.MavenSettingsPreferencePage_job_indexing) { - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - IndexManager indexManager = MavenPlugin.getIndexManager(); - indexManager.getWorkspaceIndex().updateIndex(true, monitor); - return Status.OK_STATUS; - } - }.schedule(); - })); ModifyListener settingsModifyListener = modifyevent -> { updateLocalRepository(); diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/IndexSearchEngine.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/IndexSearchEngine.java deleted file mode 100644 index 23f1388cc8..0000000000 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/search/util/IndexSearchEngine.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.ui.internal.search.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.eclipse.core.runtime.CoreException; - -import org.apache.maven.artifact.versioning.ComparableVersion; - -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexManager; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.MatchTyped.MatchType; -import org.eclipse.m2e.core.internal.index.MatchTypedStringSearchExpression; -import org.eclipse.m2e.core.internal.index.SearchExpression; - - -/** - * Search engine integrating {@link IndexManager} with POM XML editor. - * - * @author Lukas Krecan - * @author Eugene Kuleshov - */ -public class IndexSearchEngine implements SearchEngine { - - private final IIndex index; - - public IndexSearchEngine(IIndex index) { - this.index = index; - } - - protected boolean isBlank(String str) { - return str == null || str.trim().length() == 0; - } - - @Override - public Collection findArtifactIds(String groupId, String searchExpression, Packaging packaging, - ArtifactInfo containingArtifact) { - // TODO add support for implicit groupIds in plugin dependencies "org.apache.maven.plugins", ... - // Someone, give me here access to settings.xml, to be able to pick up "real" predefined groupIds added by user - // Currently, I am just simulating the "factory defaults" of maven, but user changes to settings.xml - // will not be picked up this way! - ArrayList groupIdSearchExpressions = new ArrayList<>(); - if(isBlank(groupId)) { - // values from effective settings - // we are wiring in the defaults only, but user changes are lost! - // org.apache.maven.plugins - // org.codehaus.mojo - groupIdSearchExpressions.add(new MatchTypedStringSearchExpression("org.apache.maven.plugins", MatchType.EXACT)); - groupIdSearchExpressions.add(new MatchTypedStringSearchExpression("org.codehaus.mojo", MatchType.EXACT)); - } else { - groupIdSearchExpressions.add(new MatchTypedStringSearchExpression(groupId, MatchType.EXACT)); - } - - try { - TreeSet ids = new TreeSet<>(); - for(IndexedArtifact artifact : index.find(groupIdSearchExpressions, null, null, - packaging.toSearchExpression() == null ? null : Collections.singleton(packaging.toSearchExpression()))) { - ids.add(artifact.getArtifactId()); - } - return subSet(ids, searchExpression); - } catch(CoreException ex) { - throw new SearchException(ex.getMessage(), ex.getStatus().getException()); - } - } - - @Override - public Collection findClassifiers(String groupId, String artifactId, String version, String prefix, - Packaging packaging) { - try { - Collection values = index.find(new MatchTypedStringSearchExpression(groupId, MatchType.EXACT), - new MatchTypedStringSearchExpression(artifactId, MatchType.EXACT), null, packaging.toSearchExpression()); - if(values.isEmpty()) { - return Collections.emptySet(); - } - - TreeSet ids = new TreeSet<>(); - Set files = values.iterator().next().getFiles(); - for(IndexedArtifactFile artifactFile : files) { - if(artifactFile.classifier != null) { - ids.add(artifactFile.classifier); - } - } - return subSet(ids, prefix); - } catch(CoreException ex) { - throw new SearchException(ex.getMessage(), ex.getStatus().getException()); - } - } - - @Override - public Collection findGroupIds(String searchExpression, Packaging packaging, ArtifactInfo containingArtifact) { - try { - TreeSet ids = new TreeSet<>(); - - SearchExpression groupSearchExpression = isBlank(searchExpression) ? null : new MatchTypedStringSearchExpression( - searchExpression, MatchType.PARTIAL); - - for(IndexedArtifact artifact : index.find(groupSearchExpression, null, null, packaging.toSearchExpression())) { - ids.add(artifact.getGroupId()); - } - return subSet(ids, searchExpression); - } catch(CoreException ex) { - throw new SearchException(ex.getMessage(), ex.getStatus().getException()); - } - } - - @Override - public Collection findTypes(String groupId, String artifactId, String version, String prefix, - Packaging packaging) { - try { - Collection values = index.find(new MatchTypedStringSearchExpression(groupId, MatchType.EXACT), - new MatchTypedStringSearchExpression(artifactId, MatchType.EXACT), null, packaging.toSearchExpression()); - if(values.isEmpty()) { - return Collections.emptySet(); - } - - TreeSet ids = new TreeSet<>(); - Set files = values.iterator().next().getFiles(); - for(IndexedArtifactFile artifactFile : files) { - if(artifactFile.type != null) { - ids.add(artifactFile.type); - } - } - return subSet(ids, prefix); - } catch(CoreException ex) { - throw new SearchException(ex.getMessage(), ex.getStatus().getException()); - } - } - - @Override - public Collection findVersions(String groupId, String artifactId, String searchExpression, Packaging packaging) { - try { - Collection values = index.find(new MatchTypedStringSearchExpression(groupId, MatchType.EXACT), - new MatchTypedStringSearchExpression(artifactId, MatchType.EXACT), null, packaging.toSearchExpression()); - if(values.isEmpty()) { - return Collections.emptySet(); - } - - TreeSet ids = new TreeSet<>(); - Set files = values.iterator().next().getFiles(); - for(IndexedArtifactFile artifactFile : files) { - ids.add(artifactFile.version); - } - Collection result = subSet(ids, searchExpression); - - // sort results according to o.a.m.artifact.versioning.ComparableVersion - SortedSet versions = new TreeSet<>(); - for(String version : result) { - versions.add(new ComparableVersion(version)); - } - result = null; // not used any more - List sorted = new ArrayList<>(versions.size()); - for(ComparableVersion version : versions) { - sorted.add(version.toString()); - } - versions = null; // not used any more - Collections.reverse(sorted); - return sorted; - } catch(CoreException ex) { - throw new SearchException(ex.getMessage(), ex.getStatus().getException()); - } - } - - private Collection subSet(TreeSet ids, String searchExpression) { - if(searchExpression == null || searchExpression.length() == 0) { - return ids; - } - int n = searchExpression.length(); - return ids.subSet(searchExpression, // - searchExpression.substring(0, n - 1) + ((char) (searchExpression.charAt(n - 1) + 1))); - } - -} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/ProposalUtil.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/ProposalUtil.java index 01936a566d..b0f076ab93 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/ProposalUtil.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/util/ProposalUtil.java @@ -34,8 +34,6 @@ import org.eclipse.ui.IWorkbenchCommandConstants; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; -import org.apache.lucene.queryparser.classic.QueryParserBase; - import org.apache.maven.project.MavenProject; import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator; @@ -132,9 +130,7 @@ public static void addClassifierProposal(final IProject project, final Text grou @Override public Collection search() throws CoreException { return getSearchEngine(project).findClassifiers( - escapeQuerySpecialCharacters(groupIdText.getText()), // - escapeQuerySpecialCharacters(artifactIdText.getText()), - escapeQuerySpecialCharacters(versionText.getText()), "", packaging); + groupIdText.getText(), artifactIdText.getText(), versionText.getText(), "", packaging); } }); } @@ -145,8 +141,8 @@ public static void addVersionProposal(final IProject project, final MavenProject @Override public Collection search() throws CoreException { Collection toRet = new ArrayList<>(); - toRet.addAll(getSearchEngine(project).findVersions(escapeQuerySpecialCharacters(groupIdText.getText()), // - escapeQuerySpecialCharacters(artifactIdText.getText()), "", packaging)); + toRet.addAll(getSearchEngine(project).findVersions(groupIdText.getText(), // + artifactIdText.getText(), "", packaging)); if(mp != null) { //add version props now.. Properties props = mp.getProperties(); @@ -173,7 +169,7 @@ public static void addArtifactIdProposal(final IProject project, final Text grou @Override public Collection search() throws CoreException { // TODO handle artifact info - return getSearchEngine(project).findArtifactIds(escapeQuerySpecialCharacters(groupIdText.getText()), "", + return getSearchEngine(project).findArtifactIds(groupIdText.getText(), "", packaging, null); } }); @@ -184,20 +180,12 @@ public static void addGroupIdProposal(final IProject project, final Text groupId @Override public Collection search() throws CoreException { // TODO handle artifact info - return getSearchEngine(project).findGroupIds(escapeQuerySpecialCharacters(groupIdText.getText()), packaging, + return getSearchEngine(project).findGroupIds(groupIdText.getText(), packaging, null); } }); } - //issue 350271 - //http://lucene.apache.org/java/3_2_0/queryparsersyntax.html#Escaping Special Characters - //for proposal queries, any special chars shall be escaped - // + - && || ! ( ) { } [ ] ^ " ~ * ? : \ - private static String escapeQuerySpecialCharacters(String raw) { - return QueryParserBase.escape(raw); - } - public static SearchEngine getSearchEngine(final IProject project) throws CoreException { return M2EUIPluginActivator.getDefault().getSearchEngine(project); } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java index c49cedabad..1cbb56de71 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/MavenRepositoryView.java @@ -19,12 +19,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.eclipse.aether.artifact.Artifact; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; @@ -35,11 +35,8 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; @@ -56,22 +53,14 @@ import org.eclipse.ui.part.ViewPart; import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.IndexListener; -import org.eclipse.m2e.core.internal.index.IndexManager; import org.eclipse.m2e.core.internal.index.IndexedArtifact; import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.nexus.IndexedArtifactGroup; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.repository.IRepository; import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator; import org.eclipse.m2e.core.ui.internal.MavenImages; import org.eclipse.m2e.core.ui.internal.Messages; import org.eclipse.m2e.core.ui.internal.actions.OpenPomAction; -import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils; -import org.eclipse.m2e.core.ui.internal.views.nodes.AbstractIndexedRepositoryNode; import org.eclipse.m2e.core.ui.internal.views.nodes.IArtifactNode; -import org.eclipse.m2e.core.ui.internal.views.nodes.IndexedArtifactFileNode; -import org.eclipse.m2e.core.ui.internal.views.nodes.LocalRepositoryNode; +import org.eclipse.m2e.core.ui.internal.views.nodes.IMavenRepositoryNode; import org.eclipse.m2e.core.ui.internal.views.nodes.RepositoryNode; @@ -109,24 +98,12 @@ public class MavenRepositoryView extends ViewPart { private static final String MENU_ID = ".repositoryViewMenu"; //$NON-NLS-1$ - private final IndexManager indexManager = MavenPlugin.getIndexManager(); - private IAction collapseAllAction; private IAction reloadSettings; BaseSelectionListenerAction openPomAction; - private BaseSelectionListenerAction updateAction; - - private BaseSelectionListenerAction rebuildAction; - - private DisableIndexAction disableAction; - - private EnableMinIndexAction enableMinAction; - - private EnableFullIndexAction enableFullAction; - private BaseSelectionListenerAction copyUrlAction; //private BaseSelectionListenerAction materializeProjectAction; @@ -137,8 +114,6 @@ public class MavenRepositoryView extends ViewPart { private DrillDownAdapter drillDownAdapter; - private IndexListener indexListener; - @Override public void setFocus() { viewer.getControl().setFocus(); @@ -166,30 +141,6 @@ public void createPartControl(Composite parent) { viewer.addDoubleClickListener(event -> openPomAction.run()); contributeToActionBars(); - this.indexListener = new IndexListener() { - - @Override - public void indexAdded(IRepository repository) { - refreshView(); - } - - @Override - public void indexChanged(IRepository repository) { - refreshView(); - } - - @Override - public void indexRemoved(IRepository repository) { - refreshView(); - } - - @Override - public void indexUpdating(IRepository repository) { - Display.getDefault().asyncExec(() -> viewer.refresh(true)); - } - }; - - indexManager.addIndexListener(this.indexListener); } private void hookContextMenu() { @@ -217,12 +168,12 @@ private void fillLocalPullDown(IMenuManager manager) { manager.add(reloadSettings); } - protected List getSelectedRepositoryNodes(List elements) { - ArrayList list = new ArrayList<>(); + protected List getSelectedRepositoryNodes(List elements) { + ArrayList list = new ArrayList<>(); if(elements != null) { for(Object elem : elements) { - if(elem instanceof AbstractIndexedRepositoryNode) { - list.add((AbstractIndexedRepositoryNode) elem); + if(elem instanceof IMavenRepositoryNode) { + list.add((IMavenRepositoryNode) elem); } } } @@ -250,12 +201,6 @@ void fillContextMenu(IMenuManager manager) { manager.prependToGroup(MENU_OPEN_GRP, copyUrlAction); manager.prependToGroup(MENU_OPEN_GRP, openPomAction); - manager.prependToGroup(MENU_UPDATE_GRP, updateAction); - manager.prependToGroup(MENU_UPDATE_GRP, rebuildAction); - - manager.add(disableAction); - manager.add(enableMinAction); - manager.add(enableFullAction); manager.add(new Separator()); manager.add(collapseAllAction); manager.add(new Separator()); @@ -305,152 +250,21 @@ public IStatus runInWorkspace(IProgressMonitor monitor) { }; reloadSettings.setImageDescriptor(MavenImages.REFRESH); -// deleteFromLocalAction = new BaseSelectionListenerAction("Delete from Repository") { -// public void run() { -// List nodes = getArtifactNodes(getStructuredSelection().toList()); -// if(nodes != null){ -// for(IArtifactNode node : nodes){ -// String key = node.getDocumentKey(); -// System.out.println("key: "+key); -// ((NexusIndexManager)MavenPlugin.getIndexManager()).removeDocument("local", null, key); -// } -// } -// } -// -// protected boolean updateSelection(IStructuredSelection selection) { -// List nodes = getArtifactNodes(getStructuredSelection().toList()); -// return (nodes != null && nodes.size() > 0); -// } -// }; -// deleteFromLocalAction.setToolTipText("Delete the selected GAV from the local repository"); - //updateAction.setImageDescriptor(MavenImages.UPD_INDEX); - - updateAction = new BaseSelectionListenerAction(Messages.MavenRepositoryView_action_update) { - @Override - public void run() { - List nodes = getSelectedRepositoryNodes(getStructuredSelection().toList()); - for(AbstractIndexedRepositoryNode node : nodes) { - if(node instanceof RepositoryNode) { - ((RepositoryNode) node).getIndex().scheduleIndexUpdate(false); - } - } - } - - @Override - protected boolean updateSelection(IStructuredSelection selection) { - int indexCount = 0; - for(AbstractIndexedRepositoryNode node : getSelectedRepositoryNodes(selection.toList())) { - if(node instanceof RepositoryNode && node.isEnabledIndex()) { - indexCount++ ; - } - } - if(indexCount > 1) { - setText(Messages.MavenRepositoryView_update_more); - } else { - setText(Messages.MavenRepositoryView_update_one); - } - return indexCount > 0; - } - }; - updateAction.setToolTipText(Messages.MavenRepositoryView_btnUpdate_tooltip); - updateAction.setImageDescriptor(MavenImages.UPD_INDEX); - - rebuildAction = new BaseSelectionListenerAction(Messages.MavenRepositoryView_action_rebuild) { - @Override - public void run() { - new Job(Messages.MavenRepositoryView_rebuild_indexes) { - - @Override - protected IStatus run(IProgressMonitor monitor) { - // Remove the index listener to avoid locking the user interface - indexManager.removeIndexListener(indexListener); - try { - List nodes = getSelectedRepositoryNodes(getStructuredSelection().toList()); - if(!nodes.isEmpty()) { - final String title = Messages.MavenRepositoryView_rebuild_title; - final String msg = nodes.size() == 1 - ? NLS.bind(Messages.MavenRepositoryView_rebuild_msg, nodes.get(0).getIndex().getRepositoryUrl()) - : Messages.MavenRepositoryView_rebuild_msg2; - - final boolean result[] = new boolean[1]; - Display.getDefault() - .syncExec(() -> result[0] = MessageDialog.openConfirm(getViewSite().getShell(), title, msg)); - if(result[0]) { - SubMonitor mon = SubMonitor.convert(monitor, nodes.size()); - try { - for(AbstractIndexedRepositoryNode node : nodes) { - NexusIndex index = node.getIndex(); - if(index != null) { - try { - index.updateIndex(true, mon.newChild(1)); - } catch(CoreException ex) { - log.error(ex.getMessage(), ex); - } - } else { - mon.worked(1); - } - } - } finally { - mon.done(); - } - } - } - return Status.OK_STATUS; - } finally { - indexManager.addIndexListener(indexListener); - refreshView(); - } - } - }.schedule(); - } - - @Override - protected boolean updateSelection(IStructuredSelection selection) { - int indexCount = 0; - for(AbstractIndexedRepositoryNode node : getSelectedRepositoryNodes(selection.toList())) { - if((node instanceof LocalRepositoryNode) || node.isEnabledIndex()) { - indexCount++ ; - } - } - if(indexCount > 1) { - setText(Messages.MavenRepositoryView_rebuild_many); - } else { - setText(Messages.MavenRepositoryView_rebuild_one); - } - return indexCount > 0; - } - }; - - rebuildAction.setToolTipText(Messages.MavenRepositoryView_action_rebuild_tooltip); - rebuildAction.setImageDescriptor(MavenImages.REBUILD_INDEX); - - disableAction = new DisableIndexAction(); - - disableAction.setToolTipText(Messages.MavenRepositoryView_action_disable_tooltip); - disableAction.setImageDescriptor(MavenImages.REBUILD_INDEX); - - enableMinAction = new EnableMinIndexAction(); - enableMinAction.setToolTipText(Messages.MavenRepositoryView_action_enable_tooltip); - enableMinAction.setImageDescriptor(MavenImages.REBUILD_INDEX); - - enableFullAction = new EnableFullIndexAction(); - enableFullAction.setToolTipText(Messages.MavenRepositoryView_action_enableFull_tooltip); - enableFullAction.setImageDescriptor(MavenImages.REBUILD_INDEX); openPomAction = new BaseSelectionListenerAction(Messages.MavenRepositoryView_action_open) { @Override public void run() { ISelection selection = viewer.getSelection(); Object element = ((IStructuredSelection) selection).getFirstElement(); - if(element instanceof IndexedArtifactFileNode) { - IndexedArtifactFile f = ((IndexedArtifactFileNode) element).getIndexedArtifactFile(); - OpenPomAction.openEditor(f.group, f.artifact, f.version, null); + if(element instanceof IArtifactNode) { + Artifact f = ((IArtifactNode) element).getArtifact(); + OpenPomAction.openEditor(f.getGroupId(), f.getArtifactId(), f.getVersion(), null); } } @Override protected boolean updateSelection(IStructuredSelection selection) { - return selection.getFirstElement() instanceof IndexedArtifactFileNode; + return selection.getFirstElement() instanceof IArtifactNode; } }; openPomAction.setToolTipText(Messages.MavenRepositoryView_action_open_tooltip); @@ -463,13 +277,6 @@ public void run() { String url = null; if(element instanceof RepositoryNode) { url = ((RepositoryNode) element).getRepositoryUrl(); - } else if(element instanceof IndexedArtifactGroup) { - IndexedArtifactGroup group = (IndexedArtifactGroup) element; - String repositoryUrl = group.getRepository().getUrl(); - if(!repositoryUrl.endsWith("/")) { //$NON-NLS-1$ - repositoryUrl += "/"; //$NON-NLS-1$ - } - url = repositoryUrl + group.getPrefix().replace('.', '/'); } else if(element instanceof IndexedArtifact) { // } else if(element instanceof IndexedArtifactFile) { @@ -485,7 +292,7 @@ public void run() { @Override protected boolean updateSelection(IStructuredSelection selection) { Object element = selection.getFirstElement(); - return element instanceof RepositoryNode || element instanceof IndexedArtifactGroup; + return element instanceof RepositoryNode; } }; copyUrlAction.setToolTipText(Messages.MavenRepositoryView_action_copy_tooltip); @@ -510,46 +317,24 @@ protected boolean updateSelection(IStructuredSelection selection) { // materializeProjectAction.setImageDescriptor(MavenImages.IMPORT_PROJECT); viewer.addSelectionChangedListener(openPomAction); - viewer.addSelectionChangedListener(updateAction); - viewer.addSelectionChangedListener(disableAction); - viewer.addSelectionChangedListener(enableMinAction); - viewer.addSelectionChangedListener(enableFullAction); - viewer.addSelectionChangedListener(rebuildAction); viewer.addSelectionChangedListener(copyUrlAction); // viewer.addSelectionChangedListener(materializeProjectAction); } - protected void setIndexDetails(AbstractIndexedRepositoryNode node, String details) { - if(node != null && node.getIndex() != null) { - try { - node.getIndex().setIndexDetails(details); - } catch(CoreException ex) { - M2EUIUtils.showErrorDialog(this.getViewSite().getShell(), Messages.MavenRepositoryView_error_title, - Messages.MavenRepositoryView_error_message, ex); - } - } - } - - protected AbstractIndexedRepositoryNode getSelectedRepositoryNode(IStructuredSelection selection) { + protected RepositoryNode getSelectedRepositoryNode(IStructuredSelection selection) { List elements = selection.toList(); if(elements.size() != 1) { return null; } Object element = elements.get(0); - return element instanceof AbstractIndexedRepositoryNode ? (AbstractIndexedRepositoryNode) element : null; + return element instanceof RepositoryNode ? (RepositoryNode) element : null; } @Override public void dispose() { // viewer.removeSelectionChangedListener(materializeProjectAction); viewer.removeSelectionChangedListener(copyUrlAction); - viewer.removeSelectionChangedListener(rebuildAction); - viewer.removeSelectionChangedListener(disableAction); - viewer.removeSelectionChangedListener(enableMinAction); - viewer.removeSelectionChangedListener(enableFullAction); - viewer.removeSelectionChangedListener(updateAction); viewer.removeSelectionChangedListener(openPomAction); - indexManager.removeIndexListener(this.indexListener); super.dispose(); } @@ -565,99 +350,4 @@ void refreshView() { }); } - /** - * Base Selection Listener does not allow the style (radio button/check) to be set. This base class listens to - * selections and sets the appropriate index value depending on its value AbstractIndexAction - * - * @author dyocum - */ - abstract class AbstractIndexAction extends Action implements ISelectionChangedListener { - - protected abstract String getDetailsValue(); - - protected abstract String getActionText(); - - public AbstractIndexAction(String text, int style) { - super(text, style); - } - - @Override - public void run() { - IStructuredSelection sel = (IStructuredSelection) viewer.getSelection(); - setIndexDetails(getSelectedRepositoryNode(sel), getDetailsValue()); - } - - /* - */ - @Override - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - updateSelection(sel); - } - - protected void updateSelection(IStructuredSelection selection) { - AbstractIndexedRepositoryNode node = getSelectedRepositoryNode(selection); - updateIndexDetails(node); - setText(getActionText()); - boolean enabled = (node instanceof RepositoryNode); - this.setEnabled(enabled); - } - - protected void updateIndexDetails(AbstractIndexedRepositoryNode node) { - if(node == null || node.getIndex() == null) { - return; - } - NexusIndex index = node.getIndex(); - setChecked(getDetailsValue().equals(index.getIndexDetails())); - } - - } - - class DisableIndexAction extends AbstractIndexAction { - public DisableIndexAction() { - super(DISABLE_DETAILS, IAction.AS_CHECK_BOX); - } - - @Override - protected String getDetailsValue() { - return NexusIndex.DETAILS_DISABLED; - } - - @Override - protected String getActionText() { - return isChecked() ? DISABLED_DETAILS : DISABLE_DETAILS; - } - } - - class EnableMinIndexAction extends AbstractIndexAction { - public EnableMinIndexAction() { - super(ENABLE_MIN, IAction.AS_CHECK_BOX); - } - - @Override - protected String getDetailsValue() { - return NexusIndex.DETAILS_MIN; - } - - @Override - protected String getActionText() { - return isChecked() ? ENABLED_MIN : ENABLE_MIN; - } - } - - class EnableFullIndexAction extends AbstractIndexAction { - public EnableFullIndexAction() { - super(ENABLE_FULL, IAction.AS_CHECK_BOX); - } - - @Override - protected String getDetailsValue() { - return NexusIndex.DETAILS_FULL; - } - - @Override - protected String getActionText() { - return isChecked() ? ENABLED_FULL : ENABLE_FULL; - } - } } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java index 1d9aff3227..7a1f0a33ba 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/RepositoryViewLabelProvider.java @@ -84,7 +84,7 @@ public Color getBackground(Object element) { @Override public Color getForeground(Object element) { - if(element instanceof RepositoryNode && !((RepositoryNode) element).isEnabledIndex()) { + if(element instanceof RepositoryNode && !(((RepositoryNode) element).hasChildren())) { return Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY); } return null; diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractIndexedRepositoryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractIndexedRepositoryNode.java deleted file mode 100644 index a8edf4eb38..0000000000 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractIndexedRepositoryNode.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.ui.internal.views.nodes; - -import java.util.Arrays; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.m2e.core.internal.index.nexus.IndexedArtifactGroup; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.ui.internal.MavenImages; - - -/** - * AbstractIndexedRepository - * - * @author igor - */ -public abstract class AbstractIndexedRepositoryNode implements IMavenRepositoryNode { - private static final Logger log = LoggerFactory.getLogger(AbstractIndexedRepositoryNode.class); - - protected static final Object[] NO_CHILDREN = new Object[0]; - - protected final NexusIndex index; - - protected AbstractIndexedRepositoryNode(NexusIndex index) { - this.index = index; - } - - @Override - public Object[] getChildren() { - - if(index == null) { - return NO_CHILDREN; - } - - try { - IndexedArtifactGroup[] rootGroups = index.getRootIndexedArtifactGroups(); - if(rootGroups == null) { - return NO_CHILDREN; - } - IndexedArtifactGroupNode[] children = new IndexedArtifactGroupNode[rootGroups.length]; - Arrays.sort(rootGroups); - for(int i = 0; i < rootGroups.length; i++ ) { - children[i] = new IndexedArtifactGroupNode(rootGroups[i]); - } - return children; - } catch(CoreException ex) { - log.error(ex.getMessage(), ex); - return NO_CHILDREN; - } - } - - @Override - public Image getImage() { - return MavenImages.IMG_INDEX; - } - - @Override - public boolean hasChildren() { - return index != null; - } - - @Override - public boolean isUpdating() { - return index != null && index.isUpdating(); - } - - public NexusIndex getIndex() { - return index; - } - - public String getRepositoryUrl() { - return index.getRepositoryUrl(); - } - - public boolean isEnabledIndex() { - return index != null && index.isEnabled(); - } -} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractRepositoriesNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractRepositoriesNode.java index d1e438d75e..293aa7487a 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractRepositoriesNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/AbstractRepositoriesNode.java @@ -19,8 +19,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; import org.eclipse.m2e.core.repository.IRepository; import org.eclipse.m2e.core.repository.IRepositoryRegistry; import org.eclipse.m2e.core.ui.internal.MavenImages; @@ -33,8 +31,6 @@ */ public abstract class AbstractRepositoriesNode implements IMavenRepositoryNode { - protected final NexusIndexManager indexManager = (NexusIndexManager) MavenPlugin.getIndexManager(); - protected final IRepositoryRegistry repositoryRegistry = MavenPlugin.getRepositoryRegistry(); @Override @@ -44,8 +40,7 @@ public Object[] getChildren() { ArrayList globalRepoNodes = new ArrayList<>(); for(IRepository repo : getRepositories()) { - NexusIndex index = indexManager.getIndex(repo); - RepositoryNode node = new RepositoryNode(index); + RepositoryNode node = new RepositoryNode(repo); if(repo.getMirrorOf() != null) { mirrorNodes.add(node); } else { diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IArtifactNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IArtifactNode.java index c2d78d4bd3..b093f73c13 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IArtifactNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IArtifactNode.java @@ -13,6 +13,9 @@ package org.eclipse.m2e.core.ui.internal.views.nodes; +import org.eclipse.aether.artifact.Artifact; + + /** * AbstractArtifactNode * @@ -20,4 +23,9 @@ */ public interface IArtifactNode { String getDocumentKey(); + + /** + * @return + */ + Artifact getArtifact(); } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java deleted file mode 100644 index 330acc77ce..0000000000 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactFileNode.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2018 Sonatype, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.ui.internal.views.nodes; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.swt.graphics.Image; - -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; -import org.eclipse.m2e.core.ui.internal.MavenImages; - - -/** - * IndexedArtifactFileNode - * - * @author dyocum - */ -@SuppressWarnings("restriction") -public class IndexedArtifactFileNode extends PlatformObject implements IMavenRepositoryNode, IArtifactNode, IAdaptable { - - private final IndexedArtifactFile artifactFile; - - public IndexedArtifactFileNode(IndexedArtifactFile artifactFile) { - this.artifactFile = artifactFile; - } - - public IndexedArtifactFile getIndexedArtifactFile() { - return this.artifactFile; - } - - @Override - public Object[] getChildren() { - return null; - } - - @Override - public String getName() { - String label = artifactFile.artifact; - if(artifactFile.classifier != null) { - label += " : " + artifactFile.classifier; //$NON-NLS-1$ - } - if(artifactFile.version != null) { - label += " : " + artifactFile.version; //$NON-NLS-1$ - } - return label; - } - - @Override - public boolean hasChildren() { - return false; - } - - @Override - public Image getImage() { - if(artifactFile.sourcesExists == IIndex.PRESENT) { - return MavenImages.IMG_VERSION_SRC; - } - return MavenImages.IMG_VERSION; - - } - - @Override - public String getDocumentKey() { - return NexusIndexManager.getDocumentKey(artifactFile.getArtifactKey()); - } - - @Override - public boolean isUpdating() { - return false; - } - - public static class AdapterFactory implements IAdapterFactory { - - private static final Class[] ADAPTERS = new Class[] {ArtifactKey.class, IndexedArtifactFile.class}; - - @Override - public T getAdapter(Object adaptableObject, Class adapterType) { - if(adaptableObject instanceof IndexedArtifactFileNode) { - IndexedArtifactFileNode node = (IndexedArtifactFileNode) adaptableObject; - IndexedArtifactFile artifactFile = node.artifactFile; - if(ArtifactKey.class.equals(adapterType)) { - return adapterType.cast(new ArtifactKey(artifactFile.group, artifactFile.artifact, artifactFile.version, - artifactFile.classifier)); - } else if(IndexedArtifactFile.class.equals(adapterType)) { - return adapterType.cast(artifactFile); - } - } - return null; - } - - @Override - public Class[] getAdapterList() { - return ADAPTERS; - } - - } -} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactGroupNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactGroupNode.java deleted file mode 100644 index 41fc974dd3..0000000000 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactGroupNode.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.ui.internal.views.nodes; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.nexus.IndexedArtifactGroup; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; - - -/** - * IndexedArtifactGroupNode - * - * @author dyocum - */ -public class IndexedArtifactGroupNode implements IMavenRepositoryNode, IArtifactNode { - - private final IndexedArtifactGroup indexedArtifactGroup; - - private Object[] kids = null; - - public IndexedArtifactGroupNode(IndexedArtifactGroup group) { - this.indexedArtifactGroup = group; - } - - @Override - public Object[] getChildren() { - NexusIndexManager indexManager = (NexusIndexManager) MavenPlugin.getIndexManager(); - - IndexedArtifactGroup resolvedGroup = indexManager.resolveGroup(indexedArtifactGroup); - //IndexedArtifactGroup resolvedGroup = indexedArtifactGroup; - ArrayList results = new ArrayList<>(); - Collection groups = resolvedGroup.getNodes().values(); - for(IndexedArtifactGroup group : groups) { - IndexedArtifactGroupNode node = new IndexedArtifactGroupNode(group); - results.add(node); - } - - Collection artifacts = resolvedGroup.getFiles().values(); // IndexedArtifact - for(IndexedArtifact artifact : artifacts) { - IndexedArtifactNode artifactNode = new IndexedArtifactNode(artifact); - results.add(artifactNode); - } - kids = results.toArray(new Object[results.size()]); - return kids; - } - - @Override - public String getName() { - String prefix = indexedArtifactGroup.getPrefix(); - int n = prefix.lastIndexOf('.'); - return n < 0 ? prefix : prefix.substring(n + 1); - } - - @Override - public boolean hasChildren() { -// if(kids == null){ -// kids = getChildren(); -// } -// return kids != null && kids.length > 0; - return true; - } - - @Override - public Image getImage() { - return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); - } - - @Override - public String getDocumentKey() { - return indexedArtifactGroup.getPrefix(); - } - - @Override - public boolean isUpdating() { - // TODO Auto-generated method isUpdating - return false; - } - -} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java deleted file mode 100644 index e41945596c..0000000000 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/IndexedArtifactNode.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.ui.internal.views.nodes; - -import java.util.ArrayList; -import java.util.Set; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.ui.internal.MavenImages; -import org.eclipse.m2e.core.ui.internal.Messages; - - -/** - * IndexedArtifactNode - * - * @author dyocum - */ -@SuppressWarnings("restriction") -public class IndexedArtifactNode implements IMavenRepositoryNode, IArtifactNode { - - private final IndexedArtifact artifact; - - private Object[] kids = null; - - public IndexedArtifactNode(IndexedArtifact artifact) { - this.artifact = artifact; - } - - @Override - public Object[] getChildren() { - Set files = artifact.getFiles(); - if(files == null) { - return new Object[0]; - } - ArrayList fileList = new ArrayList<>(); - for(IndexedArtifactFile iaf : files) { - fileList.add(new IndexedArtifactFileNode(iaf)); - } - kids = fileList.toArray(new IndexedArtifactFileNode[fileList.size()]); - return kids; - } - - @Override - public String getName() { - // return a.group + ":" + a.artifact; - String pkg = artifact.getPackaging(); - if(pkg == null) { - pkg = Messages.IndexedArtifactNode_no_pack; - } - return artifact.getArtifactId() + " - " + pkg; //$NON-NLS-1$ - } - - @Override - public boolean hasChildren() { - //return kids != null && kids.length > 0; - return true; - } - - @Override - public Image getImage() { - return MavenImages.IMG_JAR; - } - - @Override - public String getDocumentKey() { - return artifact.getArtifactId(); - } - - @Override - public boolean isUpdating() { - return false; - } - -} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryNode.java index cd99879c63..a67851ae2f 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryNode.java @@ -13,8 +13,7 @@ package org.eclipse.m2e.core.ui.internal.views.nodes; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.repository.IRepository; +import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.ui.internal.Messages; @@ -23,15 +22,14 @@ * * @author igor */ -public class LocalRepositoryNode extends AbstractIndexedRepositoryNode { +public class LocalRepositoryNode extends RepositoryNode { - public LocalRepositoryNode(NexusIndex index) { - super(index); + public LocalRepositoryNode() { + super(MavenPlugin.getRepositoryRegistry().getLocalRepository()); } @Override public String getName() { - IRepository repository = index.getRepository(); StringBuilder sb = new StringBuilder(); sb.append(Messages.LocalRepositoryNode_local); if(repository.getBasedir() != null) { diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryRootNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryRootNode.java index ebbcaf91b9..a16be898e1 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryRootNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/LocalRepositoryRootNode.java @@ -15,9 +15,6 @@ import org.eclipse.swt.graphics.Image; -import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; import org.eclipse.m2e.core.ui.internal.MavenImages; import org.eclipse.m2e.core.ui.internal.Messages; @@ -31,10 +28,7 @@ public class LocalRepositoryRootNode implements IMavenRepositoryNode { @Override public Object[] getChildren() { - NexusIndexManager indexManager = (NexusIndexManager) MavenPlugin.getIndexManager(); - NexusIndex localIndex = indexManager.getLocalIndex(); - NexusIndex workspaceIndex = indexManager.getWorkspaceIndex(); - return new Object[] {new LocalRepositoryNode(localIndex), new WorkspaceRepositoryNode(workspaceIndex)}; + return new Object[] {new LocalRepositoryNode(), new WorkspaceRepositoryNode()}; } @Override diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/ProjectRepositoriesNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/ProjectRepositoriesNode.java index 81af33579e..42955a1196 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/ProjectRepositoriesNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/ProjectRepositoriesNode.java @@ -18,8 +18,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; import org.eclipse.m2e.core.repository.IRepository; import org.eclipse.m2e.core.repository.IRepositoryRegistry; import org.eclipse.m2e.core.ui.internal.MavenImages; @@ -31,17 +29,13 @@ */ public class ProjectRepositoriesNode implements IMavenRepositoryNode { - private final NexusIndexManager indexManager = (NexusIndexManager) MavenPlugin.getIndexManager(); - private final IRepositoryRegistry repositoryRegistry = MavenPlugin.getRepositoryRegistry(); @Override public Object[] getChildren() { ArrayList nodes = new ArrayList<>(); for(IRepository repo : repositoryRegistry.getRepositories(IRepositoryRegistry.SCOPE_PROJECT)) { - NexusIndex index = indexManager.getIndex(repo); - RepositoryNode node = new RepositoryNode(index); - nodes.add(node); + nodes.add(new RepositoryNode(repo)); } return nodes.toArray(new Object[nodes.size()]); } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RemoteRepositoryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RemoteRepositoryNode.java new file mode 100644 index 0000000000..9b96814164 --- /dev/null +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RemoteRepositoryNode.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2008-2010 Sonatype, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Sonatype, Inc. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.m2e.core.ui.internal.views.nodes; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.eclipse.swt.graphics.Image; + +import org.eclipse.m2e.core.repository.IRepository; +import org.eclipse.m2e.core.ui.internal.MavenImages; + + +/** + * AbstractIndexedRepository + * + * @author igor + */ +public abstract class RemoteRepositoryNode implements IMavenRepositoryNode { + private static final Logger log = LoggerFactory.getLogger(RemoteRepositoryNode.class); + + protected static final Object[] NO_CHILDREN = new Object[0]; + + protected final IRepository repository; + + protected RemoteRepositoryNode(IRepository repository) { + this.repository = repository; + } + + @Override + public Object[] getChildren() { + return NO_CHILDREN; + } + + @Override + public Image getImage() { + return MavenImages.IMG_INDEX; + } + + @Override + public boolean hasChildren() { + return false; + } + + @Override + public boolean isUpdating() { + return false; + } + + + public String getRepositoryUrl() { + return repository.getUrl(); + } + +} diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RepositoryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RepositoryNode.java index 9c883868b9..ae1459a7eb 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RepositoryNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/RepositoryNode.java @@ -13,7 +13,8 @@ package org.eclipse.m2e.core.ui.internal.views.nodes; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; +import org.eclipse.swt.graphics.Image; + import org.eclipse.m2e.core.repository.IRepository; import org.eclipse.m2e.core.ui.internal.Messages; @@ -23,13 +24,12 @@ * * @author dyocum */ -public class RepositoryNode extends AbstractIndexedRepositoryNode { +public class RepositoryNode implements IMavenRepositoryNode { - private final IRepository repository; + protected final IRepository repository; - public RepositoryNode(NexusIndex index) { - super(index); - this.repository = index.getRepository(); + public RepositoryNode(IRepository repository) { + this.repository = repository; } @Override @@ -49,13 +49,33 @@ public String getName() { return sb.toString(); } - @Override - public String getRepositoryUrl() { - return repository.getUrl(); - } public String getRepoName() { return repository.toString(); } + @Override + public Object[] getChildren() { + return new Object[0]; + } + + @Override + public Image getImage() { + return null; + } + + @Override + public boolean hasChildren() { + return false; + } + + @Override + public boolean isUpdating() { + return false; + } + + public String getRepositoryUrl() { + return repository.getUrl(); + } + } diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/WorkspaceRepositoryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/WorkspaceRepositoryNode.java index ec03804ccb..d3405de722 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/WorkspaceRepositoryNode.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/views/nodes/WorkspaceRepositoryNode.java @@ -13,7 +13,7 @@ package org.eclipse.m2e.core.ui.internal.views.nodes; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndex; +import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.ui.internal.Messages; @@ -22,10 +22,10 @@ * * @author igor */ -public class WorkspaceRepositoryNode extends AbstractIndexedRepositoryNode { +public class WorkspaceRepositoryNode extends RepositoryNode { - public WorkspaceRepositoryNode(NexusIndex index) { - super(index); + public WorkspaceRepositoryNode() { + super(MavenPlugin.getRepositoryRegistry().getWorkspaceRepository()); } @Override diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java index ad34c3ef75..12270e9887 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenInstallFileArtifactWizardPage.java @@ -242,23 +242,19 @@ void updateFileName(String fileName) { pomFileNameText.setText(""); //$NON-NLS-1$ } - try { - IndexedArtifactFile iaf = MavenPlugin.getIndexManager().getAllIndexes().identify(file); - if(iaf != null) { - groupIdCombo.setText(iaf.group); - artifactIdCombo.setText(iaf.artifact); - versionCombo.setText(iaf.version); - if(iaf.classifier != null) { - classifierCombo.setText(iaf.classifier); - } - - String name = iaf.group + ":" + iaf.artifact + "-" + iaf.version // //$NON-NLS-1$ //$NON-NLS-2$ - + (iaf.classifier == null ? "" : iaf.classifier); //$NON-NLS-1$ - setMessage(NLS.bind(Messages.MavenInstallFileArtifactWizardPage_message, name), WARNING); - return; + IndexedArtifactFile iaf = null; // TODO used to be some indexer request + if(iaf != null) { + groupIdCombo.setText(iaf.group); + artifactIdCombo.setText(iaf.artifact); + versionCombo.setText(iaf.version); + if(iaf.classifier != null) { + classifierCombo.setText(iaf.classifier); } - } catch(CoreException ex) { - log.error(ex.getMessage(), ex); + + String name = iaf.group + ":" + iaf.artifact + "-" + iaf.version // //$NON-NLS-1$ //$NON-NLS-2$ + + (iaf.classifier == null ? "" : iaf.classifier); //$NON-NLS-1$ + setMessage(NLS.bind(Messages.MavenInstallFileArtifactWizardPage_message, name), WARNING); + return; } if(n > -1) { diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java index fb81bdd517..8a4d9cf18a 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomSelectionComponent.java @@ -15,9 +15,7 @@ import java.text.DateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -63,17 +61,12 @@ import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; -import org.apache.lucene.search.BooleanQuery; - import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.embedder.ArtifactKey; import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexManager; import org.eclipse.m2e.core.internal.index.IndexedArtifact; import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.UserInputSearchExpression; import org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager; import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator; import org.eclipse.m2e.core.ui.internal.MavenImages; @@ -238,7 +231,7 @@ void selectFirstElementInTheArtifactTreeIfNoSelectionHasBeenMade() { } protected boolean showClassifiers() { - return (IIndex.SEARCH_ARTIFACT.equals(queryType)); + return true; } public void init(String queryText, String queryType, IProject project, Set artifacts, @@ -391,14 +384,12 @@ List getSelectedIndexedArtifactFiles(IStructuredSelection s void scheduleSearch(String query, boolean delay) { if(query != null && query.length() > 2) { if(searchJob == null) { - IndexManager indexManager = MavenPlugin.getIndexManager(); - searchJob = new SearchJob(queryType, indexManager); + searchJob = new SearchJob(queryType); } else { if(!searchJob.cancel()) { //for already running ones, just create new instance so that the previous one can peacefully die //without preventing the new one from completing first - IndexManager indexManager = MavenPlugin.getIndexManager(); - searchJob = new SearchJob(queryType, indexManager); + searchJob = new SearchJob(queryType); } } searchJob.setQuery(query.toLowerCase()); @@ -423,18 +414,15 @@ public static String getKey(IndexedArtifact art) { */ private class SearchJob extends Job { - private final IndexManager indexManager; - private String query; private final String field; private volatile boolean stop = false; - public SearchJob(String field, IndexManager indexManager) { + public SearchJob(String field) { super(Messages.MavenPomSelectionComponent_searchJob); this.field = field; - this.indexManager = indexManager; } public void setQuery(String query) { @@ -447,52 +435,18 @@ public boolean shouldRun() { return super.shouldRun(); } - public int getClassifier() { - // mkleint: no more allowing people to opt in/out displaying javadoc and sources.. - // allow tests and every other classifier.. - return IIndex.SEARCH_JARS + IIndex.SEARCH_TESTS; - } - @Override protected IStatus run(IProgressMonitor monitor) { - int classifier = showClassifiers() ? getClassifier() : IIndex.SEARCH_ALL; if(searchResultViewer == null || searchResultViewer.getControl() == null || searchResultViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } if(query != null) { String activeQuery = query; - try { - setResult(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_searching, activeQuery.toLowerCase()), - null); - - Map res = indexManager.getAllIndexes().search( - new UserInputSearchExpression(activeQuery), field, classifier); - - //335139 have the managed entries always come up as first results - LinkedHashMap managed = new LinkedHashMap<>(); - LinkedHashMap nonManaged = new LinkedHashMap<>(); - for(Map.Entry art : res.entrySet()) { - String key = art.getValue().getGroupId() + ":" + art.getValue().getArtifactId(); //$NON-NLS-1$ - if(managedKeys.contains(key)) { - managed.put(art.getKey(), art.getValue()); - } else { - nonManaged.put(art.getKey(), art.getValue()); - } - } - managed.putAll(nonManaged); - setResult(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_results, activeQuery, res.size()), managed); - } catch(BooleanQuery.TooManyClauses ex) { - setResult(IStatus.ERROR, Messages.MavenPomSelectionComponent_toomany, - Collections. emptyMap()); - } catch(final RuntimeException ex) { - setResult(IStatus.ERROR, NLS.bind(Messages.MavenPomSelectionComponent_error, ex.toString()), - Collections. emptyMap()); - } catch(final Exception ex) { - setResult(IStatus.ERROR, NLS.bind(Messages.MavenPomSelectionComponent_error, ex.getMessage()), - Collections. emptyMap()); - } + setResult(IStatus.OK, NLS.bind(Messages.MavenPomSelectionComponent_searching, activeQuery.toLowerCase()), null); } + // TODO used to be indexer, replace with Central search + return Status.OK_STATUS; } @@ -566,14 +520,14 @@ public Color getBackground(Object element) { public Image getImage(Object element) { if(element instanceof IndexedArtifactFile) { IndexedArtifactFile f = (IndexedArtifactFile) element; - if(managedKeys.contains(getKey(f))) { - return MavenImages.getOverlayImage(f.sourcesExists == IIndex.PRESENT ? MavenImages.PATH_VERSION_SRC - : MavenImages.PATH_VERSION, MavenImages.PATH_LOCK, IDecoration.BOTTOM_LEFT); - } - - if(f.sourcesExists == IIndex.PRESENT) { - return MavenImages.IMG_VERSION_SRC; - } +// if(managedKeys.contains(getKey(f))) { +// return MavenImages.getOverlayImage(f.sourcesExists == IIndex.PRESENT ? MavenImages.PATH_VERSION_SRC +// : MavenImages.PATH_VERSION, MavenImages.PATH_LOCK, IDecoration.BOTTOM_LEFT); +// } + +// if(f.sourcesExists == IIndex.PRESENT) { +// return MavenImages.IMG_VERSION_SRC; +// } return MavenImages.IMG_VERSION; } else if(element instanceof IndexedArtifact) { IndexedArtifact i = (IndexedArtifact) element; diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java index 6e9e914d51..6006c4f002 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java @@ -85,17 +85,12 @@ import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.archetype.ArchetypeUtil; -import org.eclipse.m2e.core.embedder.ArtifactKey; import org.eclipse.m2e.core.embedder.IMaven; import org.eclipse.m2e.core.internal.MavenPluginActivator; import org.eclipse.m2e.core.internal.archetype.ArchetypeCatalogFactory; import org.eclipse.m2e.core.internal.archetype.ArchetypeManager; -import org.eclipse.m2e.core.internal.index.IMutableIndex; -import org.eclipse.m2e.core.internal.index.IndexListener; -import org.eclipse.m2e.core.internal.index.IndexManager; import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants; import org.eclipse.m2e.core.project.ProjectImportConfiguration; -import org.eclipse.m2e.core.repository.IRepository; import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator; import org.eclipse.m2e.core.ui.internal.Messages; import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils; @@ -105,7 +100,7 @@ * Maven Archetype selection wizard page presents the user with a list of available Maven Archetypes available for * creating new project. */ -public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage implements IndexListener { +public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage { private static final Logger log = LoggerFactory.getLogger(MavenProjectWizardArchetypePage.class); private static final String KEY_CATALOG = "catalog"; //$NON-NLS-1$ @@ -179,7 +174,6 @@ public void createControl(Composite parent) { createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); - MavenPlugin.getIndexManager().addIndexListener(this); setControl(composite); } @@ -526,7 +520,6 @@ public void dispose() { job.cancel(); job = null; } - MavenPlugin.getIndexManager().removeIndexListener(this); archetypesCache.clear(); super.dispose(); } @@ -614,8 +607,6 @@ public void done(IJobChangeEvent event) { Collection catalogs = archetypeManager.getActiveArchetypeCatalogs(); if(catalogs.isEmpty()) { error = Messages.MavenProjectWizardArchetypePage_error_noEnabledCatalogs; - } else if(catalogFactory != null && "Nexus Indexer".equals(catalogFactory.getDescription())) { //$NON-NLS-1$ - error = Messages.MavenProjectWizardArchetypePage_error_emptyNexusIndexer; } else { error = Messages.MavenProjectWizardArchetypePage_error_emptyCatalog; } @@ -831,9 +822,6 @@ protected void downloadArchetype(final String archetypeGroupId, final String arc } monitor.subTask(org.eclipse.m2e.core.ui.internal.Messages.MavenProjectWizardArchetypePage_task_indexing); - IndexManager indexManager = MavenPlugin.getIndexManager(); - IMutableIndex localIndex = indexManager.getLocalIndex(); - localIndex.addArtifact(jarFile, new ArtifactKey(pomArtifact)); //save out the archetype //TODO move this logic out of UI code! @@ -1009,11 +997,6 @@ public void widgetDefaultSelected(SelectionEvent e) { } } - @Override - public void indexAdded(IRepository repository) { - - } - //reload the table when index updating finishes //try to preserve selection in case this is a rebuild protected void reloadViewer() { @@ -1033,19 +1016,6 @@ protected void reloadViewer() { }); } - @Override - public void indexChanged(IRepository repository) { - reloadViewer(); - } - - @Override - public void indexRemoved(IRepository repository) { - } - - @Override - public void indexUpdating(IRepository repository) { - } - private class RetrievingArchetypesJob extends Job { List catalogArchetypes; diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF index 060dfd12f6..68b1ef6feb 100644 --- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF @@ -2,14 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true -Bundle-Version: 1.18.4.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin Require-Bundle: org.eclipse.osgi;bundle-version="3.10.0", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.archetype.common;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.indexer;bundle-version="[1.17.1,2.0.0)", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.archetype.common;bundle-version="1.16.0", org.eclipse.m2e.workspace.cli;bundle-version="0.1.0", org.eclipse.core.runtime;bundle-version="3.12.0", org.eclipse.core.resources;bundle-version="3.9.0", @@ -29,7 +28,6 @@ Export-Package: org.eclipse.m2e.core, org.eclipse.m2e.core.internal.equinox;x-internal:=true, org.eclipse.m2e.core.internal.index;x-internal:=true, org.eclipse.m2e.core.internal.index.filter;x-internal:=true, - org.eclipse.m2e.core.internal.index.nexus;x-internal:=true, org.eclipse.m2e.core.internal.jobs;x-internal:=true, org.eclipse.m2e.core.internal.launch;x-internal:=true, org.eclipse.m2e.core.internal.lifecyclemapping;x-internal:=true, diff --git a/org.eclipse.m2e.core/pom.xml b/org.eclipse.m2e.core/pom.xml index 7b779e05a9..bbf449043c 100644 --- a/org.eclipse.m2e.core/pom.xml +++ b/org.eclipse.m2e.core/pom.xml @@ -19,7 +19,7 @@ org.eclipse.m2e.core - 1.18.4-SNAPSHOT + 2.0.0-SNAPSHOT eclipse-plugin Maven Integration for Eclipse Core Plug-in diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java index bbd1a6ad39..818b491fd3 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java @@ -18,7 +18,6 @@ import org.eclipse.m2e.core.embedder.MavenModelManager; import org.eclipse.m2e.core.embedder.MavenRuntimeManager; import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.index.IndexManager; import org.eclipse.m2e.core.project.IMavenProjectRegistry; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.IWorkspaceClassifierResolverManager; @@ -58,10 +57,6 @@ public static IRepositoryRegistry getRepositoryRegistry() { return MavenPluginActivator.getDefault().getRepositoryRegistry(); } - public static IndexManager getIndexManager() { - return MavenPluginActivator.getDefault().getIndexManager(); - } - public static IMavenConfiguration getMavenConfiguration() { return MavenPluginActivator.getDefault().getMavenConfiguration(); } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java index dc2aa96fd3..c45ebe521c 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java @@ -59,7 +59,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactCollector; import org.apache.maven.execution.MavenSession; -import org.apache.maven.index.updater.IndexUpdater; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.DefaultProjectBuilder; import org.apache.maven.repository.legacy.WagonManager; @@ -71,9 +70,6 @@ import org.eclipse.m2e.core.internal.archetype.ArchetypeManager; import org.eclipse.m2e.core.internal.embedder.MavenImpl; import org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager; -import org.eclipse.m2e.core.internal.index.nexus.IndexesExtensionReader; -import org.eclipse.m2e.core.internal.index.nexus.IndexingTransferListener; -import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager; import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl; import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory; import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager; @@ -106,8 +102,6 @@ public class MavenPluginActivator extends Plugin { private MavenModelManager modelManager; - private NexusIndexManager indexManager; - private BundleContext bundleContext; private MavenProjectManager projectManager; @@ -277,7 +271,6 @@ protected void configure() { private static ArchetypeManager newArchetypeManager(PlexusContainer container, File stateLocationDir) { ArchetypeManager archetypeManager = new ArchetypeManager(container, new File(stateLocationDir, PREFS_ARCHETYPES)); - archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.NexusIndexerCatalogFactory()); archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.InternalCatalogFactory()); archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.DefaultLocalCatalogFactory()); for(ArchetypeCatalogFactory archetypeCatalogFactory : ExtensionReader.readArchetypeExtensions()) { @@ -325,9 +318,6 @@ public void stop(BundleContext context) throws Exception { this.mavenBackgroundJob = null; this.projectManager.removeMavenProjectChangedListener(this.configurationManager); - if(indexManager != null) { - this.projectManager.removeMavenProjectChangedListener(indexManager); - } this.projectManager.removeMavenProjectChangedListener(repositoryRegistry); this.projectManager = null; @@ -362,27 +352,6 @@ public ProjectRegistryManager getMavenProjectManagerImpl() { return this.managerImpl; } - public NexusIndexManager getIndexManager() { - synchronized(this) { - if(this.indexManager == null) { - try { - PlexusContainer indexerContainer = newPlexusContainer(IndexUpdater.class.getClassLoader()); - toDisposeContainers.add(indexerContainer); - this.indexManager = new NexusIndexManager(indexerContainer, getMavenProjectManager(), getRepositoryRegistry(), - getStateLocation().toFile()); - getMavenProjectManager().addMavenProjectChangedListener(indexManager); - getMaven().addLocalRepositoryListener(new IndexingTransferListener(indexManager)); - ((RepositoryRegistry) getRepositoryRegistry()).addRepositoryIndexer(indexManager); - ((RepositoryRegistry) getRepositoryRegistry()) - .addRepositoryDiscoverer(new IndexesExtensionReader(indexManager)); - } catch(PlexusContainerException ex1) { - log.error("Failed to initialize the NexusIndexManager", ex1); - } - } - } - return this.indexManager; - } - public MavenRuntimeManagerImpl getMavenRuntimeManager() { return this.runtimeManager; } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/archetype/ArchetypeCatalogFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/archetype/ArchetypeCatalogFactory.java index a670524644..00bc7b4345 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/archetype/ArchetypeCatalogFactory.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/archetype/ArchetypeCatalogFactory.java @@ -96,30 +96,6 @@ protected ArchetypeManager getArchetyper() { return MavenPluginActivator.getDefault().getArchetypeManager().getArchetyper(); } - /** - * Factory for Nexus Indexer ArchetypeCatalog - */ - public static class NexusIndexerCatalogFactory extends ArchetypeCatalogFactory { - public static final String ID = "nexusIndexer"; //$NON-NLS-1$ - - public NexusIndexerCatalogFactory() { - super(ID, Messages.ArchetypeCatalogFactory_indexer_catalog, false); - } - - @Override - public ArchetypeCatalog getArchetypeCatalog() throws CoreException { - try { - ArchetypeDataSource source = MavenPluginActivator.getDefault().getIndexManager().getArchetypeCatalog(); - return source.getArchetypeCatalog(new Properties()); - } catch(ArchetypeDataSourceException ex) { - String msg = NLS.bind(Messages.ArchetypeCatalogFactory_error_missing_catalog, ex.getMessage()); - log.error(msg, ex); - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, msg, ex)); - } - } - - } - /** * Factory for internal ArchetypeCatalog */ diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/equinox/EquinoxLocker.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/equinox/EquinoxLocker.java deleted file mode 100644 index a5ad311e9c..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/equinox/EquinoxLocker.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Igor Fedorenko - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Igor Fedorenko - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.equinox; - -import java.io.File; - -import org.eclipse.osgi.internal.location.LocationHelper; -import org.eclipse.osgi.internal.location.Locker; - - -/** - * Adaptor for Equinox internal file Locker implementation - * - * @since 1.5 - */ -@SuppressWarnings("restriction") -public class EquinoxLocker implements org.apache.maven.index.fs.Locker { - - private static class EquinoxLock implements org.apache.maven.index.fs.Lock { - - private final Locker locker; - - public EquinoxLock(Locker locker) { - this.locker = locker; - } - - @Override - public void release() { - locker.release(); - } - } - - @Override - public org.apache.maven.index.fs.Lock lock(File directory) { - File lock = new File(directory, LOCK_FILE); - return new EquinoxLock(LocationHelper.createLocker(lock, null /*lockMode*/, false /*debug*/)); - } -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IMutableIndex.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IMutableIndex.java deleted file mode 100644 index eef4b0a652..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IMutableIndex.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index; - -import java.io.File; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.m2e.core.embedder.ArtifactKey; - - -/** - * @author igor - */ -public interface IMutableIndex extends IIndex { - - // index content manipulation - - void addArtifact(File pomFile, ArtifactKey artifactKey); - - void removeArtifact(File pomFile, ArtifactKey artifactKey); - - // reindexing - - void updateIndex(boolean force, IProgressMonitor monitor) throws CoreException; - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexListener.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexListener.java deleted file mode 100644 index dda28caf0c..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexListener.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index; - -import org.eclipse.m2e.core.repository.IRepository; - - -/** - * IndexListener - * - * @author Eugene Kuleshov - */ -public interface IndexListener { - - void indexAdded(IRepository repository); - - void indexRemoved(IRepository repository); - - void indexChanged(IRepository repository); - - void indexUpdating(IRepository repository); - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexManager.java deleted file mode 100644 index 1b86db60a5..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/IndexManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; - - -public interface IndexManager { - - // well-known indexes - - String LOCAL_INDEX = "local"; //$NON-NLS-1$ - - String WORKSPACE_INDEX = "workspace"; //$NON-NLS-1$ - - // - - IMutableIndex getWorkspaceIndex(); - - IMutableIndex getLocalIndex(); - - /** - * For Maven projects, returns index of all repositories configured for the project. Index includes repositories - * defined in the project pom.xml, inherited from parent projects and defined in enabled profiles in settings.xml. If - * project is null or is not a maven project, returns index that includes repositories defined in profiles enabled by - * default in settings.xml. - */ - IIndex getIndex(IProject project) throws CoreException; - - /** - * Returns index aggregating all indexes enabled for repositories defined in settings.xml - * - * @return - * @throws CoreException - */ - IIndex getAllIndexes() throws CoreException; - - // - - void removeIndexListener(IndexListener listener); - - void addIndexListener(IndexListener listener); -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java deleted file mode 100644 index 1ed1a63304..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/filter/FilteredIndex.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2018 Sonatype, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.filter; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.SearchExpression; - - -/** - * FilteredIndex - * - * @author igor - */ -public class FilteredIndex implements IIndex { - - private final IIndex index; - - private final IProject project; - - public FilteredIndex(IProject project, IIndex index) { - this.project = project; - this.index = index; - } - - @Override - public IndexedArtifactFile getIndexedArtifactFile(ArtifactKey artifact) throws CoreException { - return index.getIndexedArtifactFile(artifact); - } - - @Override - public IndexedArtifactFile identify(File file) throws CoreException { - return index.identify(file); - } - - @Override - public Collection find(SearchExpression groupId, SearchExpression artifactId, - SearchExpression version, SearchExpression packaging) throws CoreException { - return filter(index.find(groupId, artifactId, version, packaging)); - } - - @Override - public Collection find(Collection groupId, - Collection artifactId, Collection version, - Collection packaging) throws CoreException { - return filter(index.find(groupId, artifactId, version, packaging)); - } - - @Override - public Map search(SearchExpression expression, String searchType) throws CoreException { - return filter(index.search(expression, searchType)); - } - - @Override - public Map search(SearchExpression expression, String searchType, int classifier) - throws CoreException { - return filter(index.search(expression, searchType, classifier)); - } - - // filter methods - - protected Collection filter(Collection indexedArtifacts) { - ArrayList result = new ArrayList<>(); - for(IndexedArtifact indexedArtifact : indexedArtifacts) { - indexedArtifact = filter(indexedArtifact); - if(indexedArtifact != null && !indexedArtifact.getFiles().isEmpty()) { - result.add(indexedArtifact); - } - } - return result; - } - - protected IndexedArtifact filter(IndexedArtifact original) { - ArtifactFilterManager arifactFilterManager = MavenPluginActivator.getDefault().getArifactFilterManager(); - IndexedArtifact result = new IndexedArtifact(original.getGroupId(), original.getArtifactId(), - original.getPackageName(), original.getClassname(), original.getPackaging()); - for(IndexedArtifactFile file : original.getFiles()) { - if(arifactFilterManager.filter(project, file.getAdapter(ArtifactKey.class)).isOK()) { - result.addFile(file); - } - } - return result; - } - - private Map filter(Map original) { - LinkedHashMap result = new LinkedHashMap<>(); - for(Map.Entry entry : original.entrySet()) { - IndexedArtifact filtered = filter(entry.getValue()); - if(filtered != null && !filtered.getFiles().isEmpty()) { - result.put(entry.getKey(), filtered); - } - } - return result; - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java deleted file mode 100644 index acd86c872f..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.NoSuchAlgorithmException; -import java.util.HashMap; -import java.util.Map; - -import javax.net.ssl.SSLContext; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.apache.maven.index.updater.ResourceFetcher; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.proxy.ProxyInfo; -import org.apache.maven.wagon.proxy.ProxyUtils; - -import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.Messages; - -import io.takari.aether.client.AetherClient; -import io.takari.aether.client.AetherClientAuthentication; -import io.takari.aether.client.AetherClientConfig; -import io.takari.aether.client.AetherClientProxy; -import io.takari.aether.client.Response; -import io.takari.aether.okhttp.OkHttpAetherClient; - - -public class AetherClientResourceFetcher implements ResourceFetcher { - - private AetherClient aetherClient; - - private final AuthenticationInfo authInfo; - - private final ProxyInfo proxyInfo; - - private final String userAgent; - - private final IProgressMonitor monitor; - - private String baseUrl; - - public AetherClientResourceFetcher(final AuthenticationInfo authInfo, final ProxyInfo proxyInfo, - final IProgressMonitor monitor) { - this.authInfo = authInfo; - this.proxyInfo = proxyInfo; - this.monitor = (monitor != null) ? monitor : new NullProgressMonitor(); - this.userAgent = MavenPluginActivator.getUserAgent(); - } - - @Override - public void connect(String id, String url) { - this.baseUrl = url; - aetherClient = new OkHttpAetherClient( - new AetherClientConfigAdapter(baseUrl, authInfo, proxyInfo, userAgent, - new HashMap())); - } - - @Override - public void disconnect() throws IOException { - aetherClient.close(); - } - - @Deprecated - public void retrieve(String name, File targetFile) throws IOException, FileNotFoundException { - String url = baseUrl + "/" + name; - try (Response response = aetherClient.get(url); - InputStream is = response.getInputStream(); - OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile))) { - final byte[] buffer = new byte[1024 * 1024]; - int n = 0; - while(-1 != (n = is.read(buffer))) { - os.write(buffer, 0, n); - if(monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } - } - } - - @Override - public InputStream retrieve(String name) throws IOException, FileNotFoundException { - String url = baseUrl + "/" + name; - Response response = aetherClient.get(url); - - return response.getInputStream(); - } - - class AetherClientConfigAdapter extends AetherClientConfig { - private final Logger log = LoggerFactory.getLogger(AetherClientConfigAdapter.class); - - int connectionTimeout; - - int requestTimeout; - - AuthenticationInfo authInfo; - - ProxyInfo proxyInfo; - - String userAgent; - - String baseUrl; - - Map headers; - - public AetherClientConfigAdapter(String baseUrl, AuthenticationInfo authInfo, ProxyInfo proxyInfo, String userAgent, - Map headers) { - this.baseUrl = baseUrl; - this.authInfo = authInfo; - this.proxyInfo = proxyInfo; - this.userAgent = userAgent; - this.headers = headers; - - try { - // ensure JVM's trust & key stores are used - setSslSocketFactory(SSLContext.getDefault().getSocketFactory()); - } catch(NoSuchAlgorithmException ex) { - log.warn(Messages.AetherClientConfigAdapter_error_sslContext); - } - } - - @Override - public String getUserAgent() { - return userAgent; - } - - @Override - public int getConnectionTimeout() { - return connectionTimeout; - } - - @Override - public int getRequestTimeout() { - return requestTimeout; - } - - @Override - public AetherClientProxy getProxy() { - - if(proxyInfo == null) { - return null; - } - //Bug 512006 don't return the proxy for nonProxyHosts - try { - if(ProxyUtils.validateNonProxyHosts(proxyInfo, new URL(baseUrl).getHost())) { - return null; - } - } catch(MalformedURLException ignore) { - } - - return new AetherClientProxy() { - - @Override - public String getHost() { - return proxyInfo.getHost(); - } - - @Override - public int getPort() { - return proxyInfo.getPort(); - } - - @Override - public AetherClientAuthentication getAuthentication() { - - if(proxyInfo != null && proxyInfo.getUserName() != null && proxyInfo.getPassword() != null) { - return new AetherClientAuthentication(proxyInfo.getUserName(), proxyInfo.getPassword()); - } - return null; - } - }; - } - - @Override - public AetherClientAuthentication getAuthentication() { - - if(authInfo != null) { - return new AetherClientAuthentication(authInfo.getUserName(), authInfo.getPassword()); - } - return null; - } - - @Override - public Map getHeaders() { - return headers; - } - } -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/ArtifactScanningMonitor.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/ArtifactScanningMonitor.java deleted file mode 100644 index 5beb9b5b9d..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/ArtifactScanningMonitor.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.File; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.apache.maven.index.ArtifactContext; -import org.apache.maven.index.ArtifactScanningListener; -import org.apache.maven.index.ScanningResult; -import org.apache.maven.index.context.IndexingContext; - - -class ArtifactScanningMonitor implements ArtifactScanningListener { - private static final Logger log = LoggerFactory.getLogger(ArtifactScanningMonitor.class); - - private static final long THRESHOLD = 1 * 1000L; - - //private final IndexInfo indexInfo; - - private final IProgressMonitor monitor; - - private long timestamp = System.currentTimeMillis(); - - private final File repositoryDir; - - ArtifactScanningMonitor(File repositoryDir, IProgressMonitor monitor) { - //this.indexInfo = indexInfo; - this.repositoryDir = repositoryDir; - this.monitor = monitor; - } - - @Override - public void scanningStarted(IndexingContext ctx) { - } - - @Override - public void scanningFinished(IndexingContext ctx, ScanningResult result) { - } - - @Override - public void artifactDiscovered(ArtifactContext ac) { - long current = System.currentTimeMillis(); - if((current - timestamp) > THRESHOLD) { - // String id = info.groupId + ":" + info.artifactId + ":" + info.version; - String id = ac.getPom().getAbsolutePath().substring(this.repositoryDir.getAbsolutePath().length()); - this.monitor.setTaskName(id); - this.timestamp = current; - } - } - - @Override - public void artifactError(ArtifactContext ac, Exception e) { - String id = ac.getPom().getAbsolutePath().substring(repositoryDir.getAbsolutePath().length()); - log.error(id + " " + e.getMessage()); //$NON-NLS-1$ - } -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/CompositeIndex.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/CompositeIndex.java deleted file mode 100644 index bdaece0881..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/CompositeIndex.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.SearchExpression; - - -/** - * CompositeIndex - * - * @author igor - */ -public class CompositeIndex implements IIndex { - - private final List indexes; - - public CompositeIndex(List indexes) { - this.indexes = indexes; - } - - @Override - public IndexedArtifactFile getIndexedArtifactFile(ArtifactKey artifact) throws CoreException { - for(IIndex index : indexes) { - IndexedArtifactFile aif = index.getIndexedArtifactFile(artifact); - if(aif != null) { - // first one wins - return aif; - } - } - - // did not find anything - return null; - } - - @Override - public IndexedArtifactFile identify(File file) throws CoreException { - List aifs = identifyAll(file); - return !aifs.isEmpty() ? aifs.get(0) : null; - } - - public List identifyAll(File file) throws CoreException { - List result = new ArrayList<>(); - - for(IIndex index : indexes) { - IndexedArtifactFile aif = index.identify(file); - if(aif != null) { - // first one wins - result.add(aif); - } - } - - // did not find anything - return result; - } - - @Override - public Collection find(SearchExpression groupId, SearchExpression artifactId, - SearchExpression version, SearchExpression packaging) throws CoreException { - Set result = new TreeSet<>(); - for(IIndex index : indexes) { - Collection findResults = index.find(groupId, artifactId, version, packaging); - if(findResults != null) { - result.addAll(findResults); - } - } - return result; - } - - @Override - public Collection find(Collection groupId, - Collection artifactId, Collection version, - Collection packaging) throws CoreException { - - Set result = new TreeSet<>(); - for(IIndex index : indexes) { - Collection findResults = index.find(groupId, artifactId, version, packaging); - if(findResults != null) { - result.addAll(findResults); - } - } - return result; - } - - @Override - public Map search(SearchExpression term, String searchType) throws CoreException { - Map result = new TreeMap<>(); - for(IIndex index : indexes) { - Map iresult = index.search(term, searchType); - if(iresult != null) { - result.putAll(iresult); - } - } - return result; - } - - @Override - public Map search(SearchExpression term, String searchType, int classifier) - throws CoreException { - Map result = new TreeMap<>(); - for(IIndex index : indexes) { - Map iresult = index.search(term, searchType, classifier); - if(iresult != null) { - result.putAll(iresult); - } - } - return result; - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexUpdaterJob.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexUpdaterJob.java deleted file mode 100644 index 89886d0595..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexUpdaterJob.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.util.ArrayList; -import java.util.Stack; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.core.runtime.jobs.Job; - -import org.eclipse.m2e.core.internal.IMavenConstants; -import org.eclipse.m2e.core.internal.Messages; -import org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue; - - -class IndexUpdaterJob extends Job implements IBackgroundProcessingQueue { - - public static class IndexUpdaterRule implements ISchedulingRule { - - @Override - public boolean contains(ISchedulingRule rule) { - return rule == this; - } - - @Override - public boolean isConflicting(ISchedulingRule rule) { - return rule == this; - } - - } - - public interface IndexCommand { - void run(IProgressMonitor monitor) throws CoreException; - } - - private final Stack updateQueue = new Stack<>(); - - public IndexUpdaterJob(NexusIndexManager indexManager) { - super(Messages.IndexUpdaterJob_title); - setRule(new IndexUpdaterRule()); - } - - public void addCommand(IndexUpdaterJob.IndexCommand indexCommand) { - updateQueue.add(indexCommand); - } - - @Override - public IStatus run(IProgressMonitor monitor) { - monitor.beginTask(getName(), IProgressMonitor.UNKNOWN); - - ArrayList problems = new ArrayList<>(); - - while(!updateQueue.isEmpty()) { - if(monitor.isCanceled()) { - throw new OperationCanceledException(); - } - - IndexUpdaterJob.IndexCommand command = updateQueue.pop(); - try { - command.run(monitor); - } catch(CoreException ex) { - problems.add(ex.getStatus()); - } - } - - monitor.done(); - - return problems.isEmpty() ? Status.OK_STATUS : new MultiStatus(IMavenConstants.PLUGIN_ID, -1, - problems.toArray(new IStatus[problems.size()]), null, null); - } - - @Override - public boolean isEmpty() { - return updateQueue.isEmpty(); - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexedArtifactGroup.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexedArtifactGroup.java deleted file mode 100644 index 58e4e8dd97..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexedArtifactGroup.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.util.LinkedHashMap; - -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.repository.IRepository; - - -public class IndexedArtifactGroup implements Comparable { - private final IRepository repository; - - private final String prefix; - - private final LinkedHashMap nodes = new LinkedHashMap<>(); - - private final LinkedHashMap files = new LinkedHashMap<>(); - - public IndexedArtifactGroup(IRepository repository, String prefix) { - this.repository = repository; - this.prefix = prefix; - } - - public LinkedHashMap getNodes() { - return nodes; - } - - public LinkedHashMap getFiles() { - return files; - } - - public String getPrefix() { - return prefix; - } - - public IRepository getRepository() { - return this.repository; - } - - /* - * Compare the groups by prefix - */ - @Override - public int compareTo(IndexedArtifactGroup o) { - if(o == null) { - return -1; - } - return getPrefix().compareToIgnoreCase(o.getPrefix()); - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexesExtensionReader.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexesExtensionReader.java deleted file mode 100644 index f7e47eb306..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexesExtensionReader.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; - -import org.eclipse.m2e.core.internal.IMavenConstants; -import org.eclipse.m2e.core.internal.repository.IRepositoryDiscoverer; -import org.eclipse.m2e.core.internal.repository.RepositoryInfo; -import org.eclipse.m2e.core.internal.repository.RepositoryRegistry; -import org.eclipse.m2e.core.repository.IRepositoryRegistry; - - -/** - * IndexesExtensionReader - * - * @author igor - */ -public class IndexesExtensionReader implements IRepositoryDiscoverer { - - private static final String EXTENSION_INDEXES = IMavenConstants.PLUGIN_ID + ".indexes"; //$NON-NLS-1$ - - private static final String ELEMENT_INDEX = "index"; //$NON-NLS-1$ - - private static final String ATTR_INDEX_ID = "indexId"; //$NON-NLS-1$ - -// private static final String ATTR_INDEX_ARCHIVE = "archive"; - - private static final String ATTR_REPOSITORY_URL = "repositoryUrl"; //$NON-NLS-1$ - -// private static final String ATTR_UPDATE_URL = "updateUrl"; - - private static final String ATTR_IS_SHORT = "isShort"; //$NON-NLS-1$ - - private final NexusIndexManager indexManager; - - public IndexesExtensionReader(NexusIndexManager indexManager) { - this.indexManager = indexManager; - } - - @Override - public void addRepositories(RepositoryRegistry registry, IProgressMonitor monitor) throws CoreException { - IExtensionPoint indexesExtensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_INDEXES); - if(indexesExtensionPoint != null) { - IExtension[] indexesExtensions = indexesExtensionPoint.getExtensions(); - for(IExtension extension : indexesExtensions) { - IConfigurationElement[] elements = extension.getConfigurationElements(); - for(IConfigurationElement element : elements) { - if(ELEMENT_INDEX.equals(element.getName())) { - processIndexElement(registry, element, monitor); - } - } - } - } - } - - private void processIndexElement(RepositoryRegistry registry, IConfigurationElement element, IProgressMonitor monitor) - throws CoreException { - String indexId = element.getAttribute(ATTR_INDEX_ID); - String repositoryUrl = element.getAttribute(ATTR_REPOSITORY_URL); - boolean isShort = Boolean.parseBoolean(element.getAttribute(ATTR_IS_SHORT)); - -// String indexUpdateUrl = element.getAttribute(ATTR_UPDATE_URL); -// String archive = element.getAttribute(ATTR_INDEX_ARCHIVE); - - RepositoryInfo repository = new RepositoryInfo(indexId, repositoryUrl, IRepositoryRegistry.SCOPE_UNKNOWN, null); - registry.addRepository(repository, monitor); - - // for consistency, always process indexes using our background thread - indexManager - .setIndexDetails(repository, isShort ? NexusIndex.DETAILS_MIN : NexusIndex.DETAILS_FULL, null/*async*/); - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexingTransferListener.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexingTransferListener.java deleted file mode 100644 index 6f5a2d05da..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/IndexingTransferListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.File; - -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.embedder.ILocalRepositoryListener; - - -public class IndexingTransferListener implements ILocalRepositoryListener { - - private final NexusIndexManager indexManager; - - public IndexingTransferListener(NexusIndexManager indexManager) { - this.indexManager = indexManager; - } - - @Override - public void artifactInstalled(File repositoryBasedir, ArtifactKey baseArtifact, ArtifactKey artifact, - File artifactFile) { - NexusIndex localIndex = indexManager.getLocalIndex(); - if(artifactFile.getName().endsWith(".jar")) { //$NON-NLS-1$ - localIndex.addArtifact(artifactFile, artifact); - } - } - -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndex.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndex.java deleted file mode 100644 index 6e8c759c72..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndex.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.search.BooleanQuery; - -import org.apache.maven.index.Field; -import org.apache.maven.index.MAVEN; - -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.internal.index.IMutableIndex; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.SearchExpression; -import org.eclipse.m2e.core.repository.IRepository; - - -/** - * NexusIndex - * - * @author igor - */ -public class NexusIndex implements IMutableIndex { - - /** - * Repository index is disabled. - */ - public static final String DETAILS_DISABLED = "off"; //$NON-NLS-1$ - - /** - * Only artifact index information is used. Classname index is disabled. - */ - public static final String DETAILS_MIN = "min"; //$NON-NLS-1$ - - /** - * Both artifact and classname indexes are used. - */ - public static final String DETAILS_FULL = "full"; //$NON-NLS-1$ - - private final NexusIndexManager indexManager; - - private final IRepository repository; - - private final String indexDetails; - - NexusIndex(NexusIndexManager indexManager, IRepository repository, String indexDetails) { - this.indexManager = indexManager; - this.repository = repository; - this.indexDetails = indexDetails; - } - - public String getRepositoryUrl() { - return this.repository.getUrl(); - } - - public String getIndexDetails() { - return this.indexDetails; - } - - @Override - public void addArtifact(File pomFile, ArtifactKey artifactKey) { - indexManager.addDocument(repository, pomFile, artifactKey); - } - - @Override - public void removeArtifact(File pomFile, ArtifactKey artifactKey) { - indexManager.removeDocument(repository, pomFile, artifactKey, null); - } - - @Override - public Collection find(SearchExpression groupId, SearchExpression artifactId, - SearchExpression version, SearchExpression packaging) throws CoreException { - return find(wrapIfNotNull(groupId), wrapIfNotNull(artifactId), wrapIfNotNull(version), wrapIfNotNull(packaging)); - } - - /** - * Method wrapping one SearchExpression into a collection, if it is not null. - * - * @param sex - * @return - */ - private Collection wrapIfNotNull(SearchExpression se) { - if(se == null) { - return null; - } - return Collections.singleton(se); - } - - @Override - public Collection find(Collection groupId, - Collection artifactId, Collection version, - Collection packaging) throws CoreException { - BooleanQuery.Builder query = new BooleanQuery.Builder(); - - addQueryFromSearchExpressionCollection(query, MAVEN.PACKAGING, packaging); - - addQueryFromSearchExpressionCollection(query, MAVEN.GROUP_ID, groupId); - - addQueryFromSearchExpressionCollection(query, MAVEN.ARTIFACT_ID, artifactId); - - addQueryFromSearchExpressionCollection(query, MAVEN.VERSION, version); - - return indexManager.search(repository, query.build()).values(); - } - - private void addQueryFromSearchExpressionCollection(final BooleanQuery.Builder query, final Field field, - final Collection sec) { - if(sec != null && !sec.isEmpty()) { - if(sec.size() > 1) { - BooleanQuery.Builder q = new BooleanQuery.Builder(); - for(SearchExpression se : sec) { - q.add(indexManager.constructQuery(field, se), Occur.SHOULD); - } - query.add(q.build(), Occur.MUST); - } else { - query.add(indexManager.constructQuery(field, sec.iterator().next()), Occur.MUST); - } - } - } - - @Override - public IndexedArtifactFile getIndexedArtifactFile(ArtifactKey artifact) throws CoreException { - return indexManager.getIndexedArtifactFile(repository, artifact); - } - - @Override - public IndexedArtifactFile identify(File file) throws CoreException { - return indexManager.identify(repository, file); - } - - @Override - public void updateIndex(boolean force, IProgressMonitor monitor) throws CoreException { - indexManager.updateIndex(repository, force, monitor); - } - - public void scheduleIndexUpdate(boolean force) { - indexManager.scheduleIndexUpdate(repository, force); - } - - public IndexedArtifactGroup[] getRootIndexedArtifactGroups() throws CoreException { - return indexManager.getRootIndexedArtifactGroups(repository); - } - - public boolean isUpdating() { - return indexManager.isUpdatingIndex(repository); - } - - public IRepository getRepository() { - return repository; - } - - public boolean isEnabled() { - return DETAILS_MIN.equals(indexDetails) || DETAILS_FULL.equals(indexDetails); - } - - public void setIndexDetails(String details) throws CoreException { - indexManager.setIndexDetails(repository, details, null/*async*/); - } - - @Override - public Map search(SearchExpression term, String searchType) throws CoreException { - return indexManager.search(getRepository(), term, searchType); - } - - @Override - public Map search(SearchExpression term, String searchType, int classifier) - throws CoreException { - return indexManager.search(getRepository(), term, searchType, classifier); - } -} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java deleted file mode 100644 index 64de550c5e..0000000000 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java +++ /dev/null @@ -1,1343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 Sonatype, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sonatype, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.m2e.core.internal.index.nexus; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeMap; -import java.util.WeakHashMap; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.util.NLS; - -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.util.FileUtils; - -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.FSDirectory; - -import org.apache.maven.archetype.source.ArchetypeDataSource; -import org.apache.maven.index.ArtifactContext; -import org.apache.maven.index.ArtifactContextProducer; -import org.apache.maven.index.ArtifactInfo; -import org.apache.maven.index.Field; -import org.apache.maven.index.IteratorSearchRequest; -import org.apache.maven.index.IteratorSearchResponse; -import org.apache.maven.index.MAVEN; -import org.apache.maven.index.NexusIndexer; -import org.apache.maven.index.SearchType; -import org.apache.maven.index.artifact.Gav; -import org.apache.maven.index.context.IndexCreator; -import org.apache.maven.index.context.IndexingContext; -import org.apache.maven.index.creator.JarFileContentsIndexCreator; -import org.apache.maven.index.creator.MavenArchetypeArtifactInfoIndexCreator; -import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator; -import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator; -import org.apache.maven.index.fs.Lock; -import org.apache.maven.index.updater.IndexUpdateRequest; -import org.apache.maven.index.updater.IndexUpdateResult; -import org.apache.maven.index.updater.IndexUpdater; -import org.apache.maven.wagon.authentication.AuthenticationInfo; -import org.apache.maven.wagon.proxy.ProxyInfo; - -import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.embedder.ArtifactKey; -import org.eclipse.m2e.core.embedder.ArtifactRepositoryRef; -import org.eclipse.m2e.core.embedder.IMaven; -import org.eclipse.m2e.core.embedder.IMavenConfiguration; -import org.eclipse.m2e.core.internal.IMavenConstants; -import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.Messages; -import org.eclipse.m2e.core.internal.NoSuchComponentException; -import org.eclipse.m2e.core.internal.equinox.EquinoxLocker; -import org.eclipse.m2e.core.internal.index.IIndex; -import org.eclipse.m2e.core.internal.index.IndexListener; -import org.eclipse.m2e.core.internal.index.IndexManager; -import org.eclipse.m2e.core.internal.index.IndexedArtifact; -import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; -import org.eclipse.m2e.core.internal.index.MatchTyped; -import org.eclipse.m2e.core.internal.index.MatchTyped.MatchType; -import org.eclipse.m2e.core.internal.index.SearchExpression; -import org.eclipse.m2e.core.internal.index.SourcedSearchExpression; -import org.eclipse.m2e.core.internal.index.nexus.IndexUpdaterJob.IndexCommand; -import org.eclipse.m2e.core.internal.repository.IRepositoryIndexer; -import org.eclipse.m2e.core.project.IMavenProjectChangedListener; -import org.eclipse.m2e.core.project.IMavenProjectFacade; -import org.eclipse.m2e.core.project.IMavenProjectRegistry; -import org.eclipse.m2e.core.project.MavenProjectChangedEvent; -import org.eclipse.m2e.core.repository.IRepository; -import org.eclipse.m2e.core.repository.IRepositoryRegistry; - - -/** - * @author Eugene Kuleshov - */ -public class NexusIndexManager implements IndexManager, IMavenProjectChangedListener, IRepositoryIndexer { - private static final Logger log = LoggerFactory.getLogger(NexusIndexManager.class); - - public static final int MIN_CLASS_QUERY_LENGTH = 6; - - /** - * Lazy instantiated nexus indexer instance. - */ - private NexusIndexer indexer; - - /** - * Lazy instantiated nexus indexer's contextProducer. - */ - private ArtifactContextProducer artifactContextProducer; - - /** - * Lock guarding lazy instantiation of indexerLock instance - */ - private final Object indexerLock = new Object(); - - /** - * Lock guarding lazy instantiation of contextProducer instance - */ - private final Object contextProducerLock = new Object(); - - private final IMaven maven; - - private final IMavenProjectRegistry projectManager; - - private final IRepositoryRegistry repositoryRegistry; - - private final List fullCreators; - - private final List minCreators; - - private final File baseIndexDir; - - private final List indexListeners = new ArrayList<>(); - - private NexusIndex localIndex; - - private final NexusIndex workspaceIndex; - - private final IndexUpdaterJob updaterJob; - - private final Properties indexDetails = new Properties(); - - private final Set updatingIndexes = new HashSet<>(); - - private final IndexUpdater indexUpdater; - - private static final EquinoxLocker locker = new EquinoxLocker(); - - /** - * Maps repository UID to the lock object associated with the repository. Entries are only added but never directly - * removed from the map, although jvm garbage collector may remove otherwise unused entries to reclaim the little - * memory they use. Never access this map directly. #getIndexLock must be used to get repository lock object. - */ - private final Map indexLocks = new WeakHashMap<>(); - - private final PlexusContainer container; - - public NexusIndexManager(PlexusContainer container, IMavenProjectRegistry projectManager, - IRepositoryRegistry repositoryRegistry, File stateDir) { - this.container = container; - this.projectManager = projectManager; - this.repositoryRegistry = repositoryRegistry; - this.baseIndexDir = new File(stateDir, "nexus"); //$NON-NLS-1$ - this.maven = MavenPlugin.getMaven(); - - try { - this.indexUpdater = container.lookup(IndexUpdater.class); - this.fullCreators = Collections.unmodifiableList(getFullCreator()); - this.minCreators = Collections.unmodifiableList(getMinCreator()); - } catch(ComponentLookupException ex) { - throw new NoSuchComponentException(ex); - } - - this.updaterJob = new IndexUpdaterJob(this); - - this.workspaceIndex = new NexusIndex(this, repositoryRegistry.getWorkspaceRepository(), NexusIndex.DETAILS_MIN); - } - - private NexusIndex newLocalIndex(IRepository localRepository) { - return new NexusIndex(this, localRepository, NexusIndex.DETAILS_FULL); - } - - private List getFullCreator() throws ComponentLookupException { - List creators = new ArrayList<>(); - IndexCreator min = container.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID); - IndexCreator mavenPlugin = container.lookup(IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID); - IndexCreator mavenArchetype = container.lookup(IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID); - IndexCreator jar = container.lookup(IndexCreator.class, JarFileContentsIndexCreator.ID); - - creators.add(min); - creators.add(jar); - creators.add(mavenPlugin); - creators.add(mavenArchetype); - return creators; - } - - private List getMinCreator() throws ComponentLookupException { - List creators = new ArrayList<>(); - IndexCreator min = container.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID); - IndexCreator mavenArchetype = container.lookup(IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID); - creators.add(min); - creators.add(mavenArchetype); - return creators; - } - - /** for Unit test */ - public IndexedArtifactFile getIndexedArtifactFile(IRepository repository, ArtifactKey gav) throws CoreException { - - try { - BooleanQuery.Builder query = new BooleanQuery.Builder(); - query.add(constructQuery(MAVEN.GROUP_ID, gav.getGroupId(), SearchType.EXACT), BooleanClause.Occur.MUST); - query.add(constructQuery(MAVEN.ARTIFACT_ID, gav.getArtifactId(), SearchType.EXACT), BooleanClause.Occur.MUST); - query.add(constructQuery(MAVEN.VERSION, gav.getVersion(), SearchType.EXACT), BooleanClause.Occur.MUST); - - if(gav.getClassifier() != null) { - query.add(constructQuery(MAVEN.CLASSIFIER, gav.getClassifier(), SearchType.EXACT), BooleanClause.Occur.MUST); - } - - synchronized(getIndexLock(repository)) { - Collection artifactInfo = getIndexer().identify(query.build(), - Collections.singleton(getIndexingContext(repository))); - if(artifactInfo != null && !artifactInfo.isEmpty()) { - return getIndexedArtifactFile((ArtifactInfo) artifactInfo.toArray()[0]); - } - } - } catch(Exception ex) { - String msg = "Illegal artifact coordinate " + ex.getMessage(); - log.error(msg, ex); - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_search, ex)); - } - return null; - } - - /** for Unit test */ - public IndexedArtifactFile getIndexedArtifactFile(ArtifactInfo artifactInfo) { - String groupId = artifactInfo.getGroupId(); - String artifactId = artifactInfo.getArtifactId(); - String repository = artifactInfo.getRepository(); - String version = artifactInfo.getVersion(); - String classifier = artifactInfo.getClassifier(); - String packaging = artifactInfo.getPackaging(); - String fname = artifactInfo.getFileName(); - if(fname == null) { - fname = artifactId + '-' + version - + (classifier != null ? '-' + classifier : "") + (packaging != null ? ('.' + packaging) : ""); //$NON-NLS-1$ //$NON-NLS-2$ - } - - long size = artifactInfo.getSize(); - Date date = new Date(artifactInfo.getLastModified()); - - int sourcesExists = artifactInfo.getSourcesExists().ordinal(); - int javadocExists = artifactInfo.getJavadocExists().ordinal(); - - String prefix = artifactInfo.getPrefix(); - List goals = artifactInfo.getGoals(); - - return new IndexedArtifactFile(repository, groupId, artifactId, version, packaging, classifier, fname, size, date, - sourcesExists, javadocExists, prefix, goals); - } - - public IndexedArtifactFile identify(File file) throws CoreException { - try { - Collection artifactInfo = getIndexer().identify(file); - return artifactInfo == null || artifactInfo.isEmpty() ? null - : getIndexedArtifactFile((ArtifactInfo) artifactInfo.toArray()[0]); - } catch(IOException ex) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_search, ex)); - } - } - - protected IndexedArtifactFile identify(IRepository repository, File file) throws CoreException { - try { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - return null; - } - ArtifactInfo artifactInfo = identify(file, Collections.singleton(context)); - return artifactInfo == null ? null : getIndexedArtifactFile(artifactInfo); - } catch(IOException ex) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_search, ex)); - } - } - - /** - * Method to construct Lucene Queries without need to actually know the structure and details (field names, analyze - * details, etc) of the underlying index. Also, using this methods makes you "future proof". Naturally, at caller - * level you can still combine these queries using BooleanQuery to suit your needs. - * - * @param field - * @param query - * @param type - * @return - */ - public Query constructQuery(Field field, SearchExpression query) { - // let the default be "scored" search - SearchType st = SearchType.SCORED; - - if(query instanceof MatchTyped) { - MatchType mt = ((MatchTyped) query).getMatchType(); - - if(MatchType.EXACT.equals(mt)) { - st = SearchType.EXACT; - } - } - - return constructQuery(field, query.getStringValue(), st); - } - - private Query constructQuery(Field field, String query, SearchType searchType) { - return getIndexer().constructQuery(field, query, searchType); - } - - public Map search(SearchExpression term, String type) throws CoreException { - return search(null, term, type, IIndex.SEARCH_ALL); - } - - public Map search(SearchExpression term, String type, int classifier) throws CoreException { - return search(null, term, type, classifier); - } - - private void addClassifiersToQuery(BooleanQuery.Builder bq, int classifier) { - boolean includeJavaDocs = (classifier & IIndex.SEARCH_JAVADOCS) > 0; - Query tq = null; - if(!includeJavaDocs) { - tq = constructQuery(MAVEN.CLASSIFIER, "javadoc", SearchType.EXACT); //$NON-NLS-1$ - bq.add(tq, Occur.MUST_NOT); - } - boolean includeSources = (classifier & IIndex.SEARCH_SOURCES) > 0; - if(!includeSources) { - tq = constructQuery(MAVEN.CLASSIFIER, "sources", SearchType.EXACT); //$NON-NLS-1$ - bq.add(tq, Occur.MUST_NOT); - } - boolean includeTests = (classifier & IIndex.SEARCH_TESTS) > 0; - if(!includeTests) { - tq = constructQuery(MAVEN.CLASSIFIER, "tests", SearchType.EXACT); //$NON-NLS-1$ - bq.add(tq, Occur.MUST_NOT); - } - } - - /** - * @return Map - */ - protected Map search(IRepository repository, SearchExpression term, String type, - int classifier) throws CoreException { - Query query; - if(IIndex.SEARCH_GROUP.equals(type)) { - query = constructQuery(MAVEN.GROUP_ID, term); - - // query = new TermQuery(new Term(ArtifactInfo.GROUP_ID, term)); - // query = new PrefixQuery(new Term(ArtifactInfo.GROUP_ID, term)); - } else if(IIndex.SEARCH_ARTIFACT.equals(type)) { - BooleanQuery.Builder bq = new BooleanQuery.Builder(); - bq.add(constructQuery(MAVEN.GROUP_ID, term), Occur.SHOULD); - bq.add(constructQuery(MAVEN.ARTIFACT_ID, term), Occur.SHOULD); - bq.add( - constructQuery(MAVEN.SHA1, term.getStringValue(), term.getStringValue().length() == 40 ? SearchType.EXACT - : SearchType.SCORED), Occur.SHOULD); - addClassifiersToQuery(bq, classifier); - query = bq.build(); - - } else if(IIndex.SEARCH_PARENTS.equals(type)) { - if(term == null) { - query = constructQuery(MAVEN.PACKAGING, "pom", SearchType.EXACT); //$NON-NLS-1$ - } else { - BooleanQuery.Builder bq = new BooleanQuery.Builder(); - bq.add(constructQuery(MAVEN.GROUP_ID, term), Occur.SHOULD); - bq.add(constructQuery(MAVEN.ARTIFACT_ID, term), Occur.SHOULD); - bq.add( - constructQuery(MAVEN.SHA1, term.getStringValue(), term.getStringValue().length() == 40 ? SearchType.EXACT - : SearchType.SCORED), Occur.SHOULD); - Query tq = constructQuery(MAVEN.PACKAGING, "pom", SearchType.EXACT); //$NON-NLS-1$ - BooleanQuery.Builder builder = new BooleanQuery.Builder(); - builder.add(bq.build(), Occur.MUST); - builder.add(tq, Occur.FILTER); - query = builder.build(); - } - - } else if(IIndex.SEARCH_PLUGIN.equals(type)) { - if(term == null) { - query = constructQuery(MAVEN.PACKAGING, "maven-plugin", SearchType.EXACT); //$NON-NLS-1$ - } else { - BooleanQuery.Builder bq = new BooleanQuery.Builder(); - bq.add(constructQuery(MAVEN.GROUP_ID, term), Occur.SHOULD); - bq.add(constructQuery(MAVEN.ARTIFACT_ID, term), Occur.SHOULD); - Query tq = constructQuery(MAVEN.PACKAGING, "maven-plugin", SearchType.EXACT); //$NON-NLS-1$ - BooleanQuery.Builder builder = new BooleanQuery.Builder(); - builder.add(bq.build(), Occur.MUST); - builder.add(tq, Occur.FILTER); - query = builder.build(); - } - - } else if(IIndex.SEARCH_ARCHETYPE.equals(type)) { - BooleanQuery.Builder bq = new BooleanQuery.Builder(); - bq.add(constructQuery(MAVEN.GROUP_ID, term), Occur.SHOULD); - bq.add(constructQuery(MAVEN.ARTIFACT_ID, term), Occur.SHOULD); - Query tq = constructQuery(MAVEN.PACKAGING, "maven-archetype", SearchType.EXACT); //$NON-NLS-1$ - BooleanQuery.Builder builder = new BooleanQuery.Builder(); - builder.add(bq.build(), Occur.MUST); - builder.add(tq, Occur.FILTER); - query = builder.build(); - - } else if(IIndex.SEARCH_PACKAGING.equals(type)) { - query = constructQuery(MAVEN.PACKAGING, term); - } else if(IIndex.SEARCH_SHA1.equals(type)) { - // if hash is 40 chars, it is "complete", otherwise assume prefix - query = constructQuery(MAVEN.SHA1, term.getStringValue(), term.getStringValue().length() == 40 ? SearchType.EXACT - : SearchType.SCORED); - } else { - return Collections.emptyMap(); - } - - Map result = new TreeMap<>(); - - try { - IteratorSearchResponse response; - - synchronized(getIndexLock(repository)) { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - response = getIndexer().searchIterator(new IteratorSearchRequest(query)); - } else { - response = getIndexer().searchIterator(new IteratorSearchRequest(query, context)); - } - - for(ArtifactInfo artifactInfo : response.getResults()) { - addArtifactFile(result, getIndexedArtifactFile(artifactInfo), null, null, artifactInfo.getPackaging()); - } - - // https://issues.sonatype.org/browse/MNGECLIPSE-1630 - // lucene can't handle prefix queries that match many index entries. - // to workaround, use term query to locate group artifacts and manually - // match subgroups - if(IIndex.SEARCH_GROUP.equals(type) && context != null) { - Set groups = context.getAllGroups(); - for(String group : groups) { - if(term == null || group.startsWith(term.getStringValue()) && !group.equals(term.getStringValue())) { - String key = getArtifactFileKey(group, group, null, null); - result.put(key, new IndexedArtifact(group, group, null, null, null)); - } - } - } - } - } catch(IOException ex) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_search, ex)); - } - - return result; - } - - /** - * @return Map - */ - protected Map search(IRepository repository, SearchExpression term, String type) - throws CoreException { - return search(repository, term, type, IIndex.SEARCH_ALL); - } - - /** - * @return Map - */ - protected Map search(IRepository repository, Query query) throws CoreException { - Map result = new TreeMap<>(); - try { - IteratorSearchResponse response; - - synchronized(getIndexLock(repository)) { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - response = getIndexer().searchIterator(new IteratorSearchRequest(query)); - } else { - response = getIndexer().searchIterator(new IteratorSearchRequest(query, context)); - } - } - - for(ArtifactInfo artifactInfo : response.getResults()) { - addArtifactFile(result, getIndexedArtifactFile(artifactInfo), null, null, artifactInfo.getPackaging()); - } - - } catch(IOException ex) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_search, ex)); - } - return result; - } - - private void addArtifactFile(Map result, IndexedArtifactFile af, String className, - String packageName, String packaging) { - String group = af.group; - String artifact = af.artifact; - String key = getArtifactFileKey(group, artifact, packageName, className); - IndexedArtifact indexedArtifact = result.get(key); - if(indexedArtifact == null) { - indexedArtifact = new IndexedArtifact(group, artifact, packageName, className, packaging); - result.put(key, indexedArtifact); - } - indexedArtifact.addFile(af); - } - - protected String getArtifactFileKey(String group, String artifact, String packageName, String className) { - return className + " : " + packageName + " : " + group + " : " + artifact; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - private void reindexLocalRepository(IRepository repository, boolean force, final IProgressMonitor monitor) - throws CoreException { - if(!force) { - return; - } - try { - fireIndexUpdating(repository); - //IndexInfo indexInfo = getIndexInfo(indexName); - IndexingContext context = getIndexingContext(repository); - if(context != null) { - // context.purge(); // TODO: use this again as soon as maven-indexer 6.1.0 is available - // --- Workaround for https://issues.apache.org/jira/browse/MINDEXER-127, which got visible in m2e through https://github.com/eclipse-m2e/m2e-core/issues/169 --- - context = contextPurgeWorkaroundMINDEXER127(context); - - if(context.getRepository().isDirectory()) { - getIndexer().scan(context, new ArtifactScanningMonitor(context.getRepository(), monitor), false); - } - } - log.info("Updated local repository index"); - } catch(Exception ex) { - log.error("Unable to re-index " + repository.toString(), ex); - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_reindexing, ex)); - } finally { - fireIndexChanged(repository); - } - } - - /** - * Purge context, subsitute for context.purge() Workaround for - * https://issues.apache.org/jira/browse/MINDEXER-127, which got visible in m2e through - * https://github.com/eclipse-m2e/m2e-core/issues/169 --- - */ - private IndexingContext contextPurgeWorkaroundMINDEXER127(IndexingContext context) throws IOException { - // Perform all calls from DefaultIndexingContext.purge() except for openAndWarmup() : - // calls DefaultIndexingContext.closeReaders() and DefaultIndexingContext.deleteIndexFiles( true ) - getIndexer().removeIndexingContext(context, true); - // create a copy of the current index which calls prepareIndex( true ) - context = getIndexer().addIndexingContextForced(context.getId(), context.getRepositoryId(), - context.getRepository(), context.getIndexDirectoryFile(), context.getRepositoryUrl(), - context.getIndexUpdateUrl(), context.getIndexCreators()); - - context.rebuildGroups(); - context.updateTimestamp(true, null); - return context; - } - - private void reindexWorkspace(boolean force) throws CoreException { - IRepository workspaceRepository = repositoryRegistry.getWorkspaceRepository(); - if(!force) - return; - try { - IndexingContext context = getIndexingContext(workspaceRepository); - if(context != null) { - // context.purge(); - contextPurgeWorkaroundMINDEXER127(context); - } - - for(IMavenProjectFacade facade : projectManager.getProjects()) { - addDocument(workspaceRepository, facade.getPomFile(), // - facade.getArtifactKey()); - } - } catch(Exception ex) { - log.error("Unable to re-index " + workspaceRepository.toString(), ex); - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_reindexing, ex)); - } finally { - fireIndexChanged(workspaceRepository); - } - } - - protected void addDocument(IRepository repository, File file, ArtifactKey key) { - synchronized(getIndexLock(repository)) { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - // TODO log - return; - } - try { - ArtifactContext artifactContext; - if(repository.isScope(IRepositoryRegistry.SCOPE_WORKSPACE)) { - IMavenProjectFacade facade = getProjectByArtifactKey(key); - artifactContext = getWorkspaceArtifactContext(facade); - } else { - artifactContext = getArtifactContext(file, context); - } - getIndexer().addArtifactToIndex(artifactContext, context); - } catch(Exception ex) { - String msg = "Unable to add " + getDocumentKey(key); - log.error(msg, ex); - } - } - } - - private IMavenProjectFacade getProjectByArtifactKey(ArtifactKey artifactKey) throws CoreException { - for(IMavenProjectFacade facade : projectManager.getProjects()) { - if(facade.getArtifactKey().equals(artifactKey)) { - return facade; - } - } - - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_unexpected, new IllegalArgumentException(String.format( - "Workspace project with key %s not found!", artifactKey)))); //$NON-NLS-1$ - } - - protected void removeDocument(IRepository repository, File file, ArtifactKey key, IMavenProjectFacade facade) { - synchronized(getIndexLock(repository)) { - try { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - String msg = "Unable to find document to remove" + getDocumentKey(key); - log.error(msg); - return; - } - ArtifactContext artifactContext; - if(repository.isScope(IRepositoryRegistry.SCOPE_WORKSPACE)) { - if(facade == null) { - // try to get one, but you MUST have facade in case of project deletion, see mavenProjectChanged() - facade = getProjectByArtifactKey(key); - } - artifactContext = getWorkspaceArtifactContext(facade); - } else { - artifactContext = getArtifactContext(file, context); - } - getIndexer().deleteArtifactFromIndex(artifactContext, context); - } catch(Exception ex) { - String msg = "Unable to remove " + getDocumentKey(key); - log.error(msg, ex); - } - } - - fireIndexChanged(repository); - } - - private ArtifactContext getArtifactContext(File file, IndexingContext context) { - return getArtifactContextProducer().getArtifactContext(context, file); - } - - private ArtifactContext getWorkspaceArtifactContext(IMavenProjectFacade facade) { - IRepository workspaceRepository = repositoryRegistry.getWorkspaceRepository(); - ArtifactKey key = facade.getArtifactKey(); - ArtifactInfo ai = new ArtifactInfo(workspaceRepository.getUid(), key.getGroupId(), key.getArtifactId(), - key.getVersion(), key.getClassifier(), null); - ai.setPackaging(facade.getPackaging()); - File pomFile = facade.getPomFile(); - File artifactFile = (pomFile != null) ? pomFile.getParentFile() : null; - Gav gav = new Gav(key.getGroupId(), key.getArtifactId(), key.getVersion()); - return new ArtifactContext(pomFile, artifactFile, null, ai, gav); - } - - protected void scheduleIndexUpdate(final IRepository repository, final boolean force) { - if(repository != null) { - IndexCommand command = monitor -> updateIndex(repository, force, monitor); - updaterJob.addCommand(command); - updaterJob.schedule(1000L); - } - } - - /** for unit tests */ - public IndexedArtifactGroup[] getRootIndexedArtifactGroups(IRepository repository) throws CoreException { - synchronized(getIndexLock(repository)) { - IndexingContext context = getIndexingContext(repository); - if(context != null) { - try { - Set rootGroups = context.getRootGroups(); - IndexedArtifactGroup[] groups = new IndexedArtifactGroup[rootGroups.size()]; - int i = 0; - for(String group : rootGroups) { - groups[i++ ] = new IndexedArtifactGroup(repository, group); - } - return groups; - } catch(IOException ex) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, // - NLS.bind(Messages.NexusIndexManager_error_root_grp, repository.toString()), ex)); - } - } - return new IndexedArtifactGroup[0]; - } - } - - /** public for unit tests only! */ - public IndexingContext getIndexingContext(IRepository repository) { - return repository == null ? null : getIndexer().getIndexingContexts().get(repository.getUid()); - } - - public NexusIndexer getIndexer() { - synchronized(indexerLock) { - if(indexer == null) { - try { - indexer = container.lookup(NexusIndexer.class); - } catch(ComponentLookupException ex) { - throw new NoSuchComponentException(ex); - } - } - } - return indexer; - } - - public ArtifactContextProducer getArtifactContextProducer() { - synchronized(contextProducerLock) { - if(artifactContextProducer == null) { - try { - artifactContextProducer = container.lookup(ArtifactContextProducer.class); - } catch(ComponentLookupException ex) { - throw new NoSuchComponentException(ex); - } - } - } - return artifactContextProducer; - } - - public static String getDocumentKey(ArtifactKey artifact) { - String groupId = artifact.getGroupId(); - if(groupId == null) { - groupId = Messages.NexusIndexManager_inherited; - } - - String artifactId = artifact.getArtifactId(); - - String version = artifact.getVersion(); - if(version == null) { - version = Messages.NexusIndexManager_inherited; - } - - String key = groupId.replace('.', '/') + '/' + artifactId + '/' + version + '/' + artifactId + "-" + version; //$NON-NLS-1$ - - String classifier = artifact.getClassifier(); - if(classifier != null) { - key += "-" + classifier; //$NON-NLS-1$ - } - - // TODO use artifact handler to retrieve extension - // cstamas: will not work since ArtifactKey misses type - // either get packaging from POM or store/honor extension - return key + ".pom"; //$NON-NLS-1$ - } - - @Override - public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) { - /* - * This method is called while holding workspace lock. Avoid long-running operations if possible. - */ - - synchronized(getIndexLock(repositoryRegistry.getWorkspaceRepository())) { - IndexingContext context = getIndexingContext(repositoryRegistry.getWorkspaceRepository()); - - if(context != null) { - // workspace indexing context can by null during startup due to MNGECLIPSE-1633 - for(MavenProjectChangedEvent event : events) { - IMavenProjectFacade oldFacade = event.getOldMavenProject(); - IMavenProjectFacade facade = event.getMavenProject(); - if(oldFacade != null) { - if(facade != null) { - addDocument(repositoryRegistry.getWorkspaceRepository(), facade.getPomFile(), facade.getArtifactKey()); - fireIndexChanged(repositoryRegistry.getWorkspaceRepository()); - } else { - removeDocument(repositoryRegistry.getWorkspaceRepository(), oldFacade.getPomFile(), - oldFacade.getArtifactKey(), oldFacade); - fireIndexRemoved(repositoryRegistry.getWorkspaceRepository()); - } - } else if(facade != null) { - addDocument(repositoryRegistry.getWorkspaceRepository(), facade.getPomFile(), facade.getArtifactKey()); - fireIndexAdded(repositoryRegistry.getWorkspaceRepository()); - } - } - } - } - } - - @Override - public NexusIndex getWorkspaceIndex() { - return workspaceIndex; - } - - @Override - public NexusIndex getLocalIndex() { - IRepository localRepository = repositoryRegistry.getLocalRepository(); - synchronized(getIndexLock(localRepository)) { - if(localIndex == null) { - localIndex = newLocalIndex(localRepository); - } - } - return localIndex; - } - - @Override - public IIndex getIndex(IProject project) { - IMavenProjectFacade projectFacade = project != null ? projectManager.getProject(project) : null; - - ArrayList indexes = new ArrayList<>(); - indexes.add(getWorkspaceIndex()); - indexes.add(getLocalIndex()); - - if(projectFacade != null) { - LinkedHashSet repositories = new LinkedHashSet<>(); - repositories.addAll(projectFacade.getArtifactRepositoryRefs()); - repositories.addAll(projectFacade.getPluginArtifactRepositoryRefs()); - - for(ArtifactRepositoryRef repositoryRef : repositories) { - IRepository repository = repositoryRegistry.getRepository(repositoryRef); - if(repository != null) { - indexes.add(getIndex(repository)); - } - } - } else { - for(IRepository repository : repositoryRegistry.getRepositories(IRepositoryRegistry.SCOPE_SETTINGS)) { - indexes.add(getIndex(repository)); - } - } - - return new CompositeIndex(indexes); - } - - @Override - public IIndex getAllIndexes() { - ArrayList indexes = new ArrayList<>(); - indexes.add(getWorkspaceIndex()); - indexes.add(getLocalIndex()); - - LinkedHashSet repositories = new LinkedHashSet<>(); - for(IMavenProjectFacade facade : projectManager.getProjects()) { - repositories.addAll(facade.getArtifactRepositoryRefs()); - repositories.addAll(facade.getPluginArtifactRepositoryRefs()); - } - - for(ArtifactRepositoryRef repositoryRef : repositories) { - IRepository repository = repositoryRegistry.getRepository(repositoryRef); - if(repository != null) { - indexes.add(getIndex(repository)); - } - } - - return new CompositeIndex(indexes); - } - - public NexusIndex getIndex(IRepository repository) { - String details = getIndexDetails(repository); - return new NexusIndex(this, repository, details); - } - - protected File getIndexDirectoryFile(IRepository repository) { - return new File(baseIndexDir, repository.getUid()); - } - - protected Directory getIndexDirectory(IRepository repository) throws IOException { - return FSDirectory.open(getIndexDirectoryFile(repository).toPath()); - } - - public IndexedArtifactGroup resolveGroup(IndexedArtifactGroup group) { - IRepository repository = group.getRepository(); - String prefix = group.getPrefix(); - try { - IndexedArtifactGroup g = new IndexedArtifactGroup(repository, prefix); - for(IndexedArtifact a : search(repository, new SourcedSearchExpression(prefix), IIndex.SEARCH_GROUP).values()) { - String groupId = a.getGroupId(); - if(groupId.equals(prefix)) { - g.getFiles().put(a.getArtifactId(), a); - } else if(groupId.startsWith(prefix + ".")) { //$NON-NLS-1$ - int start = prefix.length() + 1; - int end = groupId.indexOf('.', start); - String key = end > -1 ? groupId.substring(0, end) : groupId; - g.getNodes().put(key, new IndexedArtifactGroup(repository, key)); - } - } - - return g; - - } catch(CoreException ex) { - log.error("Can't retrieve groups for " + repository.toString() + ":" + prefix, ex); //$NON-NLS-2$ - return group; - } - } - - @Override - public void repositoryAdded(IRepository repository, IProgressMonitor monitor) throws CoreException { - String details = getIndexDetails(repository); - - // for consistency, always process indexes using our background thread - setIndexDetails(repository, null, details, null/*async*/); - } - - /** For tests only */ - public String getIndexDetails(IRepository repository) { - String details = indexDetails.getProperty(repository.getUid()); - - if(details == null) { - if(repository.isScope(IRepositoryRegistry.SCOPE_SETTINGS) && repository.getMirrorId() == null) { - details = NexusIndex.DETAILS_MIN; - } else if(repository.isScope(IRepositoryRegistry.SCOPE_LOCAL)) { - details = NexusIndex.DETAILS_MIN; - } else if(repository.isScope(IRepositoryRegistry.SCOPE_WORKSPACE)) { - details = NexusIndex.DETAILS_MIN; - } else { - details = NexusIndex.DETAILS_DISABLED; - } - } - - return details; - } - - /** - * Updates index synchronously if monitor!=null. Schedules index update otherwise. ... and yes, I know this ain't - * kosher. Public for unit tests only! - */ - public void setIndexDetails(IRepository repository, String details, IProgressMonitor monitor) throws CoreException { - setIndexDetails(repository, details, details, monitor); - } - - private void setIndexDetails(IRepository repository, String details, String defaultDetails, IProgressMonitor monitor) - throws CoreException { - if(details != null) { - indexDetails.setProperty(repository.getUid(), details); - - writeIndexDetails(); - } else { - details = defaultDetails; - } - - synchronized(getIndexLock(repository)) { - IndexingContext indexingContext = getIndexingContext(repository); - - try { - if(NexusIndex.DETAILS_DISABLED.equals(details)) { - if(indexingContext != null) { - getIndexer().removeIndexingContext(indexingContext, false /*removeFiles*/); - fireIndexRemoved(repository); - } - } else { - if(indexingContext != null) { - getIndexer().removeIndexingContext(indexingContext, false); - } - - createIndexingContext(repository); - - fireIndexAdded(repository); - - if(monitor != null) { - updateIndex(repository, false, monitor); - } else { - scheduleIndexUpdate(repository, false); - } - } - } catch(IOException ex) { - String msg = "Error changing index details " + repository.toString(); - log.error(msg, ex); - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_add_repo, ex)); - } - - if(repository.isScope(IRepositoryRegistry.SCOPE_LOCAL)) { - // note that we are still synchronized on repository lock at this point - this.localIndex = newLocalIndex(repositoryRegistry.getLocalRepository()); - } - } - } - - protected IndexingContext createIndexingContext(IRepository repository) throws IOException { - IndexingContext indexingContext; - Directory directory = getIndexDirectory(repository); - - File repositoryPath = null; - if(repository.getBasedir() != null) { - repositoryPath = repository.getBasedir().getCanonicalFile(); - } - - indexingContext = getIndexer().addIndexingContextForced(repository.getUid(), // - repository.getUrl(), // - repositoryPath, // - directory, // - repository.getUrl(), null, // - minCreators); - - indexingContext.setSearchable(false); - - return indexingContext; - } - - protected List getIndexers(String details) { - boolean fullIndex = NexusIndex.DETAILS_FULL.equals(details); - return fullIndex ? fullCreators : minCreators; - } - - @Override - public void repositoryRemoved(IRepository repository, IProgressMonitor monitor) { - synchronized(getIndexLock(repository)) { - try { - IndexingContext context = getIndexingContext(repository); - if(context == null) { - return; - } - getIndexer().removeIndexingContext(context, false); - } catch(IOException ie) { - String msg = "Unable to delete files for index"; - log.error(msg, ie); - } - } - - fireIndexRemoved(repository); - } - - protected void fireIndexAdded(IRepository repository) { - synchronized(indexListeners) { - for(IndexListener listener : indexListeners) { - listener.indexAdded(repository); - } - } - } - - protected void fireIndexRemoved(IRepository repository) { - synchronized(updatingIndexes) { - if(repository != null) { - //since workspace index can be null at startup, guard against nulls - updatingIndexes.remove(repository.getUid()); - } - } - synchronized(indexListeners) { - for(IndexListener listener : indexListeners) { - listener.indexRemoved(repository); - } - } - } - - protected boolean isUpdatingIndex(IRepository repository) { - synchronized(updatingIndexes) { - return updatingIndexes.contains(repository.getUid()); - } - } - - protected void fireIndexUpdating(IRepository repository) { - synchronized(updatingIndexes) { - if(repository != null) { - //since workspace index can be null at startup, guard against nulls - updatingIndexes.add(repository.getUid()); - } - } - synchronized(indexListeners) { - for(IndexListener listener : indexListeners) { - listener.indexUpdating(repository); - } - } - } - - protected void fireIndexChanged(IRepository repository) { - if(repository == null) { - return; - } - synchronized(updatingIndexes) { - updatingIndexes.remove(repository.getUid()); - } - synchronized(indexListeners) { - for(IndexListener listener : indexListeners) { - listener.indexChanged(repository); - } - } - } - - @Override - public void removeIndexListener(IndexListener listener) { - synchronized(indexListeners) { - indexListeners.remove(listener); - } - } - - @Override - public void addIndexListener(IndexListener listener) { - synchronized(indexListeners) { - if(!indexListeners.contains(listener)) { - indexListeners.add(listener); - } - } - } - - //Public for testing purpose. - public void updateIndex(IRepository repository, boolean force, IProgressMonitor monitor) throws CoreException { - synchronized(getIndexLock(repository)) { - if(repository.isScope(IRepositoryRegistry.SCOPE_WORKSPACE)) { - reindexWorkspace(force); - } else { - IndexingContext context = getIndexingContext(repository); - if(context != null) { - if(context.getRepository() != null) { - reindexLocalRepository(repository, force, monitor); - } else { - if(!force) { - //if 'force' is not set, then only do the remote update if this value is set - IMavenConfiguration mavenConfig = MavenPlugin.getMavenConfiguration(); - if(mavenConfig.isUpdateIndexesOnStartup()) { - updateRemoteIndex(repository, force, monitor); - } - } else { - updateRemoteIndex(repository, force, monitor); - } - } - } - } - IndexingContext context = getIndexingContext(repository); - if(context != null) { - context.setSearchable(true); - } - } - } - - /* - * Callers must hold repository access synchronisation lock - */ - private void updateRemoteIndex(IRepository repository, boolean force, IProgressMonitor monitor) { - if(repository == null) { - return; - } - - long start = System.currentTimeMillis(); - - if(monitor != null) { - monitor.setTaskName(NLS.bind(Messages.NexusIndexManager_task_updating, repository.toString())); - } - log.info("Updating index for repository: {}", repository.toString()); //$NON-NLS-1$ - try { - fireIndexUpdating(repository); - - IndexingContext context = getIndexingContext(repository); - - if(context != null) { - IndexUpdateRequest request = newIndexUpdateRequest(repository, context, monitor); - request.setForceFullUpdate(force); - - Lock cacheLock = locker.lock(request.getLocalIndexCacheDir()); - try { - boolean updated; - - request.setCacheOnly(true); - IndexUpdateResult result = indexUpdater.fetchAndUpdateIndex(request); - if(result.isFullUpdate() || !context.isSearchable()) { - // need to fully recreate index - - // 1. process index gz into cached/shared lucene index. this can be a noop if cache is uptodate - String details = getIndexDetails(repository); - String id = repository.getUid() + "-cache"; //$NON-NLS-1$ - File luceneCache = new File(request.getLocalIndexCacheDir(), details); - Directory directory = FSDirectory.open(luceneCache.toPath()); - IndexingContext cacheCtx = getIndexer().addIndexingContextForced(id, id, null, directory, null, null, - getIndexers(details)); - request = newIndexUpdateRequest(repository, cacheCtx, monitor); - request.setOffline(true); - indexUpdater.fetchAndUpdateIndex(request); - - // 2. copy cached/shared (this is not very elegant, oh well) - getIndexer().removeIndexingContext(context, true); // nuke workspace index files - getIndexer().removeIndexingContext(cacheCtx, false); // keep the cache! - FileUtils.cleanDirectory(context.getIndexDirectoryFile()); - FileUtils.copyDirectory(luceneCache, context.getIndexDirectoryFile()); // copy cached lucene index - context = createIndexingContext(repository); // re-create indexing context - - updated = true; - } else { - // incremental change - request = newIndexUpdateRequest(repository, context, monitor); - request.setOffline(true); // local cache is already uptodate, no need to - result = indexUpdater.fetchAndUpdateIndex(request); - updated = result.getTimestamp() != null; - } - - if(updated) { - log.info("Updated index for repository: {} in {} ms", repository.toString(), System.currentTimeMillis() - - start); - } else { - log.info("No index update available for repository: {}", repository.toString()); - } - } finally { - cacheLock.release(); - } - } - } catch(FileNotFoundException e) { - String msg = "Unable to update index for " + repository.toString() + ": " + e.getMessage(); //$NON-NLS-2$ - log.error(msg, e); - } catch(Exception ie) { - String msg = "Unable to update index for " + repository.toString(); - log.error(msg, ie); - } finally { - fireIndexChanged(repository); - } - } - - protected IndexUpdateRequest newIndexUpdateRequest(IRepository repository, IndexingContext context, - IProgressMonitor monitor) throws IOException, CoreException { - //TODO: remove Wagon API - ProxyInfo proxyInfo = maven.getProxyInfo(repository.getProtocol()); - AuthenticationInfo authenticationInfo = repository.getAuthenticationInfo(); - - IndexUpdateRequest request = new IndexUpdateRequest(context, new AetherClientResourceFetcher(authenticationInfo, - proxyInfo, monitor)); - File localRepo = repositoryRegistry.getLocalRepository().getBasedir(); - File indexCacheBasedir = new File(localRepo, ".cache/m2e/" + MavenPluginActivator.getVersion()).getCanonicalFile(); //$NON-NLS-1$ - File indexCacheDir = new File(indexCacheBasedir, repository.getUid()); - indexCacheDir.mkdirs(); - request.setLocalIndexCacheDir(indexCacheDir); - return request; - } - - @Override - public void initialize(IProgressMonitor monitor) throws CoreException { - try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(getIndexDetailsFile()))) { - indexDetails.load(is); - } catch(FileNotFoundException e) { - // that's quite alright - } catch(IOException e) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_read_index, e)); - } - } - - protected void writeIndexDetails() throws CoreException { - try { - File indexDetailsFile = getIndexDetailsFile(); - indexDetailsFile.getParentFile().mkdirs(); - try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(indexDetailsFile))) { - indexDetails.store(os, null); - } - } catch(IOException e) { - throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, - Messages.NexusIndexManager_error_write_index, e)); - } - } - - private File getIndexDetailsFile() { - return new File(baseIndexDir, "indexDetails.properties"); //$NON-NLS-1$ - } - - /** for unit tests only */ - public Job getIndexUpdateJob() { - return updaterJob; - } - - @Override - public String getIndexerId() { - return Messages.NexusIndexManager_78; - } - - private Object getIndexLock(IRepository repository) { - if(repository == null) { - return new Object(); - } - // NOTE: We ultimately want to prevent concurrent access to the IndexingContext so we sync on the repo UID and not on the repo instance. - synchronized(indexLocks) { - Object lock = indexLocks.get(repository.getUid()); - if(lock == null) { - lock = new Object(); - indexLocks.put(repository.getUid(), lock); - } - return lock; - } - } - - /// REMOVE THIS BELOW ONCE Maven Indexer upgraded to 3.2.0-SNAPSHOT - /// In that moment this code becomes duplicated and already in place, this method added - - protected ArtifactInfo identify(File artifact, Collection contexts) throws IOException { - - try (FileInputStream is = new FileInputStream(artifact)) { - MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); - - - - byte[] buff = new byte[4096]; - - int n; - - while((n = is.read(buff)) > -1) { - sha1.update(buff, 0, n); - } - - byte[] digest = sha1.digest(); - - Query q = getIndexer().constructQuery(MAVEN.SHA1, encode(digest), SearchType.EXACT); - - Collection result = getIndexer().identify(q, contexts); - return result == null || result.isEmpty() ? null : (ArtifactInfo) result.toArray()[0]; - - } catch(NoSuchAlgorithmException ex) { - throw new IOException("Unable to calculate digest"); - } - - } - - private static final char[] DIGITS = "0123456789abcdef".toCharArray(); - - private static String encode(byte[] digest) { - char[] buff = new char[digest.length * 2]; - - int n = 0; - - for(byte b : digest) { - buff[n++ ] = DIGITS[(0xF0 & b) >> 4]; - buff[n++ ] = DIGITS[0x0F & b]; - } - - return new String(buff); - } - - /** - * @since 1.5 - */ - public IndexUpdater getIndexUpdate() { - return indexUpdater; - } - - /** - * @since 1.5 - */ - public ArchetypeDataSource getArchetypeCatalog() { - try { - return container.lookup(ArchetypeDataSource.class, "nexus"); - } catch(ComponentLookupException ex) { - throw new NoSuchComponentException(ex); - } - } -} diff --git a/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF b/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF index 7deb69c722..93c8c9d735 100644 --- a/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.discovery/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.discovery;singleton:=true -Bundle-Version: 1.18.1.qualifier +Bundle-Version: 1.18.2.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin @@ -11,9 +11,9 @@ Require-Bundle: org.eclipse.equinox.p2.ui.discovery, org.eclipse.equinox.p2.discovery.compatibility, org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.core.ui;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", + org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.core.ui;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", org.eclipse.core.resources, org.eclipse.ui.ide, org.eclipse.equinox.p2.operations, diff --git a/org.eclipse.m2e.editor/META-INF/MANIFEST.MF b/org.eclipse.m2e.editor/META-INF/MANIFEST.MF index 315f92ed74..ebe7a60779 100644 --- a/org.eclipse.m2e.editor/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.editor/META-INF/MANIFEST.MF @@ -13,8 +13,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.wst.sse.core, org.eclipse.wst.xml.core, org.eclipse.ui.workbench, - org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", + org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", org.eclipse.m2e.core.ui;bundle-version="[1.17.2,2.0.0)", org.eclipse.wst.sse.core, org.eclipse.wst.common.emf, diff --git a/org.eclipse.m2e.feature/build.properties b/org.eclipse.m2e.feature/build.properties index 9defd4b400..8d3e57aeee 100644 --- a/org.eclipse.m2e.feature/build.properties +++ b/org.eclipse.m2e.feature/build.properties @@ -11,5 +11,4 @@ # bin.includes = feature.xml,\ - p2.inf,\ feature.properties diff --git a/org.eclipse.m2e.feature/feature.xml b/org.eclipse.m2e.feature/feature.xml index c16b1e2a4c..c3d269d744 100644 --- a/org.eclipse.m2e.feature/feature.xml +++ b/org.eclipse.m2e.feature/feature.xml @@ -28,12 +28,6 @@ install-size="0" version="0.0.0"/> - - findArtifacts(IProject project, IPath path) throws Core for(IClasspathEntry entry : entries) { ArtifactKey artifact = findArtifactByArtifactKey(entry); - if(artifact == null) { - artifact = findArtifactInIndex(project, entry); - if(artifact == null) { - // console.logError("Can't find artifact for " + entry.getPath()); - } else { - // console.logMessage("Found indexed artifact " + artifact + " for " + entry.getPath()); - artifacts.add(artifact); - } - } else { - // console.logMessage("Found artifact " + artifact + " for " + entry.getPath()); + if(artifact != null) { artifacts.add(artifact); } } @@ -456,19 +441,6 @@ private ArtifactKey findArtifactByArtifactKey(IClasspathEntry entry) { return null; } - private ArtifactKey findArtifactInIndex(IProject project, IClasspathEntry entry) throws CoreException { - IFile jarFile = project.getWorkspace().getRoot().getFile(entry.getPath()); - File file = jarFile == null || jarFile.getLocation() == null ? entry.getPath().toFile() - : jarFile.getLocation().toFile(); - - IndexedArtifactFile iaf = indexManager.getIndex(project).identify(file); - if(iaf != null) { - return new ArtifactKey(iaf.group, iaf.artifact, iaf.version, iaf.classifier); - } - - return null; - } - // TODO should it be just one entry? private ArrayList findClasspathEntries(IProject project, IPath path) throws JavaModelException { ArrayList entries = new ArrayList<>(); diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java index b29201d359..3747afa0af 100644 --- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java +++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java @@ -50,8 +50,6 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.Resource; -import org.eclipse.m2e.core.MavenPlugin; -import org.eclipse.m2e.core.internal.index.IIndex; import org.eclipse.m2e.core.internal.index.IndexedArtifact; import org.eclipse.m2e.core.internal.index.IndexedArtifactFile; import org.eclipse.m2e.core.internal.index.SearchExpression; @@ -460,46 +458,41 @@ private String getMostRecentPluginVersion(String groupId, String artifactId, Str Assert.isNotNull(artifactId, "artifactId can not be null"); String version = referenceVersion; String partialKey = artifactId + " : " + groupId; //$NON-NLS-1$ - try { - IIndex index = MavenPlugin.getIndexManager().getAllIndexes(); - SearchExpression a = new SourcedSearchExpression(artifactId); - - //For some reason, an exact search using : - //ISearchEngine searchEngine = M2EUIPluginActivator.getDefault().getSearchEngine(null) - //searchEngine.findVersions(groupId, artifactId, searchExpression, packaging) - // - //doesn't yield the expected results (the latest versions are not returned), so we rely on a fuzzier search - //and refine the results. - Map values = index.search(a, IIndex.SEARCH_PLUGIN); - if(!values.isEmpty()) { - SortedSet versions = new TreeSet<>(); - ComparableVersion referenceComparableVersion = referenceVersion == null ? null - : new ComparableVersion(referenceVersion); - - for(Map.Entry e : values.entrySet()) { - if(!(e.getKey().endsWith(partialKey))) { - continue; - } - for(IndexedArtifactFile f : e.getValue().getFiles()) { - if(groupId.equals(f.group) && artifactId.equals(f.artifact) && !f.version.contains("SNAPSHOT")) { - ComparableVersion v = new ComparableVersion(f.version); - if(referenceComparableVersion == null || v.compareTo(referenceComparableVersion) > 0) { - versions.add(v); - } + SearchExpression a = new SourcedSearchExpression(artifactId); + + //For some reason, an exact search using : + //ISearchEngine searchEngine = M2EUIPluginActivator.getDefault().getSearchEngine(null) + //searchEngine.findVersions(groupId, artifactId, searchExpression, packaging) + // + //doesn't yield the expected results (the latest versions are not returned), so we rely on a fuzzier search + //and refine the results. + Map values = Map.of(); // was using index, but should use searchEngine as mentioned above + if(!values.isEmpty()) { + SortedSet versions = new TreeSet<>(); + ComparableVersion referenceComparableVersion = referenceVersion == null ? null + : new ComparableVersion(referenceVersion); + + for(Map.Entry e : values.entrySet()) { + if(!(e.getKey().endsWith(partialKey))) { + continue; + } + for(IndexedArtifactFile f : e.getValue().getFiles()) { + if(groupId.equals(f.group) && artifactId.equals(f.artifact) && !f.version.contains("SNAPSHOT")) { + ComparableVersion v = new ComparableVersion(f.version); + if(referenceComparableVersion == null || v.compareTo(referenceComparableVersion) > 0) { + versions.add(v); } } - if(!versions.isEmpty()) { - List sorted = new ArrayList<>(versions.size()); - for(ComparableVersion v : versions) { - sorted.add(v.toString()); - } - Collections.reverse(sorted); - version = sorted.iterator().next(); + } + if(!versions.isEmpty()) { + List sorted = new ArrayList<>(versions.size()); + for(ComparableVersion v : versions) { + sorted.add(v.toString()); } + Collections.reverse(sorted); + version = sorted.iterator().next(); } } - } catch(CoreException e) { - log.error("Can not retrieve latest version of " + partialKey, e); } return version; } diff --git a/org.eclipse.m2e.launching/META-INF/MANIFEST.MF b/org.eclipse.m2e.launching/META-INF/MANIFEST.MF index 70304992e3..7fcf1c3601 100644 --- a/org.eclipse.m2e.launching/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.launching/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.launching;singleton:=true -Bundle-Version: 1.18.0.qualifier +Bundle-Version: 1.19.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.variables, @@ -15,9 +15,12 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.jdt.core, org.eclipse.jdt.launching, org.eclipse.jdt.debug.ui, - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.core.ui;bundle-version="[1.16.0,2.0.0)", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.core.ui;bundle-version="1.16.0", + org.eclipse.jdt.debug, + org.eclipse.core.resources, + org.eclipse.debug.core, org.eclipse.m2e.workspace.cli;bundle-version="0.1.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/org.eclipse.m2e.lifecyclemapping.defaults/META-INF/MANIFEST.MF b/org.eclipse.m2e.lifecyclemapping.defaults/META-INF/MANIFEST.MF index 1b391ee191..5e49dde25c 100644 --- a/org.eclipse.m2e.lifecyclemapping.defaults/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.lifecyclemapping.defaults/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.lifecyclemapping.defaults;singleton:=true -Bundle-Version: 1.17.1.qualifier -Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.jdt;bundle-version="[1.16.0,2.0.0)" +Bundle-Version: 1.17.2.qualifier +Require-Bundle: org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.jdt;bundle-version="1.16.0" Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/org.eclipse.m2e.logback.appender/META-INF/MANIFEST.MF b/org.eclipse.m2e.logback.appender/META-INF/MANIFEST.MF index 030edda83f..2cc00e0a17 100644 --- a/org.eclipse.m2e.logback.appender/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.logback.appender/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.m2e.logback.appender;singleton:=true -Bundle-Version: 1.17.2.qualifier +Bundle-Version: 1.17.3.qualifier Bundle-Name: M2E Logback Appender Bundle-Vendor: Eclipse.org - m2e Bundle-RequiredExecutionEnvironment: JavaSE-11 @@ -10,5 +10,5 @@ Export-Package: org.eclipse.m2e.logback.appender;x-internal:=true Require-Bundle: org.eclipse.core.runtime, org.eclipse.jface, org.eclipse.ui.console, - org.eclipse.m2e.core.ui;bundle-version="[1.16.0,2.0.0)" + org.eclipse.m2e.core.ui;bundle-version="1.16.0" Automatic-Module-Name: org.eclipse.m2e.logback.appender diff --git a/org.eclipse.m2e.logback.feature/feature.xml b/org.eclipse.m2e.logback.feature/feature.xml index bf2dff9679..e82127f9fa 100644 --- a/org.eclipse.m2e.logback.feature/feature.xml +++ b/org.eclipse.m2e.logback.feature/feature.xml @@ -2,7 +2,7 @@ identify(File classesLocation) { // checksum-based lookup in central // GAV extracted from pom.properties - Collection classesArtifacts = identifyNexusIndexer(classesLocation); - if (classesArtifacts == null) { - classesArtifacts = identifyCentralSearch(classesLocation); - } + Collection classesArtifacts = identifyCentralSearch(classesLocation); if (classesArtifacts == null) { classesArtifacts = scanPomProperties(classesLocation); } @@ -86,38 +76,6 @@ public Collection identify(File classesLocation) { return classesArtifacts; } - protected Collection identifyNexusIndexer(File file) { - if (!file.isFile()) { - return null; - } - - try { - IIndex index = MavenPlugin.getIndexManager().getAllIndexes(); - - List identified; - if (index instanceof CompositeIndex) { - identified = ((CompositeIndex) index).identifyAll(file); - } else { - IndexedArtifactFile indexed = index.identify(file); - if (indexed != null) { - identified = Collections.singletonList(indexed); - } else { - identified = Collections.emptyList(); - } - } - - for (IndexedArtifactFile indexed : identified) { - if (indexed.sourcesExists == IIndex.PRESENT) { - return Collections.singleton(indexed.getArtifactKey()); - } - } - } catch (CoreException e) { - // TODO maybe log, but ignore otherwise - } - - return null; - } - protected Collection identifyCentralSearch(File file) { if (!file.isFile()) { return null; diff --git a/org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF b/org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF index c097418da3..578e24b39e 100644 --- a/org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF @@ -4,10 +4,10 @@ Bundle-Name: M2E Testing Helpers Bundle-SymbolicName: org.eclipse.m2e.tests.common;singleton:=true Bundle-Version: 1.17.5.qualifier Require-Bundle: org.junit;bundle-version="4.0.0", - org.eclipse.m2e.core;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.maven.runtime;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.jdt;bundle-version="[1.16.0,2.0.0)", - org.eclipse.m2e.lifecyclemapping.defaults;bundle-version="[1.16.0,2.0.0)", + org.eclipse.m2e.core;bundle-version="1.16.0", + org.eclipse.m2e.maven.runtime;bundle-version="1.16.0", + org.eclipse.m2e.jdt;bundle-version="1.16.0", + org.eclipse.m2e.lifecyclemapping.defaults;bundle-version="1.16.0", org.eclipse.core.runtime, org.eclipse.jdt.core, org.eclipse.debug.core,