Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2013-05-05 12:46:46 -0400
committerFred Bricon2013-05-05 12:46:46 -0400
commitee0138ec58e89d59387b238bbc3f7c4265976264 (patch)
tree37303976fb6b2c4aa08d6a4ab1633715de9d24e4
parent999f32aa09338c34503d9821a7678b5c2e0f4948 (diff)
downloadm2e-core-ee0138ec58e89d59387b238bbc3f7c4265976264.tar.gz
m2e-core-ee0138ec58e89d59387b238bbc3f7c4265976264.tar.xz
m2e-core-ee0138ec58e89d59387b238bbc3f7c4265976264.zip
cleanup JavaProjectConversionParticipant.getMostRecentPluginVersion()
Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/JavaProjectConversionParticipant.java16
1 files changed, 10 insertions, 6 deletions
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 dd5d047f..8f84cf0c 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
@@ -30,6 +30,7 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -383,8 +384,12 @@ public class JavaProjectConversionParticipant extends AbstractProjectConversionP
* Nexus indexes.
*/
@SuppressWarnings("restriction")
+ //TODO extract as API when stabilized?
private String getMostRecentPluginVersion(String groupId, String artifactId, String referenceVersion) {
+ Assert.isNotNull(groupId, "groupId can not be null");
+ 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);
@@ -398,18 +403,17 @@ public class JavaProjectConversionParticipant extends AbstractProjectConversionP
Map<String, IndexedArtifact> values = index.search(a, IIndex.SEARCH_PLUGIN);
if(!values.isEmpty()) {
SortedSet<ComparableVersion> versions = new TreeSet<ComparableVersion>();
- String partialKey = artifactId + " : " + groupId; //$NON-NLS-1$
- ComparableVersion referenceComparableVersion = new ComparableVersion(referenceVersion);
+ ComparableVersion referenceComparableVersion = referenceVersion == null ? null : new ComparableVersion(
+ referenceVersion);
for(Map.Entry<String, IndexedArtifact> e : values.entrySet()) {
if(!(e.getKey().endsWith(partialKey))) {
continue;
}
for(IndexedArtifactFile f : e.getValue().getFiles()) {
- if(COMPILER_GROUP_ID.equals(f.group) && COMPILER_ARTIFACT_ID.equals(f.artifact)
- && !f.version.contains("SNAPSHOT")) {
+ if(groupId.equals(f.group) && artifactId.equals(f.artifact) && !f.version.contains("SNAPSHOT")) {
ComparableVersion v = new ComparableVersion(f.version);
- if(v.compareTo(referenceComparableVersion) > 0) {
+ if(referenceComparableVersion == null || v.compareTo(referenceComparableVersion) > 0) {
versions.add(v);
}
}
@@ -425,7 +429,7 @@ public class JavaProjectConversionParticipant extends AbstractProjectConversionP
}
}
} catch(CoreException e) {
- log.error("Can not retrieve latest version of " + COMPILER_ARTIFACT_ID, e);
+ log.error("Can not retrieve latest version of " + partialKey, e);
}
return version;
}

Back to the top