diff --git a/pom.xml b/pom.xml index de065112..4977486d 100644 --- a/pom.xml +++ b/pom.xml @@ -291,6 +291,71 @@ + + exclude-tests-openj9-compiler + + + openj9.compiler + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + cli-options/generate-cds-archive/pom.xml + + + + + + + + exclude-tests-eclipse-openj9 + + + java.vm.vendor + Eclipse OpenJ9 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + cli-options/generate-cds-archive/pom.xml + + + + + + + + exclude-tests-ibm + + + java.vendor + IBM Corporation + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + cli-options/generate-cds-archive/pom.xml + + + + + + diff --git a/src/it/projects/cli-options/additional-args/invoker.properties b/src/it/projects/cli-options/additional-args/invoker.properties new file mode 100644 index 00000000..9ef49673 --- /dev/null +++ b/src/it/projects/cli-options/additional-args/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 package diff --git a/src/it/projects/cli-options/additional-args/pom.xml b/src/it/projects/cli-options/additional-args/pom.xml new file mode 100644 index 00000000..4dd5e825 --- /dev/null +++ b/src/it/projects/cli-options/additional-args/pom.xml @@ -0,0 +1,69 @@ + + + + + 4.0.0 + org.apache.maven.plugins + maven-jlink-plugin-cli-options-additional-args + 99.0 + jlink + Maven + http://maven.apache.org + Test JLink CLI Options additional args. + + 1.9 + 1.9 + UTF-8 + + + + localhost + first-jar-module-info + 99.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 1.9 + 1.9 + + + + org.apache.maven.plugins + maven-jlink-plugin + @project.version@ + true + + + + --strip-native-commands + + + + + + diff --git a/src/it/projects/cli-options/additional-args/src/main/configs/config.test b/src/it/projects/cli-options/additional-args/src/main/configs/config.test new file mode 100644 index 00000000..32f52ebe --- /dev/null +++ b/src/it/projects/cli-options/additional-args/src/main/configs/config.test @@ -0,0 +1,21 @@ +/* + * 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. + */ + +Test configuration file which should be located in config/config.test in +resulting jmod file. diff --git a/src/it/projects/cli-options/additional-args/verify.groovy b/src/it/projects/cli-options/additional-args/verify.groovy new file mode 100644 index 00000000..a39c614a --- /dev/null +++ b/src/it/projects/cli-options/additional-args/verify.groovy @@ -0,0 +1,45 @@ +/* + * 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.*; + +boolean result = true; + +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-cli-options-additional-args-99.0.zip"); + if (!artifact.exists() || artifact.isDirectory()) { + System.err.println("maven-jlink-plugin-cli-options-additional-args-99.0.zip file is missing or is a directory."); + return false; + } + +} +catch (Throwable e) { + e.printStackTrace(); + result = false; +} + +return result; diff --git a/src/it/projects/cli-options/generate-cds-archive/invoker.properties b/src/it/projects/cli-options/generate-cds-archive/invoker.properties new file mode 100644 index 00000000..67549840 --- /dev/null +++ b/src/it/projects/cli-options/generate-cds-archive/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.goals=clean package +invoker.java.version=17+ diff --git a/src/it/projects/cli-options/generate-cds-archive/pom.xml b/src/it/projects/cli-options/generate-cds-archive/pom.xml new file mode 100644 index 00000000..f0be75fc --- /dev/null +++ b/src/it/projects/cli-options/generate-cds-archive/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + org.apache.maven.plugins + maven-jlink-plugin-cli-options-generate-cds-archive + 99.0 + jlink + Maven + http://maven.apache.org + Test JLink CLI Options --generate-cds-archive. + + 17 + 17 + UTF-8 + + + + localhost + first-jar-module-info + 99.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 17 + 17 + + + + org.apache.maven.plugins + maven-jlink-plugin + @project.version@ + true + + true + + + + + diff --git a/src/it/projects/cli-options/generate-cds-archive/src/main/configs/config.test b/src/it/projects/cli-options/generate-cds-archive/src/main/configs/config.test new file mode 100644 index 00000000..32f52ebe --- /dev/null +++ b/src/it/projects/cli-options/generate-cds-archive/src/main/configs/config.test @@ -0,0 +1,21 @@ +/* + * 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. + */ + +Test configuration file which should be located in config/config.test in +resulting jmod file. diff --git a/src/it/projects/cli-options/generate-cds-archive/verify.groovy b/src/it/projects/cli-options/generate-cds-archive/verify.groovy new file mode 100644 index 00000000..516b4cb4 --- /dev/null +++ b/src/it/projects/cli-options/generate-cds-archive/verify.groovy @@ -0,0 +1,45 @@ +/* + * 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.*; + +boolean result = true; + +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-cli-options-generate-cds-archive-99.0.zip"); + if (!artifact.exists() || artifact.isDirectory()) { + System.err.println("maven-jlink-plugin-cli-options-generate-cds-archive-99.0.zip file is missing or is a directory."); + return false; + } + +} +catch (Throwable e) { + e.printStackTrace(); + result = false; +} + +return result; diff --git a/src/it/projects/cli-options/order-resources/invoker.properties b/src/it/projects/cli-options/order-resources/invoker.properties new file mode 100644 index 00000000..9ef49673 --- /dev/null +++ b/src/it/projects/cli-options/order-resources/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 package diff --git a/src/it/projects/cli-options/order-resources/pom.xml b/src/it/projects/cli-options/order-resources/pom.xml new file mode 100644 index 00000000..1527e0da --- /dev/null +++ b/src/it/projects/cli-options/order-resources/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + org.apache.maven.plugins + maven-jlink-plugin-cli-options-order-resources + 99.0 + jlink + Maven + http://maven.apache.org + Test JLink CLI Options --order-resources. + + 1.9 + 1.9 + UTF-8 + + + + localhost + first-jar-module-info + 99.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 1.9 + 1.9 + + + + org.apache.maven.plugins + maven-jlink-plugin + @project.version@ + true + + + module-info.class + + + + + + diff --git a/src/it/projects/cli-options/order-resources/src/main/configs/config.test b/src/it/projects/cli-options/order-resources/src/main/configs/config.test new file mode 100644 index 00000000..32f52ebe --- /dev/null +++ b/src/it/projects/cli-options/order-resources/src/main/configs/config.test @@ -0,0 +1,21 @@ +/* + * 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. + */ + +Test configuration file which should be located in config/config.test in +resulting jmod file. diff --git a/src/it/projects/cli-options/order-resources/src/main/java/module-info.java b/src/it/projects/cli-options/order-resources/src/main/java/module-info.java new file mode 100644 index 00000000..204bb76d --- /dev/null +++ b/src/it/projects/cli-options/order-resources/src/main/java/module-info.java @@ -0,0 +1,21 @@ +/* +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 test { + +} \ No newline at end of file diff --git a/src/it/projects/cli-options/order-resources/verify.groovy b/src/it/projects/cli-options/order-resources/verify.groovy new file mode 100644 index 00000000..5cf769f1 --- /dev/null +++ b/src/it/projects/cli-options/order-resources/verify.groovy @@ -0,0 +1,45 @@ +/* + * 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.*; + +boolean result = true; + +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-cli-options-order-resources-99.0.zip"); + if (!artifact.exists() || artifact.isDirectory()) { + System.err.println("maven-jlink-plugin-cli-options-order-resources-99.0.zip file is missing or is a directory."); + return false; + } + +} +catch (Throwable e) { + e.printStackTrace(); + result = false; +} + +return result; 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 be4d37a0..a8c98eb7 100644 --- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java +++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java @@ -322,6 +322,20 @@ public class JLinkMojo extends AbstractJLinkMojo { @Parameter private List includeLocales; + /** + * This will generate a CDS archive if the runtime image supports it. + * The JLink command line equivalent is: --generate-cds-archive + */ + @Parameter(defaultValue = "false") + private boolean generateCdsArchive; + + /** + * This will order the specified paths in priority order. + * The JLink command line equivalent is: --order-resources <path>[,<path>...] + */ + @Parameter + private List orderResources; + /** * This will turn on verbose mode. The jlink command line equivalent is: --verbose */ @@ -381,6 +395,12 @@ public class JLinkMojo extends AbstractJLinkMojo { @Parameter(defaultValue = "") private String zipDirPrefix; + /** + * These arguments are additionally passed to the jlink command line. + */ + @Parameter + private List additionalArgs; + /** * Convenience interface for plugins to add or replace artifacts and resources on projects. */ @@ -774,6 +794,15 @@ protected List createJlinkArgs(Collection pathsOfModules, Collec jlinkArgs.add(sb); } + if (generateCdsArchive) { + jlinkArgs.add("--generate-cds-archive"); + } + + if (orderResources != null && !orderResources.isEmpty()) { + String sb = String.join(",", orderResources); + jlinkArgs.add("--order-resources=" + sb); + } + if (pluginModulePath != null) { jlinkArgs.add("--plugin-module-path"); StringBuilder sb = convertSeparatedModulePathToPlatformSeparatedModulePath(pluginModulePath); @@ -789,6 +818,10 @@ protected List createJlinkArgs(Collection pathsOfModules, Collec jlinkArgs.add("--verbose"); } + if (additionalArgs != null && !additionalArgs.isEmpty()) { + jlinkArgs.addAll(additionalArgs); + } + // NOTE: suggestProviders is a terminal JlinkTask, so must be at the end! if (hasSuggestProviders()) { jlinkArgs.add("--suggest-providers");