Skip to content

Commit

Permalink
Merge remote-tracking branch 'cstamas/MNG-8340' into MNG-8340
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 29, 2024
2 parents e1a32ca + 4689350 commit 0e8d805
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 java.util.List;

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-8340">MNG-8340</a>.
*/
class MavenITmng8340GeneratedPomInTargetTest extends AbstractMavenIntegrationTestCase {

MavenITmng8340GeneratedPomInTargetTest() {
super("[3.8.6,)");
}

/**
* Verify that the build succeeds.
*/
@Test
void testProjectWithShadePluginAndGeneratedPomUnderTarget() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8340");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.addCliArgument("package");
verifier.execute();
verifier.verifyErrorFreeLog();

List<String> l = verifier.loadLines(verifier.getLogFileName(), "UTF-8");
if (matchesVersionRange("[4.0.0-beta-5]")) {
assertTrue(l.stream()
.anyMatch(i -> i.contains(
"[FATAL] 'parent.relativePath' points at '../../pom.xml' but no POM could be found")));
} else {
assertFalse(l.stream()
.anyMatch(i -> i.contains(
"[FATAL] 'parent.relativePath' points at '../../pom.xml' but no POM could be found")));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,58 @@ void transitiveDependencyManager() throws Exception {
}
}

/**
* Mimic bnd-maven-plugin:7.0.0: have direct dependency on plexus-build-api:0.0.7 and observe plexus-utils.
* Beta-5 makes it 1.5.5 while correct version is 1.5.8.
*/
@Test
void useCaseBndPlugin() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8347-bnd-plugin");

Verifier verifier = new Verifier(testDir.getAbsolutePath());
verifier.addCliArgument("-V");
verifier.addCliArgument("dependency:3.8.0:tree");
verifier.addCliArgument("-Dmaven.repo.local.tail=" + testDir + "/local-repo");
verifier.addCliArgument("-Dmaven.repo.local.tail.ignoreAvailability");
verifier.execute();
verifier.verifyErrorFreeLog();

List<String> l = verifier.loadLines(verifier.getLogFileName(), "UTF-8");
if (matchesVersionRange("[4.0.0-beta-5]")) {
a(l, "[INFO] org.apache.maven.it.mresolver614:root:jar:1.0.0");
a(l, "[INFO] \\- org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile");
a(l, "[INFO] \\- org.codehaus.plexus:plexus-utils:jar:1.5.5:compile");
} else {
a(l, "[INFO] org.apache.maven.it.mresolver614:root:jar:1.0.0");
a(l, "[INFO] \\- org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile");
a(l, "[INFO] \\- org.codehaus.plexus:plexus-utils:jar:1.5.8:compile");
}
}

/**
* Make Quarkus TLS Registry first level dependency and make sure expected stuff are present.
*/
@Test
void useCaseQuarkusTlsRegistry() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8347-quarkus-tls-registry");

Verifier verifier = new Verifier(testDir.getAbsolutePath());
verifier.addCliArgument("-V");
verifier.addCliArgument("dependency:3.8.0:tree");
verifier.addCliArgument("-Dmaven.repo.local.tail=" + testDir + "/local-repo");
verifier.addCliArgument("-Dmaven.repo.local.tail.ignoreAvailability");
verifier.execute();
verifier.verifyErrorFreeLog();

// this really boils down to "transitive" vs "non-transitive"
List<String> l = verifier.loadLines(verifier.getLogFileName(), "UTF-8");
if (matchesVersionRange("[,4.0.0-alpha-11)")) {
a(l, "[INFO] | | | \\- com.fasterxml.jackson.core:jackson-core:jar:2.16.1:compile");
} else {
a(l, "[INFO] | | | \\- com.fasterxml.jackson.core:jackson-core:jar:2.17.2:compile");
}
}

/**
* Assert true, log lines contains string...
*/
Expand Down
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(MavenITmng8340GeneratedPomInTargetTest.class);
suite.addTestSuite(MavenITmng8360SubprojectProfileActivationTest.class);
suite.addTestSuite(MavenITmng8347TransitiveDependencyManagerTest.class);
suite.addTestSuite(MavenITmng8341DeadlockTest.class);
Expand Down
42 changes: 42 additions & 0 deletions core-it-suite/src/test/resources/mng-8340/child1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.it.mng8340</groupId>
<artifactId>root</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>child1</artifactId>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>shade</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<dependencyReducedPomLocation>${basedir}/target/dr-pom.xml</dependencyReducedPomLocation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
21 changes: 21 additions & 0 deletions core-it-suite/src/test/resources/mng-8340/child2/pom.xml
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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.it.mng8340</groupId>
<artifactId>root</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>child2</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.maven.it.mng8340</groupId>
<artifactId>child1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
15 changes: 15 additions & 0 deletions core-it-suite/src/test/resources/mng-8340/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.it.mng8340</groupId>
<artifactId>root</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
<module>child1</module>
<module>child2</module>
</modules>
</project>
17 changes: 17 additions & 0 deletions core-it-suite/src/test/resources/mng-8347-bnd-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.it.mresolver614</groupId>
<artifactId>root</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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 https://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.it.mresolver614</groupId>
<artifactId>root</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-tls-registry</artifactId>
<version>3.15.1</version>
</dependency>
</dependencies>
</project>

0 comments on commit 0e8d805

Please sign in to comment.