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?


    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<String> 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<String, String> properties = new HashMap<>();
setProperty.invoke(rc, properties);

// maven profile
Method setActivatedProfiles = runConfig.getMethod("setActivatedProfiles", new 
Class[]{java.util.List.class});
List<String> 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)

Reply via email to