You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by bm...@apache.org on 2020/12/14 20:33:01 UTC

[maven-jlink-plugin] branch MJLINK-52 created (now 209282f)

This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a change to branch MJLINK-52
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git.


      at 209282f  [MJLINK-52] Add classifier support

This branch includes the following new commits:

     new 209282f  [MJLINK-52] Add classifier support

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-jlink-plugin] 01/01: [MJLINK-52] Add classifier support

Posted by bm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch MJLINK-52
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git

commit 209282f5bd1f6aef07d08fece1e6a100d0503c7c
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Thu Nov 26 07:12:00 2020 +0100

    [MJLINK-52] Add classifier support
    
    Signed-off-by: Benjamin Marwell <bm...@apache.org>
---
 .../MJLINK-52_classifiers/invoker.properties       | 18 +++++
 src/it/projects/MJLINK-52_classifiers/pom.xml      | 54 ++++++++++++++
 .../src/main/java/com/corporate/project/Main.java  | 35 +++++++++
 .../src/main/java/module-info.java                 | 24 ++++++
 .../projects/MJLINK-52_classifiers/verify.groovy   | 48 ++++++++++++
 .../invoker.properties                             | 18 +++++
 .../pom.xml                                        | 71 ++++++++++++++++++
 .../src/main/java/com/corporate/project/Main.java  | 35 +++++++++
 .../src/main/java/module-info.java                 | 24 ++++++
 .../verify.groovy                                  | 47 ++++++++++++
 .../invoker.properties                             | 19 +++++
 .../pom.xml                                        | 64 ++++++++++++++++
 .../src/main/java/com/corporate/project/Main.java  | 35 +++++++++
 .../src/main/java/module-info.java                 | 24 ++++++
 .../verify.groovy                                  | 47 ++++++++++++
 .../invoker.properties                             | 18 +++++
 .../MJLINK-52_classifiers_jarproject/pom.xml       | 63 ++++++++++++++++
 .../src/main/java/com/corporate/project/Main.java  | 35 +++++++++
 .../src/main/java/module-info.java                 | 24 ++++++
 .../MJLINK-52_classifiers_jarproject/verify.groovy | 55 ++++++++++++++
 .../maven/plugins/jlink/AbstractJLinkMojo.java     |  8 +-
 .../org/apache/maven/plugins/jlink/JLinkMojo.java  | 85 ++++++++++++++++++++--
 22 files changed, 842 insertions(+), 9 deletions(-)

diff --git a/src/it/projects/MJLINK-52_classifiers/invoker.properties b/src/it/projects/MJLINK-52_classifiers/invoker.properties
new file mode 100644
index 0000000..8948d9b
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers/invoker.properties
@@ -0,0 +1,18 @@
+# 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.java.version = 1.9+
+invoker.goals = clean package
diff --git a/src/it/projects/MJLINK-52_classifiers/pom.xml b/src/it/projects/MJLINK-52_classifiers/pom.xml
new file mode 100644
index 0000000..1b1ea17
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers/pom.xml
@@ -0,0 +1,54 @@
+<?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-mjlink-52</artifactId>
+  <version>96.0</version>
+  <packaging>jlink</packaging>
+  <name>Maven</name>
+  <url>https://maven.apache.org</url>
+  <description>Test JLink creates archives with classifiers.</description>
+  <properties>
+    <maven.compiler.release>9</maven.compiler.release>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <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>
+        <configuration>
+          <classifier>jlink</classifier>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/MJLINK-52_classifiers/src/main/java/com/corporate/project/Main.java b/src/it/projects/MJLINK-52_classifiers/src/main/java/com/corporate/project/Main.java
new file mode 100644
index 0000000..1b4ca36
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers/src/main/java/com/corporate/project/Main.java
@@ -0,0 +1,35 @@
+package com.corporate.project;
+
+/*
+ * 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.
+ */
+
+public class Main
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Main one from Java 9+" );
+        if ( args.length > 0 )
+        {
+            for ( String arg : args )
+            {
+                System.out.println( " Arg: '" + arg + "'" );
+            }
+        }
+    }
+}
diff --git a/src/it/projects/MJLINK-52_classifiers/src/main/java/module-info.java b/src/it/projects/MJLINK-52_classifiers/src/main/java/module-info.java
new file mode 100644
index 0000000..d35441d
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+module com.corporate.project {
+  requires java.base;
+  exports com.corporate.project;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers/verify.groovy b/src/it/projects/MJLINK-52_classifiers/verify.groovy
new file mode 100644
index 0000000..8975fe5
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers/verify.groovy
@@ -0,0 +1,48 @@
+
+/*
+ * 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
+    }
+
+    File artifact = new File( target, "maven-jlink-plugin-mjlink-52-96.0-jlink.zip" )
+    if ( !artifact.exists() || artifact.isDirectory() )
+    {
+        System.err.println( "maven-jlink-plugin-mjlink-52-96.0-jlink.zip file is missing or is a directory." )
+        return false
+    }
+
+    return true
+}
+catch( Throwable e )
+{
+    e.printStackTrace()
+    return false
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/invoker.properties b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/invoker.properties
new file mode 100644
index 0000000..8948d9b
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/invoker.properties
@@ -0,0 +1,18 @@
+# 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.java.version = 1.9+
+invoker.goals = clean package
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/pom.xml b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/pom.xml
new file mode 100644
index 0000000..2ccb413
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/pom.xml
@@ -0,0 +1,71 @@
+<?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-mjlink-52</artifactId>
+  <version>96.0</version>
+  <packaging>jar</packaging>
+  <name>Maven</name>
+  <url>https://maven.apache.org</url>
+  <description>Test JLink does not fail on duplicate classifiers.</description>
+  <properties>
+    <maven.compiler.release>9</maven.compiler.release>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <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>
+        <executions>
+          <execution>
+            <id>primary-jlink</id>
+            <goals>
+              <goal>jlink</goal>
+            </goals>
+            <configuration>
+              <classifier>jlink1</classifier>
+            </configuration>
+          </execution>
+          <execution>
+            <id>secondary-jlink</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jlink</goal>
+            </goals>
+            <configuration>
+              <classifier>jlink1</classifier>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/com/corporate/project/Main.java b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/com/corporate/project/Main.java
new file mode 100644
index 0000000..1b4ca36
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/com/corporate/project/Main.java
@@ -0,0 +1,35 @@
+package com.corporate.project;
+
+/*
+ * 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.
+ */
+
+public class Main
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Main one from Java 9+" );
+        if ( args.length > 0 )
+        {
+            for ( String arg : args )
+            {
+                System.out.println( " Arg: '" + arg + "'" );
+            }
+        }
+    }
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/module-info.java b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/module-info.java
new file mode 100644
index 0000000..d35441d
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+module com.corporate.project {
+  requires java.base;
+  exports com.corporate.project;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/verify.groovy b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/verify.groovy
new file mode 100644
index 0000000..9cfed2d
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_classifier/verify.groovy
@@ -0,0 +1,47 @@
+
+/*
+ * 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;
+    }
+    File artifact = new File( target, "maven-jlink-plugin-mjlink-52-96.0-jlink1.zip" );
+    if ( !artifact.exists() || artifact.isDirectory() )
+    {
+        System.err.println( "maven-jlink-plugin-mjlink-52-96.0-jlink1.zip file is missing or is a directory." );
+        return false;
+    }
+
+    return true;
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    return false;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_default/invoker.properties b/src/it/projects/MJLINK-52_classifiers_duplicate_default/invoker.properties
new file mode 100644
index 0000000..594aefa
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_default/invoker.properties
@@ -0,0 +1,19 @@
+# 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.java.version = 1.9+
+invoker.goals = clean package
+invoker.buildResult = failure
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_default/pom.xml b/src/it/projects/MJLINK-52_classifiers_duplicate_default/pom.xml
new file mode 100644
index 0000000..e739b8f
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_default/pom.xml
@@ -0,0 +1,64 @@
+<?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-mjlink-52</artifactId>
+  <version>96.0</version>
+  <packaging>jlink</packaging>
+  <name>Maven</name>
+  <url>https://maven.apache.org</url>
+  <description>Test JLink fails on duplicate default artifact.</description>
+  <properties>
+    <maven.compiler.release>9</maven.compiler.release>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <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>
+          <execution>
+            <id>default-jlink</id>
+          </execution>
+          <execution>
+            <!-- this execution must fail because a default artifact may not be attached twice. -->
+            <id>secondary-jlink</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jlink</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/com/corporate/project/Main.java b/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/com/corporate/project/Main.java
new file mode 100644
index 0000000..1b4ca36
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/com/corporate/project/Main.java
@@ -0,0 +1,35 @@
+package com.corporate.project;
+
+/*
+ * 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.
+ */
+
+public class Main
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Main one from Java 9+" );
+        if ( args.length > 0 )
+        {
+            for ( String arg : args )
+            {
+                System.out.println( " Arg: '" + arg + "'" );
+            }
+        }
+    }
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/module-info.java b/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/module-info.java
new file mode 100644
index 0000000..d35441d
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_default/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+module com.corporate.project {
+  requires java.base;
+  exports com.corporate.project;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_duplicate_default/verify.groovy b/src/it/projects/MJLINK-52_classifiers_duplicate_default/verify.groovy
new file mode 100644
index 0000000..77f05f8
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_duplicate_default/verify.groovy
@@ -0,0 +1,47 @@
+
+/*
+ * 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;
+    }
+    File artifact = new File( target, "maven-jlink-plugin-mjlink-52-96.0.zip" );
+    if ( !artifact.exists() || artifact.isDirectory() )
+    {
+        System.err.println( "maven-jlink-plugin-mjlink-52-96.0.zip file is missing or is a directory." );
+        return false;
+    }
+
+    return true;
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    return false;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_jarproject/invoker.properties b/src/it/projects/MJLINK-52_classifiers_jarproject/invoker.properties
new file mode 100644
index 0000000..8948d9b
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_jarproject/invoker.properties
@@ -0,0 +1,18 @@
+# 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.java.version = 1.9+
+invoker.goals = clean package
diff --git a/src/it/projects/MJLINK-52_classifiers_jarproject/pom.xml b/src/it/projects/MJLINK-52_classifiers_jarproject/pom.xml
new file mode 100644
index 0000000..4858354
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_jarproject/pom.xml
@@ -0,0 +1,63 @@
+<?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-mjlink-52</artifactId>
+  <version>96.0</version>
+  <packaging>jar</packaging>
+  <name>Maven</name>
+  <url>https://maven.apache.org</url>
+  <description>Test JLink creates an additional archive with classifiers on a jar-packaged project.</description>
+  <properties>
+    <maven.compiler.release>9</maven.compiler.release>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <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>
+          <execution>
+            <id>create-dist</id>
+            <phase>package</phase>
+            <goals>
+              <goal>jlink</goal>
+            </goals>
+            <configuration>
+              <classifier>jlink</classifier>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/com/corporate/project/Main.java b/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/com/corporate/project/Main.java
new file mode 100644
index 0000000..1b4ca36
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/com/corporate/project/Main.java
@@ -0,0 +1,35 @@
+package com.corporate.project;
+
+/*
+ * 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.
+ */
+
+public class Main
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Main one from Java 9+" );
+        if ( args.length > 0 )
+        {
+            for ( String arg : args )
+            {
+                System.out.println( " Arg: '" + arg + "'" );
+            }
+        }
+    }
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/module-info.java b/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/module-info.java
new file mode 100644
index 0000000..d35441d
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_jarproject/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+module com.corporate.project {
+  requires java.base;
+  exports com.corporate.project;
+}
diff --git a/src/it/projects/MJLINK-52_classifiers_jarproject/verify.groovy b/src/it/projects/MJLINK-52_classifiers_jarproject/verify.groovy
new file mode 100644
index 0000000..1f45c22
--- /dev/null
+++ b/src/it/projects/MJLINK-52_classifiers_jarproject/verify.groovy
@@ -0,0 +1,55 @@
+
+/*
+ * 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
+    }
+
+    File primaryArtifact = new File( target, "maven-jlink-plugin-mjlink-52-96.0.jar" )
+    if ( !primaryArtifact.exists() || primaryArtifact.isDirectory() )
+    {
+        System.err.println( "maven-jlink-plugin-mjlink-52-96.0.jar file is missing or is a directory." )
+        return false
+    }
+
+    File jlinkArtifact = new File( target, "maven-jlink-plugin-mjlink-52-96.0-jlink.zip" )
+    if ( !jlinkArtifact.exists() || jlinkArtifact.isDirectory() )
+    {
+        System.err.println( "maven-jlink-plugin-mjlink-52-96.0-jlink.zip file is missing or is a directory." )
+        return false
+    }
+
+    return true
+}
+catch( Throwable e )
+{
+    e.printStackTrace()
+    return false
+}
diff --git a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
index 74bef13..16542a0 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
@@ -59,6 +59,12 @@ public abstract class AbstractJLinkMojo
     @Component
     private ToolchainManager toolchainManager;
 
+    /**
+     * Overload this to produce a zip with another classifier, for example a jlink-zip.
+     * @return get the classifier.
+     */
+    protected abstract String getClassifier();
+
     protected JLinkExecutor getJlinkExecutor()
     {
         return new JLinkExecutor( getToolchain().orElse( null ), getLog() );
@@ -167,7 +173,7 @@ public abstract class AbstractJLinkMojo
     protected boolean hasClassifier( String classifier )
     {
         boolean result = false;
-        if ( classifier != null && classifier.trim().length() > 0 )
+        if ( classifier != null && !classifier.isEmpty() )
         {
             result = true;
         }
diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
index 3e7a63a..f8ff013 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -41,6 +41,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.java.DefaultJavaToolChain;
 import org.codehaus.plexus.archiver.Archiver;
@@ -151,8 +152,11 @@ public class JLinkMojo
     /**
      * The output directory for the resulting Run Time Image. The created Run Time Image is stored in non compressed
      * form. This will later being packaged into a <code>zip</code> file. <code>--output &lt;path&gt;</code>
+     *
+     * <p>The {@link #classifier} is appended as a subdirecty if it exists,
+     * otherwise {@code default} will be used as subdirectory.
+     * This ensures that multiple executions using classifiers will not overwrite the previous run’s image.</p>
      */
-    // TODO: is this a good final location?
     @Parameter( defaultValue = "${project.build.directory}/maven-jlink", required = true, readonly = true )
     private File outputDirectoryImage;
 
@@ -266,17 +270,34 @@ public class JLinkMojo
     private File sourceJdkModules;
 
     /**
+     * Classifier to add to the artifact generated. If given, the artifact will be attached
+     * as a supplemental artifact.
+     * If not given this will create the main artifact which is the default behavior.
+     * If you try to do that a second time without using a classifier the build will fail.
+     */
+    @Parameter
+    private String classifier;
+
+    /**
      * Name of the generated ZIP file in the <code>target</code> directory. This will not change the name of the
      * installed/deployed file.
      */
     @Parameter( defaultValue = "${project.build.finalName}", readonly = true )
     private String finalName;
 
+    /**
+     * Convenience interface for plugins to add or replace artifacts and resources on projects.
+     */
+    @Component
+    private MavenProjectHelper projectHelper;
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException
     {
         failIfParametersAreNotInTheirValidValueRanges();
 
+        setOutputDirectoryImage();
+
         ifOutputDirectoryExistsDelteIt();
 
         JLinkExecutor jLinkExec = getExecutor();
@@ -321,13 +342,19 @@ public class JLinkMojo
 
         File createZipArchiveFromImage = createZipArchiveFromImage( buildDirectory, outputDirectoryImage );
 
-        if ( projectHasAlreadySetAnArtifact() )
+        if ( hasClassifier() )
         {
-            throw new MojoExecutionException( "You have to use a classifier "
-                            + "to attach supplemental artifacts to the project instead of replacing them." );
+            projectHelper.attachArtifact( getProject(), "jlink", getClassifier(), createZipArchiveFromImage );
+        }
+        else
+        {
+            if ( projectHasAlreadySetAnArtifact() )
+            {
+                throw new MojoExecutionException( "You have to use a classifier "
+                        + "to attach supplemental artifacts to the project instead of replacing them." );
+            }
+            getProject().getArtifact().setFile( createZipArchiveFromImage );
         }
-
-        getProject().getArtifact().setFile( createZipArchiveFromImage );
     }
 
     private List<File> getCompileClasspathElements( MavenProject project )
@@ -428,7 +455,7 @@ public class JLinkMojo
         return getJlinkExecutor();
     }
 
-    private boolean projectHasAlreadySetAnArtifact()
+    private boolean projectHasAlreadySetAnArtifact( )
     {
         if ( getProject().getArtifact().getFile() != null )
         {
@@ -440,12 +467,26 @@ public class JLinkMojo
         }
     }
 
+    /**
+     * @return true in case where the classifier is not {@code null} and contains something else than white spaces.
+     */
+    protected boolean hasClassifier()
+    {
+        boolean result = false;
+        if ( getClassifier() != null && !getClassifier().isEmpty() )
+        {
+            result = true;
+        }
+
+        return result;
+    }
+
     private File createZipArchiveFromImage( File outputDirectory, File outputDirectoryImage )
         throws MojoExecutionException
     {
         zipArchiver.addDirectory( outputDirectoryImage );
 
-        File resultArchive = getArchiveFile( outputDirectory, finalName, null, "zip" );
+        File resultArchive = getArchiveFile( outputDirectory, finalName, getClassifier(), "zip" );
 
         zipArchiver.setDestFile( resultArchive );
         try
@@ -486,6 +527,25 @@ public class JLinkMojo
         }
     }
 
+    /**
+     * Use a separate directory for each image.
+     *
+     * <p>Rationale: If a user creates multiple jlink artifacts using classifiers,
+     * the directories should not overwrite themselves for each execution.</p>
+     */
+    private void setOutputDirectoryImage()
+    {
+        if ( hasClassifier() )
+        {
+            final File classifiersDirectory = new File( outputDirectoryImage, "classifiers" );
+            outputDirectoryImage = new File( classifiersDirectory, classifier );
+        }
+        else
+        {
+            outputDirectoryImage = new File( outputDirectoryImage, "default" );
+        }
+    }
+
     private void ifOutputDirectoryExistsDelteIt()
         throws MojoExecutionException
     {
@@ -633,4 +693,13 @@ public class JLinkMojo
     {
         return limitModules != null && !limitModules.isEmpty();
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected String getClassifier()
+    {
+        return classifier;
+    }
+
 }