On 19. 07. 22 18:32, Peter Cheung wrote:
Hi
I am creating a new project type for RISC-V. The below code only work when
my netbeans loaded maven plugin. Is it possible to let netbeans load my plugin
and auto load maven plugin together?
Well, that's bad. Maven module's API is just 'friend API'; so it is only
available to a certain set of modules. Mainly because the API is too
broad and the original author perhaps did not feel (?) it's rock solid
to be published and maintained for good.
If it was a regular API, you could just add a module dependency.
You may consider to make an "implementation dependency" on Maven
Projects module --
https://netbeans.apache.org/wiki/DevFaqImplementationDependency.asciidoc
--%< from project.xml of the dependent module -%<--
org.netbeans.modules.maven
2
--%<%<-%<--
But please read carefully to understand the consequences. But the
reflection is really ugly
-S.
How can my netbeans modules got the mvn path? i found "mavenHome =
EmbedderFactory.getEffectiveMavenHome();" in netbeans source code but I don't have
class EmbedderFactory
ClassLoader syscl = Lookup.getDefault().lookup(ClassLoader.class);
System.out.println(syscl);
List goals = new ArrayList<>();
goals.add("compile");
ProjectInformation projectInformation = ProjectUtils.getInformation(this);
Class runUtils =
syscl.loadClass("org.netbeans.modules.maven.api.execute.RunUtils");
Method createRunConfig = runUtils.getMethod("createRunConfig", new
Class[]{File.class, Project.class, String.class, List.class});
Object rc = createRunConfig.invoke(null, FileUtil.toFile(this.projectDir),
this, projectInformation.getDisplayName(), goals);
Class runConfig =
syscl.loadClass("org.netbeans.modules.maven.api.execute.RunConfig");
// maven properties
Method setProperty = runConfig.getMethod("addProperties", new
Class[]{Map.class});
Map properties = new HashMap<>();
setProperty.invoke(rc, properties);
// maven profile
Method setActivatedProfiles = runConfig.getMethod("setActivatedProfiles", new
Class[]{java.util.List.class});
List profiles = new ArrayList<>();
profiles.add("dev");
profiles.add("prod");
setActivatedProfiles.invoke(rc, profiles);
Method executeMaven = runUtils.getMethod("executeMaven", new
Class[]{runConfig});
executeMaven.invoke(null, rc);
Thanks
From Peter (System Architect, Quantr Limited https://www.quantr.hk , Mobile :
96554595)
-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists