Java Code Examples for org.netbeans.modules.maven.model.pom.POMModel#getFactory()

The following examples show how to use org.netbeans.modules.maven.model.pom.POMModel#getFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: POMComponentImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void populateChildren(List<POMComponent> children) {
    //System.out.println("populateChildren: " + getPeer().getNodeName());
    NodeList nl = getPeer().getChildNodes();
    if (nl != null){
        POMModel model = getModel();
        POMComponentFactory componentFactory = model.getFactory();
        for (int i = 0; i < nl.getLength(); i++) {
            Node n = nl.item(i);
            if (n instanceof Element) {
                POMComponent comp = componentFactory.create((Element)n, this);
                if (comp != null) {
                    children.add(comp);
                }
            }
        }
    }
}
 
Example 2
Source File: EnablePreviewMavenProj.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void performOperation(final POMModel model) {
    factory = model.getFactory();
    org.netbeans.modules.maven.model.pom.Project proj = model.getProject();
    Build build = model.getProject().getBuild();
    if (build == null) {
        build = factory.createBuild();
        proj.setBuild(build);
    }

    Plugin oldPlugin = searchMavenCompilerPlugin(build);
    if (oldPlugin == null) {
        build.addPlugin(createMavenCompilerPlugin());
    } else {

        Plugin newPlugin = updateMavenCompilerPlugin(oldPlugin);

        build.removePlugin(oldPlugin);
        build.addPlugin(newPlugin);
    }
}
 
Example 3
Source File: NetBeansRunParamsIDEChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static ModelOperation<POMModel> createUpgradePluginOperation() {
    return new ModelOperation<POMModel>() {
        public @Override
        void performOperation(POMModel model) {
            POMComponentFactory factory = model.getFactory();
            Project project = model.getProject();
            Build bld = project.getBuild();
            if (bld == null) {
                bld = factory.createBuild();
                project.setBuild(bld);
            }
            Plugin plg = PluginBackwardPropertyUtils.findPluginFromBuild(bld);
            if (plg == null) {
                plg = factory.createPlugin();
                plg.setGroupId(MavenNbModuleImpl.GROUPID_APACHE);
                plg.setArtifactId(MavenNbModuleImpl.NBM_PLUGIN);
                plg.setExtensions(Boolean.TRUE);
                bld.addPlugin(plg);
            }
            plg.setVersion(MavenNbModuleImpl.getLatestNbmPluginVersion()); //
        }
    };
}
 
Example 4
Source File: AddGroovyEclipseCompiler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void performOperation(POMModel model) {
    POMComponentFactory factory = model.getFactory();
    Project project = model.getProject();

    Build build = project.getBuild();
    if (build == null) {
        build = factory.createBuild();
        project.setBuild(build);
    }

    Plugin groovyEclipseCompiler = factory.createPlugin();
    groovyEclipseCompiler.setGroupId(MavenConstants.GROOVY_ECLIPSE_COMPILER_GROUP_ID);
    groovyEclipseCompiler.setArtifactId(MavenConstants.GROOVY_ECLIPSE_COMPILER_ARTIFACT_ID);
    groovyEclipseCompiler.setVersion(MavenConstants.GROOVY_ECLIPSE_COMPILER_VERSION);
    groovyEclipseCompiler.setExtensions(Boolean.TRUE); // THIS IS THE IMPORTANT PART !

    if (!groovyEclipseCompilerExists(build)) {
        build.addPlugin(groovyEclipseCompiler);
    }
}
 
Example 5
Source File: AddMavenCompilerPlugin.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void performOperation(final POMModel model) {
    factory = model.getFactory();
    project = model.getProject();
    Build build = project.getBuild();
    if (build == null) {
        build = factory.createBuild();
        project.setBuild(build);
    }

    Plugin plugin = searchMavenCompilerPlugin(build);
    if (plugin == null) {
        build.addPlugin(createMavenEclipseCompilerPlugin());
    } else {
        Plugin newPlugin = createMavenEclipseCompilerPlugin(plugin);

        build.removePlugin(plugin);
        build.addPlugin(newPlugin);
    }
}