Added distributionManagement IT test

Change-Id: I72ee773efceb476e70d2adeda24aec12293691cc
This commit is contained in:
Mark Derricutt
2023-11-03 22:47:15 +13:00
parent ef05aa7efe
commit 8e82176a01
7 changed files with 105 additions and 9 deletions

View File

@@ -0,0 +1 @@
invoker.goals = clean dependency:go-offline help:effective-pom

View File

@@ -0,0 +1,16 @@
<?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>io.repaint.maven</groupId>
<artifactId>distribution-management-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Maven Tiles Order Test</name>
<modules>
<module>tileA</module>
<module>projectA</module>
</modules>
</project>

View File

@@ -0,0 +1,27 @@
<?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>io.repaint.maven</groupId>
<artifactId>projectA</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>Maven Distribution Management Test</name>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.repaint.maven:tileA:1</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,23 @@
<?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>io.repaint.maven</groupId>
<artifactId>tileA</artifactId>
<version>1</version>
<packaging>tile</packaging>
<name>Maven Tiles Distribution Management Test - TileA</name>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<distributionManagement>
<repository>
<id>sonatype-staging</id>
<name>oss.sonatype.org Staging Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>sonatype-snapshots</id>
<name>oss.sonatype.org Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@@ -0,0 +1,13 @@
import java.io.*;
import java.util.*;
File file = new File(basedir, "build.log" );
if ( !file.isFile() ) {
throw new FileNotFoundException( "Could not find build log: " + file );
}
String content = new Scanner(file).useDelimiter("\\Z").next();
// tileX should win
if (!content.contains("oss.sonatype.org Staging Repository"))
throw new Exception("oss.sonatype.org Staging Repository expected to be in effective pom");

View File

@@ -25,7 +25,6 @@ import org.apache.maven.RepositoryUtils
import org.apache.maven.artifact.Artifact
import org.apache.maven.artifact.DefaultArtifact
import org.apache.maven.artifact.handler.DefaultArtifactHandler
import org.apache.maven.artifact.repository.ArtifactRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy
import org.apache.maven.artifact.repository.MavenArtifactRepository
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout
@@ -309,7 +308,7 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
// disabled explicit lookup as these seem to be injected just fine. Are these required for eclipse m2e>
//repositoryFactory = mavenSession.container.lookup(ArtifactRepositoryFactory)
//repositoryLayouts = mavenSession.lookupMap(ArtifactRepositoryLayout.class.getName()) as Map<String, ArtifactRepositoryLayout>
repositoryLayouts = mavenSession.lookupMap(ArtifactRepositoryLayout.class.getName()) as Map<String, ArtifactRepositoryLayout>
List<MavenProject> allProjects = mavenSession.getProjects()
if (allProjects != null) {
@@ -349,7 +348,6 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
} else {
return new ArtifactRepositoryPolicy(true, UPDATE_POLICY_ALWAYS, CHECKSUM_POLICY_WARN)
}
}
/**
@@ -364,10 +362,11 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
if (distributionManagement) {
if (distributionManagement.repository) {
ArtifactRepository repo = new MavenArtifactRepository(
ArtifactRepositoryLayout layout = repositoryLayouts.get(distributionManagement.repository.layout);
MavenArtifactRepository repo = new MavenArtifactRepository(
distributionManagement.repository.id,
getReleaseDistributionManagementRepositoryUrl(project),
repositoryFactory.layout,
layout,
getArtifactRepositoryPolicy(distributionManagement.repository.snapshots),
getArtifactRepositoryPolicy(distributionManagement.repository.releases))
project.setReleaseArtifactRepository(repo)
@@ -375,10 +374,11 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
}
if (distributionManagement.snapshotRepository) {
ArtifactRepository repo = new MavenArtifactRepository(
ArtifactRepositoryLayout layout = repositoryLayouts.get(distributionManagement.repository.layout);
MavenArtifactRepository repo = new MavenArtifactRepository(
distributionManagement.snapshotRepository.id,
getSnapshotDistributionManagementRepositoryUrl(project),
repositoryFactory.layout,
layout,
getArtifactRepositoryPolicy(distributionManagement.snapshotRepository.snapshots),
getArtifactRepositoryPolicy(distributionManagement.snapshotRepository.releases))
project.setReleaseArtifactRepository(repo)
@@ -503,8 +503,6 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
Model read(InputStream input, Map<String, ?> options) throws IOException, ModelParseException {
Model model = modelProcessor.read(input, options)
use(GavUtil) {
// when we reference a submodule of a CI Friendly module in a pom (i.e. a workspace pom in Eclipse)