Skip to content

Commit

Permalink
[MNG-8331] Demonstrate the problem with disappearing dependencies
Browse files Browse the repository at this point in the history
Closes 393.
  • Loading branch information
mthmulders committed Oct 19, 2024
1 parent a96a238 commit 07ab883
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.it;

import java.io.File;

import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8331">MNG-8331</a>.
* <p>
* When a project that uses modelVersion 4.1.0 had both dependencies with a <pre>version</pre> element and dependencies
* without a <pre>version</pre> element, for which the version could be found elsewhere in the same aggregator project,
* the <pre>DefaultModelBuilder</pre> would enrich the dependencies without a <pre>version</pre> element.
* The dependencies that did have a <pre>version</pre> element would not be copied over into the new <pre>Model</pre>
* instance.
*/
class MavenITmng8331VersionedAndUnversionedDependenciesTest extends AbstractMavenIntegrationTestCase {

MavenITmng8331VersionedAndUnversionedDependenciesTest() {
super("[4.0.0-beta-5,)");
}

/**
* Since the dependency on junit-jupiter-api had a version, it was added to the project. The dependency on module-a
* did not have a version, but could be found in the same multi-module project. As a result, the dependency on
* junit-jupiter-api was not present in the model (see class-level JavaDoc) which would cause the test-compile
* to fail.
*/
@Test
void allDependenciesArePresentInTheProject() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8331-versioned-and-unversioned-deps");

Verifier verifier = new Verifier(testDir.getAbsolutePath());
verifier.setLogFileName("allDependenciesArePresentInTheProject.txt");
verifier.executeGoal("test-compile");

verifier.verifyErrorFreeLog();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public TestSuiteOrdering() {
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
suite.addTestSuite(MavenITmng8331VersionedAndUnversionedDependenciesTest.class);
suite.addTestSuite(MavenITmng8299CustomLifecycleTest.class);
suite.addTestSuite(MavenITmng7982DependencyManagementTransitivityTest.class);
suite.addTestSuite(MavenITmng8294ParentChecksTest.class);
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0-beta-4.xsd">
<parent>
<groupId>org.apache.maven.its</groupId>
<artifactId>mng8331</artifactId>
<version>1-SNAPSHOT</version>
</parent>

<artifactId>module-a</artifactId>
<packaging>jar</packaging>
</project>
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.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0-beta-4.xsd">
<parent>
<groupId>org.apache.maven.its</groupId>
<artifactId>mng8331</artifactId>
<version>1-SNAPSHOT</version>
</parent>

<artifactId>module-b</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.maven.its</groupId>
<artifactId>module-a</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.its.deps;

import org.junit.jupiter.api.Test;

class ExampleTest {
@Test
void example() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0-beta-4.xsd">
<groupId>org.apache.maven.its</groupId>
<artifactId>mng8331</artifactId>
<version>1-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>module-a</module>
<module>module-b</module>
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

0 comments on commit 07ab883

Please sign in to comment.