Merge branch 'feature/distributionManagement'

Change-Id: If4110533342898ff92065d701adf92e7396d04a3
This commit is contained in:
Mark Derricutt
2023-11-20 19:26:26 +13:00
9 changed files with 141 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
name: Integration Tests on Java 8 and Maven 4.0.0-alpha-7
name: Integration Tests on Java 8 and Maven 4.0.0-alpha-8
on:
push:
@@ -19,7 +19,7 @@ jobs:
java-version: 8
- name: Switch To Maven 4
run: |
echo "distributionUrl=https://dlcdn.apache.org/maven/maven-4/4.0.0-alpha-7/binaries/apache-maven-4.0.0-alpha-7-bin.zip" > .mvn/wrapper/maven-wrapper.properties
echo "distributionUrl=https://dlcdn.apache.org/maven/maven-4/4.0.0-alpha-8/binaries/apache-maven-4.0.0-alpha-8-bin.zip" > .mvn/wrapper/maven-wrapper.properties
echo "wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" >> .mvn/wrapper/maven-wrapper.properties
- name: Build with Maven
run: ./mvnw --batch-mode --update-snapshots install -Prun-its

View File

@@ -101,13 +101,13 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
<version>2.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -119,7 +119,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.9.0</version>
<version>3.10.2</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

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

View File

@@ -0,0 +1,31 @@
<?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 Distribution Management Test</name>
<modules>
<module>tileA</module>
<module>projectA</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</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,36 @@
<?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>
<distributionManagement>
<repository>
<id>repaint-staging</id>
<name>io.repaint Staging Repository</name>
<url>file:///tmp/maven-tiles/staging/</url>
</repository>
<snapshotRepository>
<id>repaint-snapshots</id>
<name>io.repaint Snapshot Repository</name>
<url>file:///tmp/maven-tiles/snapshot/</url>
</snapshotRepository>
</distributionManagement>
<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>repaint-tile-staging</id>
<name>io.repaint Staging Repository</name>
<url>file:///tmp/maven-tiles/staging/</url>
</repository>
<snapshotRepository>
<id>repaint-tile-snapshots</id>
<name>io.repaint Snapshot Repository</name>
<url>file:///tmp/maven-tiles/snapshot/</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@@ -0,0 +1,15 @@
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("<id>repaint-tile-staging</id>"))
throw new Exception("<id>repaint-tile-staging</id> expected to be in effective pom");
if (!content.contains("io.repaint Staging Repository"))
throw new Exception("io.repaint 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,13 +374,14 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
}
if (distributionManagement.snapshotRepository) {
ArtifactRepository repo = new MavenArtifactRepository(
ArtifactRepositoryLayout layout = repositoryLayouts.get(distributionManagement.snapshotRepository.layout);
MavenArtifactRepository repo = new MavenArtifactRepository(
distributionManagement.snapshotRepository.id,
getSnapshotDistributionManagementRepositoryUrl(project),
repositoryFactory.layout,
layout,
getArtifactRepositoryPolicy(distributionManagement.snapshotRepository.snapshots),
getArtifactRepositoryPolicy(distributionManagement.snapshotRepository.releases))
project.setReleaseArtifactRepository(repo)
project.setSnapshotArtifactRepository(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)