IDEA-116452 "Resolve workspace artifacts" option doesn't work with Maven 3.1.x

+review CR-IC
This commit is contained in:
Sergey Evdokimov
2013-11-25 21:10:33 +04:00
parent 690f786bf5
commit 8c35e68162
8 changed files with 162 additions and 4 deletions
+7
View File
@@ -299,6 +299,13 @@ public def layoutCommunityPlugins(String home) {
}
}
jar("artifact-resolver-m31.jar") {
module("maven-artifact-resolver-m31")
module("maven-artifact-resolver-m2") {
include(name: 'org/jetbrains/idea/maven/artifactResolver/common/*')
}
}
dir("maven3") {
fileset(dir: "$home/plugins/maven/maven3-server-impl/lib") {include(name: "*.jar")}
fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/lib") {include(name: "*.jar")}
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../maven3-server-impl/lib/maven3/lib/maven-core-3.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../maven3-server-impl/lib/maven3/lib/plexus-component-annotations-1.5.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/eclipse-aether/aether-api-0.9.0.M2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="maven-artifact-resolver-m2" />
</component>
</module>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<component-set>
<components>
<component>
<role>org.eclipse.aether.repository.WorkspaceReader</role>
<role-hint>ide</role-hint>
<implementation>org.jetbrains.idea.maven.artifactResolver.IntelliJWorkspaceReaderM31</implementation>
<description />
<isolated-realm>false</isolated-realm>
</component>
</components>
</component-set>
@@ -0,0 +1,62 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* 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.
*/
package org.jetbrains.idea.maven.artifactResolver;
import org.codehaus.plexus.component.annotations.Component;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.repository.WorkspaceRepository;
import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
import java.io.File;
import java.util.Collections;
import java.util.List;
/**
* @author Sergey Evdokimov
*/
@Component(role = WorkspaceReader.class, hint = "ide")
public class IntelliJWorkspaceReaderM31 implements WorkspaceReader {
private final WorkspaceRepository myWorkspaceRepository;
public IntelliJWorkspaceReaderM31() {
myWorkspaceRepository = new WorkspaceRepository("ide", getClass());
}
@Override
public int hashCode() {
return 311;
}
@Override
public boolean equals(Object o) {
return o instanceof IntelliJWorkspaceReaderM31;
}
public WorkspaceRepository getRepository() {
return myWorkspaceRepository;
}
public File findArtifact(Artifact artifact) {
return MavenModuleMap.getInstance().findArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(),
artifact.getBaseVersion());
}
public List<String> findVersions(Artifact artifact) {
return Collections.emptyList();
}
}
@@ -0,0 +1,22 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* 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.
*/
package org.jetbrains.idea.maven.artifactResolver;
/**
* @author Sergey Evdokimov
*/
public class MavenArtifactResolvedM31RtMarker {
}
+1
View File
@@ -59,6 +59,7 @@
<orderEntry type="module" module-name="jps-model-impl" />
<orderEntry type="module" module-name="maven-jps-plugin" />
<orderEntry type="module" module-name="maven-artifact-resolver-m3" />
<orderEntry type="module" module-name="maven-artifact-resolver-m31" />
<orderEntry type="module" module-name="spellchecker" />
<orderEntry type="module" module-name="vcs-api" />
</component>
@@ -47,6 +47,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.artifactResolver.MavenArtifactResolvedM2RtMarker;
import org.jetbrains.idea.maven.artifactResolver.MavenArtifactResolvedM31RtMarker;
import org.jetbrains.idea.maven.artifactResolver.MavenArtifactResolvedM3RtMarker;
import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
@@ -126,7 +127,7 @@ public class MavenExternalParameters {
if (project != null && parameters.isResolveToWorkspace()) {
try {
String resolverJar = getArtifactResolverJar(MavenUtil.isMaven3(mavenHome));
String resolverJar = getArtifactResolverJar(MavenUtil.getMavenVersion(mavenHome));
confFile = patchConfFile(confFile, resolverJar);
File modulesPathsFile = dumpModulesPaths(project);
@@ -196,11 +197,24 @@ public class MavenExternalParameters {
finally {
sc.close();
}
}
private static String getArtifactResolverJar(boolean isMaven3) throws IOException {
Class marker = isMaven3 ? MavenArtifactResolvedM3RtMarker.class : MavenArtifactResolvedM2RtMarker.class;
private static String getArtifactResolverJar(@Nullable String mavenVersion) throws IOException {
boolean isMaven3;
Class marker;
if (mavenVersion != null && mavenVersion.compareTo("3.1.0") >= 0) {
isMaven3 = true;
marker = MavenArtifactResolvedM31RtMarker.class;
}
else if (mavenVersion != null && mavenVersion.compareTo("3.0.0") >= 0) {
isMaven3 = true;
marker = MavenArtifactResolvedM3RtMarker.class;
}
else {
isMaven3 = false;
marker = MavenArtifactResolvedM2RtMarker.class;
}
File classDirOrJar = new File(PathUtil.getJarPathForClass(marker));