Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/distribution management #148

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/java8_m4.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions src/it/distributionManagemetTile/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = clean dependency:go-offline help:effective-pom deploy
31 changes: 31 additions & 0 deletions src/it/distributionManagemetTile/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
27 changes: 27 additions & 0 deletions src/it/distributionManagemetTile/projectA/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
36 changes: 36 additions & 0 deletions src/it/distributionManagemetTile/tileA/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
18 changes: 18 additions & 0 deletions src/it/distributionManagemetTile/tileA/tile.xml
Original file line number Diff line number Diff line change
@@ -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>
15 changes: 15 additions & 0 deletions src/it/distributionManagemetTile/verify.bsh
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -349,7 +348,6 @@ class TilesMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant {
} else {
return new ArtifactRepositoryPolicy(true, UPDATE_POLICY_ALWAYS, CHECKSUM_POLICY_WARN)
}

}

/**
Expand All @@ -364,24 +362,26 @@ 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)

}
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)

}
}
Expand Down Expand Up @@ -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)
Expand Down
Loading