This is an automated email from the ASF dual-hosted git repository. bmarwell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git
commit 28bb374838d0ef1b308138c4908fb00ee795219e Author: Peter <[email protected]> AuthorDate: Sun Jul 20 18:46:55 2025 +1000 Add integration test attach_skip to test jlink plugin correctly skips attaching output artifacts when attach parameter set to false --- pom.xml | 5 +- src/it/projects/attach_skip/invoker.properties | 17 ++++ src/it/projects/attach_skip/pom.xml | 109 +++++++++++++++++++++++++ src/it/projects/attach_skip/verify.groovy | 95 +++++++++++++++++++++ 4 files changed, 225 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f34a017..c6f60fc 100644 --- a/pom.xml +++ b/pom.xml @@ -228,7 +228,6 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-invoker-plugin</artifactId> <configuration> - <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> <environmentVariables> <!-- ! Prevent reading the .mavenrc or maven_pre.bat on Windows @@ -236,6 +235,10 @@ --> <MAVEN_SKIP_RC>1</MAVEN_SKIP_RC> </environmentVariables> + <!-- Pass local repo directory as script variable to verify.groovy --> + <scriptVariables> + <localRepoStr>${project.build.directory}/local-repo</localRepoStr> + </scriptVariables> <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> <projectsDirectory>src/it/projects</projectsDirectory> <pomIncludes> diff --git a/src/it/projects/attach_skip/invoker.properties b/src/it/projects/attach_skip/invoker.properties new file mode 100644 index 0000000..cecfb8c --- /dev/null +++ b/src/it/projects/attach_skip/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals = clean install diff --git a/src/it/projects/attach_skip/pom.xml b/src/it/projects/attach_skip/pom.xml new file mode 100644 index 0000000..e8f36de --- /dev/null +++ b/src/it/projects/attach_skip/pom.xml @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<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/maven-v4_0_0.xsd" +> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jlink-plugin-it-attach-skip</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + <name>IT-attach-skip</name> + <url>https://maven.apache.org</url> + <description>Test jlink plugin skips attaching output artifacts when attach parameter set to false.</description> + <properties> + <maven.compiler.release>9</maven.compiler.release> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>localhost</groupId> + <artifactId>first-jar-module-info</artifactId> + <version>99.0</version> + </dependency> + </dependencies> + + <build> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jlink-plugin</artifactId> + <version>@project.version@</version> + <extensions>true</extensions> + + <executions> + <!-- Generate supplemental artifact (i.e. with classifier defined) and configure to skip attaching --> + <execution> + <id>create-runtime-image-1</id> + <phase>package</phase> + <goals> + <goal>jlink</goal> + </goals> + + <configuration> + <classifier>jlink1</classifier> + <!-- Skip attaching as an artifact --> + <attach>false</attach> + </configuration> + </execution> + + <!-- Generate main artifact (i.e. omitting classifier definition) and configure to skip attaching --> + <execution> + <id>create-runtime-image-2</id> + <phase>package</phase> + <goals> + <goal>jlink</goal> + </goals> + + <configuration> + <!-- Skip attaching as an artifact --> + <attach>false</attach> + </configuration> + </execution> + + <!-- Generate supplemental artifact (i.e. with classifier defined) and configure to attach --> + <execution> + <id>create-runtime-image-3</id> + <phase>package</phase> + <goals> + <goal>jlink</goal> + </goals> + + <configuration> + <classifier>jlink3</classifier> + <!-- Attach as an artifact --> + <attach>true</attach> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + </build> +</project> diff --git a/src/it/projects/attach_skip/verify.groovy b/src/it/projects/attach_skip/verify.groovy new file mode 100644 index 0000000..401b199 --- /dev/null +++ b/src/it/projects/attach_skip/verify.groovy @@ -0,0 +1,95 @@ + +/* + * 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. + */ + +import java.io.*; +import java.util.*; +import java.util.jar.*; +import org.codehaus.plexus.util.*; + +try +{ + File target = new File( basedir, "target" ) + if ( !target.exists() || !target.isDirectory() ) { + System.err.println( "target file is missing or not a directory." ) + return false + } + + // Check script variable was passed correctly from parent POM + if (!binding.hasVariable('localRepoStr') || localRepoStr == null || localRepoStr.isEmpty()) { + System.err.println("localRepoStr script variable not set or null.") + return false + } + + // Get local repository path from script variable and validate it exists + File localRepo = new File(localRepoStr) + System.out.println("[INFO] localRepo set to: " + localRepo.getAbsolutePath()) + + if ( !localRepo.exists() || !localRepo.isDirectory() ) { + System.err.println("localRepo not set to a valid directory.") + return false + } + + + // Check that output artifacts have been created + File artifact1 = new File( target, "maven-jlink-plugin-it-attach-skip-1.0-jlink1.zip" ) + if ( !artifact1.exists() || artifact1.isDirectory() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0-jlink1.zip file is missing or is a directory." ) + return false + } + + File artifact2 = new File( target, "maven-jlink-plugin-it-attach-skip-1.0.zip" ) + if ( !artifact2.exists() || artifact2.isDirectory() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0.zip file is missing or is a directory." ) + return false + } + + File artifact3 = new File( target, "maven-jlink-plugin-it-attach-skip-1.0-jlink3.zip" ) + if ( !artifact3.exists() || artifact3.isDirectory() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0-jlink3.zip file is missing or is a directory." ) + return false + } + + + // Check that the artifacts' installation status is as expected based on the attach parameter + installedArtifact1 = new File( localRepo, "org/apache/maven/plugins/maven-jlink-plugin-it-attach-skip/1.0/maven-jlink-plugin-it-attach-skip-1.0-jlink1.zip" ) + if ( installedArtifact1.exists() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0-jlink1.zip WAS installed when attach parameter set to FALSE." ) + return false + } + + installedArtifact2 = new File( localRepo, "org/apache/maven/plugins/maven-jlink-plugin-it-attach-skip/1.0/maven-jlink-plugin-it-attach-skip-1.0.zip" ) + if ( installedArtifact2.exists() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0.zip WAS installed when attach parameter set to FALSE." ) + return false + } + + installedArtifact3 = new File( localRepo, "org/apache/maven/plugins/maven-jlink-plugin-it-attach-skip/1.0/maven-jlink-plugin-it-attach-skip-1.0-jlink3.zip" ) + if ( !installedArtifact3.exists() ) { + System.err.println( "maven-jlink-plugin-it-attach-skip-1.0-jlink3.zip NOT installed when attach parameter set to TRUE." ) + return false + } + + return true +} +catch( Throwable e ) +{ + e.printStackTrace() + return false +}
