Skip to content

Commit 1a90901

Browse files
Rework Maven plugin, add excludeConfig option, set useBuildArg to false on nix systems.
- Completely reworked Maven plugin (should fix many of previous issues and inconsistencies between main and test builds). - Added `classesDirectory`, `debug`, `fallback`, `verbose`, `sharedLibrary`, `configurationFileDirectories`, `excludeConfig` and `jvmArgs` properties in order to match those present in the Gradle plugin. - `useArgFile` is now set to true by default only on Windows - Added `excludeConfig` configuration option that allows skipping of configuration files that are present in classpath `jar` s.
1 parent 4ad8b74 commit 1a90901

File tree

13 files changed

+646
-453
lines changed

13 files changed

+646
-453
lines changed

docs/src/docs/asciidoc/index.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ If you are interested in contributing, please refer to our https://github.com/gr
2323
* Introduced the `metadataCopy` task.
2424
* Introduced the concept of agent modes.
2525
** Under the hood, the agent mode dictates what options are passed to the agent and how metadata produced by multiple runs get merged.
26+
* Added `excludeConfig` configuration option that allows skipping of configuration files that are present in classpath `jar` s.
27+
* `useArgFile` is now set to true by default only on Windows.
28+
29+
==== Maven plugin
30+
* Completely reworked Maven plugin (should fix many of previous issues and inconsistencies between main and test builds).
31+
* Added `classesDirectory`, `debug`, `fallback`, `verbose`, `sharedLibrary`, `configurationFileDirectories`, `excludeConfig` and `jvmArgs` properties in order to match those present in the Gradle plugin.
32+
* `useArgFile` is now set to true by default only on Windows.
2633

2734
=== Release 0.9.11
2835

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -126,6 +126,7 @@
126126
import static org.graalvm.buildtools.gradle.internal.GradleUtils.transitiveProjectArtifacts;
127127
import static org.graalvm.buildtools.gradle.internal.NativeImageExecutableLocator.graalvmHomeProvider;
128128
import static org.graalvm.buildtools.utils.SharedConstants.AGENT_PROPERTY;
129+
import static org.graalvm.buildtools.utils.SharedConstants.IS_WINDOWS;
129130

130131
/**
131132
* Gradle plugin for GraalVM Native Image.
@@ -170,7 +171,7 @@ public void apply(Project project) {
170171

171172
logger = GraalVMLogger.of(project.getLogger());
172173
DefaultGraalVmExtension graalExtension = (DefaultGraalVmExtension) registerGraalVMExtension(project);
173-
graalExtension.getUseArgFile().convention(true);
174+
graalExtension.getUseArgFile().convention(IS_WINDOWS);
174175
project.getPlugins()
175176
.withType(JavaPlugin.class, javaPlugin -> configureJavaProject(project, nativeImageServiceProvider, graalExtension));
176177

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/dsl/GraalVMExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -99,7 +99,7 @@ public interface GraalVMExtension {
9999

100100
/**
101101
* Property driving the use of @-arg files when invoking native image.
102-
* This is enabled by default. For older native-image versions, this
102+
* This is enabled by default on Windows. For older native-image versions, this
103103
* needs to be disabled.
104104
*
105105
* @return the argument file property

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/dsl/NativeImageOptions.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -171,14 +171,24 @@ public interface NativeImageOptions extends Named {
171171
Property<JavaLauncher> getJavaLauncher();
172172

173173
/**
174-
* Returns the list of configuration file directories (e.g resource-config.json, ...) which need
174+
* Returns the list of configuration file directories (e.g. resource-config.json, ...) which need
175175
* to be passed to native-image.
176176
*
177177
* @return a collection of directories
178178
*/
179179
@InputFiles
180180
ConfigurableFileCollection getConfigurationFileDirectories();
181181

182+
/**
183+
* Returns the map that as contains information about configuration that should be excluded
184+
* during image building. It consists of a jar regular expression as a key and a resource
185+
* regular expression as a value.
186+
*
187+
* @return a map of filters for configuration exclusion
188+
*/
189+
@Input
190+
MapProperty<String, String> getExcludeConfig();
191+
182192
@Nested
183193
NativeResourcesOptions getResources();
184194

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/internal/NativeImageCommandLineProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -104,6 +104,12 @@ public List<String> asArguments() {
104104
NativeImageOptions options = getOptions().get();
105105
List<String> cliArgs = new ArrayList<>(20);
106106

107+
options.getExcludeConfig().get().forEach((jarPath, resourcePattern) -> {
108+
cliArgs.add("--exclude-config");
109+
cliArgs.add(jarPath);
110+
cliArgs.add(resourcePattern);
111+
});
112+
107113
cliArgs.add("-cp");
108114
String classpathString = buildClasspathString(options);
109115
cliArgs.add(classpathString);

native-maven-plugin/build-plugins/src/main/java/org/graalvm/build/maven/MavenTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected void executeMaven() {
8888
File projectdir = getProjectDirectory().getAsFile().get();
8989
getExecOperations().javaexec(spec -> {
9090
spec.setClasspath(getMavenEmbedderClasspath());
91-
spec.setMain("org.apache.maven.cli.MavenCli");
91+
spec.getMainClass().set("org.apache.maven.cli.MavenCli");
9292
spec.systemProperty("maven.multiModuleProjectDirectory", projectdir.getAbsolutePath());
9393
prepareSpec(spec);
9494
List<String> arguments = new ArrayList<>();

native-maven-plugin/build-plugins/src/main/kotlin/org.graalvm.build.maven-functional-testing.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import org.graalvm.build.maven.MavenTask
2-
import org.gradle.util.GFileUtils
3-
41
/*
52
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
63
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
6464

6565
then:
6666
buildSucceeded
67-
outputContains "JVM reachability metadata repository is enabled, but no repository has been configured"
67+
outputContains "GraalVM reachability metadata repository is enabled, but no repository has been configured"
6868
outputContains "Reflection failed"
6969
}
7070

@@ -77,8 +77,8 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
7777

7878
then:
7979
buildSucceeded
80-
outputContains "The official JVM reachability metadata repository is not released yet. Only local repositories are supported"
81-
outputContains "JVM reachability metadata repository is enabled, but no repository has been configured"
80+
outputContains "The official GraalVM reachability metadata repository is not released yet. Only local repositories are supported"
81+
outputContains "GraalVM reachability metadata repository is enabled, but no repository has been configured"
8282
outputContains "Reflection failed"
8383
}
8484

@@ -94,10 +94,10 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
9494
outputContains "Hello, from reflection!"
9595

9696
and: "it doesn't find a configuration directory for the current version"
97-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
97+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
9898

9999
and: "but it finds one thanks to the latest configuration field"
100-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
100+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
101101
}
102102

103103
void "if the path doesn't exist it throws an error"() {
@@ -109,7 +109,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
109109

110110
then:
111111
buildSucceeded
112-
outputContains "JVM reachability metadata repository path does not exist"
112+
outputContains "GraalVM reachability metadata repository path does not exist"
113113
outputContains "Reflection failed"
114114
}
115115

@@ -134,7 +134,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
134134

135135
then:
136136
buildSucceeded
137-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration is forced to version 2"
137+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration is forced to version 2"
138138
outputContains "Reflection failed"
139139
}
140140

@@ -150,10 +150,10 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
150150
outputContains "Hello, from reflection!"
151151

152152
and: "it doesn't find a configuration directory for the current version"
153-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
153+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
154154

155155
and: "but it finds one thanks to the latest configuration field"
156-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
156+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
157157
}
158158

159159
void "it can download a remote repository"() {
@@ -170,10 +170,10 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
170170
outputContains "Downloaded GraalVM reachability metadata repository from http://localhost:${localServerPort}/target/repo.zip"
171171

172172
and: "it doesn't find a configuration directory for the current version"
173-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
173+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory not found. Trying latest version."
174174

175175
and: "but it finds one thanks to the latest configuration field"
176-
outputContains "[jvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
176+
outputContains "[graalvm reachability metadata repository for org.graalvm.internal:library-with-reflection:1.5]: Configuration directory is org/graalvm/internal/library-with-reflection/1"
177177
}
178178

179179
void "when pointing to a missing URL, reflection fails"() {

0 commit comments

Comments
 (0)