-
Notifications
You must be signed in to change notification settings - Fork 36
[#620] Add support for optional attach parameter to disable artifact attachment #621
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
Open
peter277
wants to merge
4
commits into
apache:master
Choose a base branch
from
peter277:add-attach-option
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
26dfd96
Add support for optional attach parameter to disable artifact attachment
peter277 a73468e
Add integration test attach_skip to test jlink plugin correctly skips…
peter277 177d25b
Refactor artifact attachment logic into separate method with guard cl…
peter277 e451204
Apply Spotless formatting
peter277 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
peter277 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simply use a groovy
asserthttps://groovy-lang.org/semantics.html#_power_assertion
but it is not a blocker for it