This is an automated email from the ASF dual-hosted git repository. sdedic pushed a commit to branch vsnetbeans_1603 in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/vsnetbeans_1603 by this push: new 133d0586ab9 React on both build and compile goals. 133d0586ab9 is described below commit 133d0586ab94958d506f81087a98b81d0ccee533 Author: Svata Dedic <svatopluk.de...@oracle.com> AuthorDate: Tue Jan 31 13:57:42 2023 +0100 React on both build and compile goals. --- .../micronaut/maven/MicronautMavenConstants.java | 10 ++++-- .../maven/MicronautPackagingArtifactsImpl.java | 37 ++++++++++++++++------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautMavenConstants.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautMavenConstants.java index bc93993b3c0..823347e2b53 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautMavenConstants.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautMavenConstants.java @@ -52,9 +52,15 @@ public final class MicronautMavenConstants { public static final String CLASSIFIER_NATIVE = "native-image"; /** - * Native image plugin's goal to compile image without fork. + * Native image plugin's goal to compile image without fork. Available from + * 0.9.14 version, DOES NOT exist on earlier versions. */ - public static final String PLUGIN_GOAL_COMPILE_NOFORK = "build"; + public static final String PLUGIN_GOAL_COMPILE_NOFORK = "compile-no-fork"; + + /** + * Now deprecated goal, which produces a warning starting from 0.9.14 . + */ + public static final String PLUGIN_GOAL_COMPILE_NOFORK_OLD = "build"; /** * Native image plugin's goal to compile image from commandline diff --git a/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautPackagingArtifactsImpl.java b/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautPackagingArtifactsImpl.java index 4f28b7f07a9..f4889716013 100644 --- a/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautPackagingArtifactsImpl.java +++ b/enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/MicronautPackagingArtifactsImpl.java @@ -66,11 +66,6 @@ public class MicronautPackagingArtifactsImpl implements ProjectArtifactsImplemen */ public static final String PLUGIN_PARAM_SHAREDLIBRARY = "sharedLibrary"; // NOI18N - /** - * Maven goal that does the native-image compilation. - */ - private static final String GOAL_NATIVE_COMPILE = "native:compile"; // NOI18N - private static final Set<String> SUPPORTED_ARTIFACT_TYPES = new HashSet<>(Arrays.asList( MicronautMavenConstants.TYPE_DYNAMIC_LIBRARY, MicronautMavenConstants.TYPE_EXECUTABLE )); @@ -122,6 +117,21 @@ public class MicronautPackagingArtifactsImpl implements ProjectArtifactsImplemen public boolean computeSupportsChanges(R r) { return true; } + + /** + * Goals that actually trigger native artifact generation. As they are compared by name with + * configurations, use both unprefixed and prefixed forms + */ + private static final String[] NATIVE_ARTIFACT_BUILDERS = new String[] { + MicronautMavenConstants.PLUGIN_GOAL_COMPILE, + MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK, + "native:" + MicronautMavenConstants.PLUGIN_GOAL_COMPILE, // NOI18N + "native:" + MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK, // NOI18N + + // Compatibility with plugin 0.9.13 and earlier: + MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK_OLD, + "native:" + MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK_OLD, // NOI18N + }; static class R extends AbstractMicronautArtifacts { @@ -173,9 +183,13 @@ public class MicronautPackagingArtifactsImpl implements ProjectArtifactsImplemen boolean explicitGraalvmGoal = false; if (buildCtx.getProjectAction() != null) { RunConfig cfg = RunUtils.createRunConfig(buildCtx.getProjectAction(), getProject(), null, Lookup.EMPTY); - if (cfg != null && cfg.getGoals().contains(GOAL_NATIVE_COMPILE)) { - LOG.log(Level.FINE, "Go explicit native compilation goal from the action"); - explicitGraalvmGoal = true; + Set<String> triggerGoals = new HashSet<>(Arrays.asList(NATIVE_ARTIFACT_BUILDERS)); + if (cfg != null) { + triggerGoals.retainAll(cfg.getGoals()); + if (!triggerGoals.isEmpty()) { + LOG.log(Level.FINE, "Go explicit native compilation goal from the action"); + explicitGraalvmGoal = true; + } } } if (!explicitGraalvmGoal && !MicronautMavenConstants.PACKAGING_NATIVE.equals(model.getPackaging())) { @@ -194,8 +208,11 @@ public class MicronautPackagingArtifactsImpl implements ProjectArtifactsImplemen } LOG.log(Level.FINE, "Configured executions: {0}", p.getExecutions()); for (PluginExecution pe : p.getExecutions()) { - if (pe.getGoals().contains(MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK)) { // NOI18N - Xpp3Dom dom = model.getGoalConfiguration(MicronautMavenConstants.NATIVE_BUILD_PLUGIN_GROUP, MicronautMavenConstants.NATIVE_BUILD_PLUGIN_ID, pe.getId(), MicronautMavenConstants.PLUGIN_GOAL_COMPILE_NOFORK); // NOI18N + Set<String> triggerGoals = new HashSet<>(Arrays.asList(NATIVE_ARTIFACT_BUILDERS)); + triggerGoals.retainAll(pe.getGoals()); + if (!triggerGoals.isEmpty()) { + String goalName = triggerGoals.iterator().next(); + Xpp3Dom dom = model.getGoalConfiguration(MicronautMavenConstants.NATIVE_BUILD_PLUGIN_GROUP, MicronautMavenConstants.NATIVE_BUILD_PLUGIN_ID, pe.getId(), goalName); // NOI18N if (dom != null) { LOG.log(Level.FINE, "Found bound execution for goals {0}", pe.getGoals()); addNativeExecutable(nativeStuff, model, dom, pe); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists