Skip to content

Commit

Permalink
Demonstrating that importing a BOM works even when it declares those …
Browse files Browse the repository at this point in the history
…same components in dependency management. (#25)
  • Loading branch information
jglick authored Jun 23, 2022
1 parent a2b5d90 commit 4f80553
Show file tree
Hide file tree
Showing 26 changed files with 348 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ public static Test suite()
suite.addTestSuite( MavenITmng0249ResolveDepsFromReactorTest.class );
suite.addTestSuite( MavenITmng0187CollectedProjectsTest.class );
suite.addTestSuite( MavenITmng0095ReactorFailureBehaviorTest.class );
suite.addTestSuite( MavenIT0199CyclicImportScopeTest.class );
suite.addTestSuite( MavenIT0146InstallerSnapshotNaming.class );
suite.addTestSuite( MavenIT0145ReactorWithIncludesExcludesTest.class );
suite.addTestSuite( MavenIT0144LifecycleExecutionOrderTest.class );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.apache.maven.it;

/*
* 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.
*/

import java.io.File;
import org.apache.maven.it.util.ResourceExtractor;

public class MavenIT0199CyclicImportScopeTest extends AbstractMavenIntegrationTestCase {

public MavenIT0199CyclicImportScopeTest() {
super(ALL_MAVEN_VERSIONS);
}

public void testit0199() throws Exception {
// v1: parent not using BOM; explicit dep from componentB → componentA
// v2: BOM introduced; componentB → componentA picks up implicit version 1 from main@v1
// v3: components now inheriting indirectly from an older version of the BOM that includes them; componentB → componentA version overridden
for (int i = 1; i <= 3; i++) {
build("v" + i + "/parent", null);
build("v" + i + "/componentA", "target/componentA-" + i + ".jar");
build("v" + i + "/componentB", "target/componentB-" + i + ".jar");
build("v" + i + "/main", "bundle/target/bundle-" + i + ".jar");
}
}

private void build(String module, String expectedArtifact) throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/cyclic-import-scope");
Verifier verifier = newVerifier(new File(testDir.getAbsolutePath(), module).getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.executeGoal("install");
if (expectedArtifact != null) {
verifier.assertFilePresent(expectedArtifact);
}
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<relativePath/>
</parent>
<artifactId>componentA</artifactId>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Av1 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<relativePath/>
</parent>
<artifactId>componentB</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Bv1 extends Av1 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>1</version>
</parent>
<artifactId>bundle</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Bundle {
Object[] components = {new Av1(), new Bv1()};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>bundle</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
<version>1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>2</version>
<relativePath/>
</parent>
<artifactId>componentA</artifactId>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Av2 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>2</version>
<relativePath/>
</parent>
<artifactId>componentB</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Bv2 extends Av1 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>2</version>
</parent>
<artifactId>bundle</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Bundle {
Object[] components = {new Av2(), new Bv2()};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>2</version>
<packaging>pom</packaging>
<modules>
<module>bundle</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
<version>2</version>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
<version>2</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>2</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>3</version>
<relativePath/>
</parent>
<artifactId>componentA</artifactId>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Av3 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>3</version>
<relativePath/>
</parent>
<artifactId>componentB</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
<version>3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Bv3 extends Av3 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>3</version>
</parent>
<artifactId>bundle</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Bundle {
Object[] components = {new Av3(), new Bv3()};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>3</version>
<packaging>pom</packaging>
<modules>
<module>bundle</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>componentA</artifactId>
<version>3</version>
</dependency>
<dependency>
<groupId>test</groupId>
<artifactId>componentB</artifactId>
<version>3</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>3</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>main</artifactId>
<version>2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

0 comments on commit 4f80553

Please sign in to comment.