Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions native-maven-plugin/docs/functional/configuration-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ when no explicit configuration is present. The exception is a parameter intentio
let the property win for one run, such as the agent toggle in [§FS-tracing-agent.1](tracing-agent.md#1-agent-enablement) where
`-Dagent=false` disables an agent enabled in the POM. This is the Maven adaptation of
[§root/FS-option-precedence](../../../docs/spec/functional/option-precedence.md#fs-option-precedence-command-line-input-and-durable-configuration-produce-one-option-state).

## 6. Plugin-wide goal skipping

Setting `<skip>true</skip>` in the native Maven plugin's root `<configuration>` must skip every
plugin goal before it resolves dependencies, downloads metadata, generates files, or otherwise
causes a goal-specific side effect. When it is absent or false, each goal retains its existing
specialized skip controls and behavior.
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,23 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
}
]''')
}

// Plugin-level skip prevents add-reachability-metadata side effects. §FS-config-model.6, §E2E-functional-tests.3.2.
void "plugin-level skip prevents reachability metadata download and copy"() {
given:
withSample("native-config-integration")
def pom = file("pom.xml")
pom.text = pom.text.replaceFirst(/(?s)(<id>addMetadataHints<\/id>.*?<configuration>)/,
'$1\n <skip>true</skip>')

when:
mvn '-PaddMetadataHints', 'package'

then:
buildSucceeded
outputContains "Skipping native Maven plugin goal (parameter 'skip' is true)."
outputDoesNotContain "Downloaded GraalVM reachability metadata repository"
!file("target/graalvm-reachability-metadata").exists()
!file("target/classes/META-INF/native-image/org.graalvm.internal/library-with-reflection/1.5/reflect-config.json").exists()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
Expand Down Expand Up @@ -87,7 +86,7 @@
/**
* @author Sebastien Deleuze
*/
public abstract class AbstractNativeMojo extends AbstractMojo {
public abstract class AbstractNativeMojo extends AbstractSkippableMojo {
private static final String GROUP_ID = "org.graalvm.buildtools";
private static final String GRAALVM_REACHABILITY_METADATA_ARTIFACT_ID = "graalvm-reachability-metadata";
private static final String REPOSITORY_FORMAT = "zip";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -71,7 +70,7 @@
import static org.graalvm.buildtools.model.resources.Helper.asNamedValues;
import static org.graalvm.buildtools.model.resources.Helper.asPatternValues;

public abstract class AbstractResourceConfigMojo extends AbstractMojo {
public abstract class AbstractResourceConfigMojo extends AbstractSkippableMojo {

@Parameter(defaultValue = "${project}", readonly = true)
protected MavenProject mavenProject;
Expand Down Expand Up @@ -108,7 +107,7 @@ public abstract class AbstractResourceConfigMojo extends AbstractMojo {
private boolean ignoreExistingResourcesConfig;

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
Set<PatternValue> includes = asPatternValues(resourceIncludedPatterns);
Set<PatternValue> excludes = asPatternValues(resourceExcludedPatterns);
Set<NamedValue> bundles = asNamedValues(resourceBundles);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2026, 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
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.graalvm.buildtools.maven;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;

public abstract class AbstractSkippableMojo extends AbstractMojo {

// A root plugin configuration skips every goal before its goal-specific work begins. §FS-config-model.6.
@Parameter(property = "skip", defaultValue = "false")
private boolean skip;

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping native Maven plugin goal (parameter 'skip' is true).");
return;
}
executeInternal();
}

protected abstract void executeInternal() throws MojoExecutionException, MojoFailureException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class AddReachabilityMetadataMojo extends AbstractNativeMojo {


@Override
public void execute() throws MojoExecutionException, MojoFailureException {
protected void executeInternal() throws MojoExecutionException, MojoFailureException {
configureMetadataRepository();
project.getArtifacts().stream().filter(this::isInScope)
.forEach(dependency -> maybeAddDependencyMetadata(dependency, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
public class DeprecatedNativeBuildMojo extends NativeCompileNoForkMojo {

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
logger.warn("'native:build' goal is deprecated. Use 'native:compile-no-fork' instead.");
super.execute();
super.executeInternal();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ListLibrariesMissingMetadataMojo extends AbstractNativeMojo {
private File reportFile;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
protected void executeInternal() throws MojoExecutionException, MojoFailureException {
if (!isMetadataRepositoryEnabled()) {
throw new MojoExecutionException("GraalVM reachability metadata repository is disabled.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
import org.graalvm.buildtools.maven.config.AbstractMergeAgentFilesMojo;
import org.graalvm.buildtools.maven.config.agent.AgentConfiguration;
Expand All @@ -65,9 +64,6 @@
*/
@Mojo(name = "merge-agent-files", defaultPhase = LifecyclePhase.TEST)
public class MergeAgentFilesMojo extends AbstractMergeAgentFilesMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;

@Parameter(defaultValue = "${project.build.directory}", readonly = true, required = true)
protected String target;

Expand All @@ -82,7 +78,7 @@ public class MergeAgentFilesMojo extends AbstractMergeAgentFilesMojo {
private static final List<String> DEFAULT_DIRS = Arrays.asList("main", "test");

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
// we need this mojo to be executed only once
numberOfExecutions++;
if (numberOfExecutions > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class MetadataCopyMojo extends AbstractMergeAgentFilesMojo {
private MavenSession session;

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
if (agentConfiguration != null && (agentConfiguration.isEnabled() || agentIsEnabledFromCmd())) {
// in direct mode user is fully responsible for agent configuration, and we will not execute anything besides line that user provided
if (agentConfiguration.getDefaultMode().equalsIgnoreCase("direct")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class NativeBuildDynamicAccessMetadataMojo extends AbstractNativeMojo {
private File outputJson;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
protected void executeInternal() throws MojoExecutionException, MojoFailureException {
configureMetadataRepository();
File jsonFile = ((FileSystemRepository) metadataRepository).getRootDirectory().resolve(LIBRARY_AND_FRAMEWORK_LIST).toFile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected List<String> getDependencyScopes() {
}

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
if (skip) {
logger.info("Skipping native-image generation (parameter 'skipNativeBuild' is true).");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected void addInferredDependenciesToClasspath() {
}

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
if (skipTests || skipNativeTests) {
logger.info("Skipping native-image tests (parameter 'skipTests' or 'skipNativeTests' is true).");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class WriteArgsFileMojo extends NativeCompileNoForkMojo {
public static final String PROPERTY_NAME = "graalvm.native-image.args-file";

@Override
public void execute() throws MojoExecutionException {
protected void executeInternal() throws MojoExecutionException {
List<String> args = getBuildArgs();

getLog().debug("Cleaning old native image build args");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,20 @@
package org.graalvm.buildtools.maven.config;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.logging.Logger;
import org.graalvm.buildtools.maven.AbstractSkippableMojo;
import org.graalvm.buildtools.utils.NativeImageConfigurationUtils;

import java.io.File;
import java.nio.file.Path;

import static org.graalvm.buildtools.utils.NativeImageUtils.nativeImageConfigureFileName;

public abstract class AbstractMergeAgentFilesMojo extends AbstractMojo {

public abstract class AbstractMergeAgentFilesMojo extends AbstractSkippableMojo {

@Component
protected Logger logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AbstractNativeImageMojoTest extends Specification {

private static class TestNativeImageMojo extends AbstractNativeImageMojo {
@Override
void execute() {
protected void executeInternal() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AbstractNativeMojoTest extends Specification {
}

@Override
void execute() {
protected void executeInternal() {
}

@Override
Expand Down
Loading