Skip to content

Commit

Permalink
Merge branch 'master' of github.com:apache/maven-integration-testing …
Browse files Browse the repository at this point in the history
…into MPH-183_dependency-management-hierarchy-inputsource
  • Loading branch information
juulhobert committed Sep 20, 2024
2 parents 7be71e6 + 1336e2d commit 1b16b7a
Show file tree
Hide file tree
Showing 62 changed files with 1,164 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testitMNG1021() throws Exception {
verifier.setAutoclean(false);
verifier.deleteDirectory("repo");
verifier.deleteArtifacts("org.apache.maven.its.mng1021");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("-Dmaven.consumer.pom=false");
verifier.addCliArgument("initialize");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void testit() throws Exception {
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("pre-site");
verifier.addCliArgument("-Dmaven.site.skip=true");
verifier.execute();
verifier.verifyErrorFreeLog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,74 @@ public void testitPackagePhase() throws Exception {
verifier.execute();
verifier.verifyErrorFreeLog();

String prefix = matchesVersionRange("[4.0.0-alpha-4,)") ? "dependency-0.1-SNAPSHOT-" : "";
String prefix = "";

List<String> classpath;

classpath = verifier.loadLines("consumer-a/target/compile.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "tests.jar"});
assertNotContains(classpath, new String[] {prefix + "client.jar"});
classpath = verifier.loadLines("consumer-a/target/runtime.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "tests.jar"});
assertNotContains(classpath, new String[] {prefix + "client.jar"});
classpath = verifier.loadLines("consumer-a/target/test.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "tests.jar"});
assertNotContains(classpath, new String[] {prefix + "client.jar"});

classpath = verifier.loadLines("consumer-b/target/compile.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
classpath = verifier.loadLines("consumer-b/target/runtime.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertNotContains(classpath, new String[] {prefix + "tests.jar"});
classpath = verifier.loadLines("consumer-b/target/test.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertNotContains(classpath, new String[] {prefix + "tests.jar"});

classpath = verifier.loadLines("consumer-c/target/compile.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertContains(classpath, new String[] {prefix + "tests.jar"});
classpath = verifier.loadLines("consumer-c/target/runtime.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertContains(classpath, new String[] {prefix + "tests.jar"});
classpath = verifier.loadLines("consumer-c/target/test.txt", "UTF-8");
assertContains(classpath, new String[] {prefix + "client.jar"});
assertContains(classpath, new String[] {prefix + "tests.jar"});
}

/**
* Test that dependency resolution still uses the actual artifact files once these have been
* assembled/attached in the "package" phase. This ensures the class path is accurate and not locked to
* the output directories of the best effort model from above.
*
* @throws Exception in case of failure
*/
@Test
public void testitPackagePhasesSlitted() throws Exception {
requiresMavenVersion("[4.0.0-beta-4,)");

File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-3043");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.deleteDirectory("consumer-a/target");
verifier.deleteDirectory("consumer-b/target");
verifier.deleteDirectory("consumer-c/target");
verifier.deleteArtifacts("org.apache.maven.its.mng3043");
verifier.setLogFileName("log-package-pre.txt");
verifier.addCliArguments("--also-make", "--projects", ":dependency", "package");
verifier.execute();
verifier.verifyErrorFreeLog();

verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.setLogFileName("log-package-pre.txt");
verifier.addCliArguments("--projects", ":consumer-a,:consumer-b,:consumer-c", "package");
verifier.execute();
verifier.verifyErrorFreeLog();

String prefix = "dependency-0.1-SNAPSHOT-";

List<String> classpath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public void testitMNG3396() throws Exception {
verifier.deleteArtifact(GROUP_ID, "A", "1.0", "jar");
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "B", "1.0", "jar");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand All @@ -60,7 +59,6 @@ public void testitMNG3396() throws Exception {
verifier.deleteArtifact(GROUP_ID, "A", "3.0", "jar");
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "plugin", "1.0", "jar");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand All @@ -70,7 +68,6 @@ public void testitMNG3396() throws Exception {
verifier = newVerifier(testDir.getAbsolutePath(), "remote");
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "pom");
verifier.deleteArtifact(GROUP_ID, "pluginuser", "1.0", "jar");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -31,6 +32,7 @@
* @author Benjamin Bentmann
*
*/
@Disabled("MNG-7255 provides the default groupId from the parent")
public class MavenITmng3863AutoPluginGroupIdTest extends AbstractMavenIntegrationTestCase {

public MavenITmng3863AutoPluginGroupIdTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testContinuousDeliveryFriendlyVersionsAreWarningFreeWithoutBuildCons
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-Dchangelist=changelist");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("-Dmaven.consumerpom=false");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down Expand Up @@ -83,7 +83,7 @@ public void testContinuousDeliveryFriendlyVersionsAreWarningFreeWithBuildConsume
verifier.setAutoclean(false);
verifier.deleteDirectory("target");
verifier.addCliArgument("-Dchangelist=changelist");
verifier.addCliArgument("-Dmaven.buildconsumer=true");
verifier.addCliArgument("-Dmaven.consumerpom=true");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testWithoutBuildConsumer() throws Exception {
verifier.setAutoclean(false);
verifier.addCliArgument("-q");
verifier.addCliArgument("-U");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("-Dmaven.consumerpom=false");
verifier.addCliArgument("verify");
verifier.execute();

Expand Down Expand Up @@ -93,7 +93,7 @@ public void testWithBuildConsumer() throws Exception {
verifier.setAutoclean(false);
verifier.addCliArgument("-q");
verifier.addCliArgument("-U");
verifier.addCliArgument("-Dmaven.buildconsumer=true");
verifier.addCliArgument("-Dmaven.consumerpom=true");
verifier.addCliArgument("verify");
verifier.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testitShouldResolveTheDependenciesWithoutBuildConsumer() throws Exce

// verifier.setLogFileName( "log-only.txt" );
verifier.addCliArgument("-Drevision=1.2");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("-Dmaven.consumerpom=false");
verifier.addCliArgument("clean");
verifier.execute();
verifier.addCliArgument("package");
Expand All @@ -76,7 +76,7 @@ public void testitShouldResolveTheDependenciesWithBuildConsumer() throws Excepti

verifier.setLogFileName("log-bc.txt");
verifier.addCliArgument("-Drevision=1.2");
verifier.addCliArgument("-Dmaven.buildconsumer=true");
verifier.addCliArgument("-Dmaven.consumerpom=true");
verifier.addCliArgument("clean");
verifier.execute();
verifier.addCliArgument("package");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testitShouldResolveTheDependenciesWithoutBuildConsumer() throws Exce
verifier.setAutoclean(false);

verifier.addCliArgument("-Drevision=1.2");
verifier.addCliArgument("-Dmaven.buildconsumer=false");
verifier.addCliArgument("-Dmaven.consumerpom=false");
verifier.setLogFileName("install-log.txt");
verifier.addCliArguments("clean", "install");
verifier.execute();
Expand All @@ -82,7 +82,7 @@ public void testitShouldResolveTheDependenciesWithBuildConsumer() throws Excepti
verifier.setForkJvm(true);

verifier.addCliArgument("-Drevision=1.2");
verifier.addCliArgument("-Dmaven.buildconsumer=true");
verifier.addCliArgument("-Dmaven.consumerpom=true");
verifier.setLogFileName("install-log.txt");
verifier.addCliArguments("clean", "install");
verifier.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;

/**
* With the build-consumer the pom.xml will be adjusted during the process.
Expand Down Expand Up @@ -111,15 +109,9 @@ public void testPublishedPoms() throws Exception {
}

static void assertTextEquals(File file1, File file2) throws IOException {
List<String> s1 = FileUtils.loadFile(file1);
List<String> s2 = FileUtils.loadFile(file2);
try {
assertEquals("Not same size", s1.size(), s2.size());
for (int i = 0; i < s1.size(); i++) {
assertEquals("Mismatch line " + i, s1.get(i), s2.get(i));
}
} catch (AssertionFailedError error) {
assertEquals(error.getMessage(), s1, s2);
}
assertEquals(
"pom files differ " + file1 + " " + file2,
String.join("\n", FileUtils.loadFile(file1)),
String.join("\n", FileUtils.loadFile(file2)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public void testPublishedPoms() throws Exception {
}

static void assertTextEquals(File file1, File file2) throws IOException {
assertEquals(FileUtils.loadFile(file1), FileUtils.loadFile(file2));
assertEquals(
"pom files differ " + file1 + " " + file2,
String.join("\n", FileUtils.loadFile(file1)),
String.join("\n", FileUtils.loadFile(file2)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.io.IOException;

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

public class MavenITmng7255InferredGroupIdTest extends AbstractMavenIntegrationTestCase {
private static final String PROJECT_PATH = "/mng-7255-inferred-groupid";

public MavenITmng7255InferredGroupIdTest() {
super("[4.0.0-alpha-5,)");
}

@Test
public void testInferredGroupId() throws IOException, VerificationException {
final File projectDir = ResourceExtractor.simpleExtractResources(getClass(), PROJECT_PATH);
final Verifier verifier = newVerifier(projectDir.getAbsolutePath());

verifier.addCliArgument("validate");
verifier.execute();

verifier.verifyErrorFreeLog();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8181">MNG-8181</a>.
*/
public class MavenITmng8181CentralRepoTest extends AbstractMavenIntegrationTestCase {
public MavenITmng8181CentralRepoTest() {
super("[4.0.0-beta-4,)");
}

/**
* Verify that the central url can be overridden by a user property.
*
* @throws Exception in case of failure
*/
@Test
public void testitModel() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8181-central-repo");

Verifier verifier = newVerifier(testDir.getAbsolutePath(), null);
verifier.setAutoclean(false);
verifier.addCliArgument("--install-settings=install-settings.xml");
verifier.addCliArgument("--settings=settings.xml");
verifier.addCliArgument("-Dmaven.repo.local=" + testDir.toPath().resolve("target/local-repo"));
verifier.addCliArgument("-Dmaven.repo.central=http://repo1.maven.org/");
verifier.addCliArgument("validate");
assertThrows(VerificationException.class, verifier::execute);
verifier.verifyTextInLog("central (http://repo1.maven.org/, default, releases)");
}
}
Loading

0 comments on commit 1b16b7a

Please sign in to comment.