Maven: do not export Maven dependencies (IDEA-53170, IDEA-51298)

This commit is contained in:
Anton Makeev
2010-03-24 15:50:35 +03:00
parent af67f2c37e
commit dbf2d8bce3
4 changed files with 8 additions and 85 deletions
@@ -107,14 +107,13 @@ public class MavenModuleImporter {
private void configDependencies() {
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
boolean isExportable = artifact.isExportable();
DependencyScope scope = selectScope(artifact.getScope());
MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
if (depProject != null) {
myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), isExportable, scope);
myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), scope);
}
else if (myMavenProject.isSupportedDependency(artifact)) {
myRootModelAdapter.addLibraryDependency(artifact, isExportable, scope, myModifiableModelsProvider, myMavenProject);
myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
}
}
}
@@ -194,7 +194,7 @@ public class MavenRootModelAdapter {
return new Path(path);
}
public void addModuleDependency(String moduleName, boolean isExportable, DependencyScope scope) {
public void addModuleDependency(String moduleName, DependencyScope scope) {
Module m = findModuleByName(moduleName);
ModuleOrderEntry e;
@@ -205,7 +205,6 @@ public class MavenRootModelAdapter {
e = myRootModel.addInvalidModuleEntry(moduleName);
}
e.setExported(isExportable);
e.setScope(scope);
}
@@ -215,7 +214,6 @@ public class MavenRootModelAdapter {
}
public void addLibraryDependency(MavenArtifact artifact,
boolean isExportable,
DependencyScope scope,
MavenModifiableModelsProvider provider,
MavenProject project) {
@@ -234,7 +232,6 @@ public class MavenRootModelAdapter {
}
LibraryOrderEntry e = myRootModel.addLibraryEntry(library);
e.setExported(isExportable);
e.setScope(scope);
}
@@ -201,7 +201,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
assertModuleDeps(moduleName, LibraryOrderEntry.class, expectedDeps);
}
protected void assertExportedModuleDeps(String moduleName, String... expectedDeps) {
protected void assertExportedDeps(String moduleName, String... expectedDeps) {
final List<String> actual = new ArrayList<String>();
getRootManager(moduleName).processOrder(new RootPolicy<Object>() {
@@ -21,7 +21,6 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.idea.maven.MavenImportingTestCase;
@@ -526,30 +525,7 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
assertModuleModuleDepScope("m1", "m4", DependencyScope.TEST);
}
public void testOptionalLibraryDependencyIsNotExportable() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>group</groupId>" +
" <artifactId>lib1</artifactId>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>group</groupId>" +
" <artifactId>lib2</artifactId>" +
" <version>1</version>" +
" <optional>true</optional>" +
" </dependency>" +
"</dependencies>");
assertModules("project");
assertExportedModuleDeps("project", "Maven: group:lib1:1");
}
public void testOptionalModuleDependencyIsNotExportable() throws Exception {
public void testDependenciesAreNotExported() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<packaging>pom</packaging>" +
@@ -558,7 +534,6 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
"<modules>" +
" <module>m1</module>" +
" <module>m2</module>" +
" <module>m3</module>" +
"</modules>");
createModulePom("m1", "<groupId>test</groupId>" +
@@ -572,10 +547,9 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>m3</artifactId>" +
" <groupId>lib</groupId>" +
" <artifactId>lib</artifactId>" +
" <version>1</version>" +
" <optional>true</optional>" +
" </dependency>" +
"</dependencies>");
@@ -583,55 +557,8 @@ public class DependenciesImportingTest extends MavenImportingTestCase {
"<artifactId>m2</artifactId>" +
"<version>1</version>");
createModulePom("m3", "<groupId>test</groupId>" +
"<artifactId>m3</artifactId>" +
"<version>1</version>");
importProject();
assertExportedModuleDeps("m1", "m2");
}
public void testOnlyCompileAndRuntimeDependenciesAreExported() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>compile</artifactId>" +
" <scope>compile</scope>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>runtime</artifactId>" +
" <scope>runtime</scope>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>test</artifactId>" +
" <scope>test</scope>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>provided</artifactId>" +
" <scope>provided</scope>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>system</artifactId>" +
" <scope>system</scope>" +
" <systemPath>${java.home}/lib/tools.jar</systemPath>" +
" <version>1</version>" +
" </dependency>" +
"</dependencies>");
assertExportedModuleDeps("project", "Maven: test:compile:1", "Maven: test:runtime:1");
assertExportedDeps("m1");
}
public void testTransitiveDependencies() throws Exception {