Skip to content

Commit

Permalink
Rework Maven plugin, add excludeConfig option, set useBuildArg to fal…
Browse files Browse the repository at this point in the history
…se 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.
  • Loading branch information
lazar-mitrovic committed Jun 7, 2022
1 parent 4ad8b74 commit fb8edf2
Show file tree
Hide file tree
Showing 9 changed files with 613 additions and 433 deletions.
7 changes: 7 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Expand Up @@ -23,6 +23,13 @@ If you are interested in contributing, please refer to our https://github.com/gr
* Introduced the `metadataCopy` task.
* Introduced the concept of agent modes.
** Under the hood, the agent mode dictates what options are passed to the agent and how metadata produced by multiple runs get merged.
* Added `excludeConfig` configuration option that allows skipping of configuration files that are present in classpath `jar` s.
* `useArgFile` is now set to true by default only on Windows.

==== Maven plugin
* 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.

=== Release 0.9.11

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -126,6 +126,7 @@
import static org.graalvm.buildtools.gradle.internal.GradleUtils.transitiveProjectArtifacts;
import static org.graalvm.buildtools.gradle.internal.NativeImageExecutableLocator.graalvmHomeProvider;
import static org.graalvm.buildtools.utils.SharedConstants.AGENT_PROPERTY;
import static org.graalvm.buildtools.utils.SharedConstants.IS_WINDOWS;

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

logger = GraalVMLogger.of(project.getLogger());
DefaultGraalVmExtension graalExtension = (DefaultGraalVmExtension) registerGraalVMExtension(project);
graalExtension.getUseArgFile().convention(true);
graalExtension.getUseArgFile().convention(IS_WINDOWS);
project.getPlugins()
.withType(JavaPlugin.class, javaPlugin -> configureJavaProject(project, nativeImageServiceProvider, graalExtension));

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -99,7 +99,7 @@ public interface GraalVMExtension {

/**
* Property driving the use of @-arg files when invoking native image.
* This is enabled by default. For older native-image versions, this
* This is enabled by default on Windows. For older native-image versions, this
* needs to be disabled.
*
* @return the argument file property
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -171,14 +171,24 @@ public interface NativeImageOptions extends Named {
Property<JavaLauncher> getJavaLauncher();

/**
* Returns the list of configuration file directories (e.g resource-config.json, ...) which need
* Returns the list of configuration file directories (e.g. resource-config.json, ...) which need
* to be passed to native-image.
*
* @return a collection of directories
*/
@InputFiles
ConfigurableFileCollection getConfigurationFileDirectories();

/**
* Returns the map that as contains information about configuration that should be excluded
* during image building. It consists of a jar regular expression as a key and a resource
* regular expression as a value.
*
* @return a map of filters for configuration exclusion
*/
@Input
MapProperty<String, String> getExcludeConfig();

@Nested
NativeResourcesOptions getResources();

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -104,6 +104,12 @@ public List<String> asArguments() {
NativeImageOptions options = getOptions().get();
List<String> cliArgs = new ArrayList<>(20);

options.getExcludeConfig().get().forEach((jarPath, resourcePattern) -> {
cliArgs.add("--exclude-config");
cliArgs.add(jarPath);
cliArgs.add(resourcePattern);
});

cliArgs.add("-cp");
String classpathString = buildClasspathString(options);
cliArgs.add(classpathString);
Expand Down

0 comments on commit fb8edf2

Please sign in to comment.