Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 8355ad6

Browse files
committed
Added result image as archive to the project so
an mvn install/deploy now works. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1799963 13f79535-47bb-0310-9956-ffa450edef68
1 parent 5754e4f commit 8355ad6

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
<configuration>
3232
<type>jlink</type>
3333
<extension>zip</extension>
34-
<!-- Need to check the following? -->
3534
<includesDependencies>true</includesDependencies>
3635
<language>java</language>
3736
<addedToClasspath>false</addedToClasspath>
@@ -59,8 +58,6 @@
5958
<package>
6059
org.apache.maven.plugins:maven-jlink-plugin:${project.version}:jlink
6160
</package>
62-
<!-- What should be installed?
63-
JRE image in zip/tar format? -->
6461
<install>
6562
org.apache.maven.plugins:maven-install-plugin:2.5.2:install
6663
</install>

maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ private Toolchain getToolchain()
251251

252252
if ( tc == null )
253253
{
254+
// TODO: Check if we should make the type configurable?
254255
tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
255256
}
256257

maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public class JLinkMojo
204204
private ArchiverManager manager;
205205

206206
/**
207-
* The kind of archive we should produce.
207+
* The kind of archive we will produce.
208208
*/
209209
@Parameter( defaultValue = "zip", required = true )
210210
private String archiveType;
@@ -246,7 +246,7 @@ public void execute()
246246

247247
failIfParametersAreNotInTheirValidValueRanges();
248248

249-
deleteOutputDirectoryIfItAlreadyExists();
249+
ifOutputDirectoryExistsDelteIt();
250250

251251
List<Dependency> dependencies = getSession().getCurrentProject().getDependencies();
252252

@@ -284,13 +284,25 @@ public void execute()
284284

285285
File createZipArchiveFromImage = createZipArchiveFromImage( outputDirectory, outputDirectoryImage );
286286

287-
// Set main artifact.
287+
if ( projectHasAlreadySetAnArtifact() )
288+
{
289+
throw new MojoExecutionException( "You have to use a classifier "
290+
+ "to attach supplemental artifacts to the project instead of replacing them." );
291+
}
292+
288293
getProject().getArtifact().setFile( createZipArchiveFromImage );
289-
// artifact.setFile( createZipArchiveFromImage );
290-
// getProject().setFile( createZipArchiveFromImage );
291-
// packaging is something different than type..
292-
// projectHelper.attachArtifact( getProject(), "image", "image", createZipArchiveFromImage );
294+
}
293295

296+
private boolean projectHasAlreadySetAnArtifact()
297+
{
298+
if ( getProject().getArtifact().getFile() != null )
299+
{
300+
return getProject().getArtifact().getFile().isFile();
301+
}
302+
else
303+
{
304+
return false;
305+
}
294306
}
295307

296308
private File createZipArchiveFromImage( File outputDirectory, File outputDirectoryImage )
@@ -396,7 +408,7 @@ private void failIfParametersAreNotInTheirValidValueRanges()
396408
// }
397409
}
398410

399-
private void deleteOutputDirectoryIfItAlreadyExists()
411+
private void ifOutputDirectoryExistsDelteIt()
400412
throws MojoExecutionException
401413
{
402414
if ( outputDirectoryImage.exists() )

0 commit comments

Comments
 (0)