You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/05/16 11:33:28 UTC
[maven-build-cache-extension] branch master updated: Use maven 3.9 by default, make maven4 optional using profiles (#13)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git
The following commit(s) were added to refs/heads/master by this push:
new 01a04f4 Use maven 3.9 by default, make maven4 optional using profiles (#13)
01a04f4 is described below
commit 01a04f42313c85a83c85fa5cd43c146d44530e25
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon May 16 13:33:24 2022 +0200
Use maven 3.9 by default, make maven4 optional using profiles (#13)
* Use maven 3.9 by default, make maven4 optional using profiles
* Add maven 3/4 in the CI matrix
---
.github/workflows/maven.yml | 3 +-
pom.xml | 127 +++++++++++++++------
.../its/junit/IntegrationTestExtension.java | 34 +++---
3 files changed, 116 insertions(+), 48 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 41d709e..22a22b1 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -25,6 +25,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest]
java: [11, 17]
+ maven: [maven3, maven4]
fail-fast: false
runs-on: ${{ matrix.os }}
@@ -49,5 +50,5 @@ jobs:
${{ runner.os }}-maven-
- name: Build with Maven
- run: mvn install -e -B -V
+ run: mvn install -e -B -V -P${{ matrix.maven }}
diff --git a/pom.xml b/pom.xml
index 8f13f08..deb17e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,8 @@ under the License.
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<classWorldsVersion>2.6.0</classWorldsVersion>
- <maven3Version>3.9.0-SNAPSHOT</maven3Version><!-- MNG-7391-maven-3.8.x branch, waiting for MNG-7391 Maven API update -->
- <maven4Version>4.0.0-alpha-1-SNAPSHOT</maven4Version><!-- MNG-7391-master branch, waiting for MNG-7391 Maven API update -->
+ <maven3Version>3.9.0-SNAPSHOT</maven3Version>
+ <maven4Version>4.0.0-alpha-1-SNAPSHOT</maven4Version>
<formatter-maven-plugin.version>2.17.0</formatter-maven-plugin.version>
<impsort-maven-plugin.version>1.6.2</impsort-maven-plugin.version>
@@ -94,7 +94,7 @@ under the License.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>${maven4Version}</version>
+ <version>${maven3Version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -365,37 +365,6 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
- <executions>
- <execution>
- <id>copy-maven-distributions</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.maven</groupId>
- <artifactId>apache-maven</artifactId>
- <version>${maven3Version}</version>
- <classifier>bin</classifier>
- <type>tar.gz</type>
- <overWrite>false</overWrite>
- <outputDirectory>${project.build.directory}/maven3</outputDirectory>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.maven</groupId>
- <artifactId>apache-maven</artifactId>
- <version>${maven4Version}</version>
- <classifier>bin</classifier>
- <type>tar.gz</type>
- <overWrite>false</overWrite>
- <outputDirectory>${project.build.directory}/maven4</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -411,4 +380,94 @@ under the License.
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>maven3</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-maven3-distributions</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>apache-maven</artifactId>
+ <version>${maven3Version}</version>
+ <classifier>bin</classifier>
+ <type>tar.gz</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/maven3</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <with-maven3>true</with-maven3>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>maven4</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-maven4-distributions</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>apache-maven</artifactId>
+ <version>${maven4Version}</version>
+ <classifier>bin</classifier>
+ <type>tar.gz</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/maven4</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <with-maven4>true</with-maven4>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/src/test/java/org/apache/maven/buildcache/its/junit/IntegrationTestExtension.java b/src/test/java/org/apache/maven/buildcache/its/junit/IntegrationTestExtension.java
index 3917fc9..00e81f5 100644
--- a/src/test/java/org/apache/maven/buildcache/its/junit/IntegrationTestExtension.java
+++ b/src/test/java/org/apache/maven/buildcache/its/junit/IntegrationTestExtension.java
@@ -68,7 +68,9 @@ public class IntegrationTestExtension implements BeforeAllCallback, TestTemplate
ExtensionContext extensionContext )
{
Method m = extensionContext.getRequiredTestMethod();
- return Stream.of( maven3, maven4 ).map( p -> new MavenTemplate( m, p ) );
+ return Stream.concat( maven3 != null ? Stream.of( maven3 ) : Stream.empty(),
+ maven4 != null ? Stream.of( maven4 ) : Stream.empty() )
+ .map( p -> new MavenTemplate( m, p ) );
}
private static void buildMaven() throws Exception
@@ -81,20 +83,26 @@ public class IntegrationTestExtension implements BeforeAllCallback, TestTemplate
// "The 'maven.multiModuleProjectDirectory' system property need to be set" );
// maven3
- maven3 = Files.list( Paths.get( "target/maven3" ) )
- .filter( f -> f.getFileName().toString().startsWith( "apache-maven" ) && Files.isDirectory( f ) )
- .findFirst()
- .orElseThrow( () -> new IllegalStateException( "Unable to find maven3 directory" ) )
- .toAbsolutePath();
- maven3.resolve( "bin/mvn" ).toFile().setExecutable( true );
+ if ( Boolean.getBoolean( "with-maven3" ) )
+ {
+ maven3 = Files.list( Paths.get( "target/maven3" ) )
+ .filter( f -> f.getFileName().toString().startsWith( "apache-maven" ) && Files.isDirectory( f ) )
+ .findFirst()
+ .map( Path::toAbsolutePath )
+ .orElseThrow( () -> new IllegalStateException( "Unable to find maven3 directory" ) );
+ maven3.resolve( "bin/mvn" ).toFile().setExecutable( true );
+ }
// maven4
- maven4 = Files.list( Paths.get( "target/maven4" ) )
- .filter( f -> f.getFileName().toString().startsWith( "apache-maven" ) && Files.isDirectory( f ) )
- .findFirst()
- .orElseThrow( () -> new IllegalStateException( "Unable to find maven4 directory" ) )
- .toAbsolutePath();
- maven4.resolve( "bin/mvn" ).toFile().setExecutable( true );
+ if ( Boolean.getBoolean( "with-maven4" ) )
+ {
+ maven4 = Files.list( Paths.get( "target/maven4" ) )
+ .filter( f -> f.getFileName().toString().startsWith( "apache-maven" ) && Files.isDirectory( f ) )
+ .findFirst()
+ .map( Path::toAbsolutePath )
+ .orElse( null );
+ maven4.resolve( "bin/mvn" ).toFile().setExecutable( true );
+ }
initialized = true;
}