Introducing jackpot30:apply
authorJan Lahoda <jlahoda@netbeans.org>
Wed, 21 Nov 2012 17:08:33 +0100
changeset 900de6375d3f9b4
parent 899 12c21232b6e5
child 901 21f586be37e3
Introducing jackpot30:apply
cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java
cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java
cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java	Wed Nov 21 17:08:33 2012 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/*
     1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 + *
     1.7 + * Copyright 2012 Sun Microsystems, Inc. All rights reserved.
     1.8 + *
     1.9 + * The contents of this file are subject to the terms of either the GNU
    1.10 + * General Public License Version 2 only ("GPL") or the Common
    1.11 + * Development and Distribution License("CDDL") (collectively, the
    1.12 + * "License"). You may not use this file except in compliance with the
    1.13 + * License. You can obtain a copy of the License at
    1.14 + * http://www.netbeans.org/cddl-gplv2.html
    1.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    1.16 + * specific language governing permissions and limitations under the
    1.17 + * License.  When distributing the software, include this License Header
    1.18 + * Notice in each file and include the License file at
    1.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    1.20 + * particular file as subject to the "Classpath" exception as provided
    1.21 + * by Sun in the GPL Version 2 section of the License file that
    1.22 + * accompanied this code. If applicable, add the following below the
    1.23 + * License Header, with the fields enclosed by brackets [] replaced by
    1.24 + * your own identifying information:
    1.25 + * "Portions Copyrighted [year] [name of copyright owner]"
    1.26 + *
    1.27 + * If you wish your version of this file to be governed by only the CDDL
    1.28 + * or only the GPL Version 2, indicate your decision by adding
    1.29 + * "[Contributor] elects to include this software in this distribution
    1.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.31 + * single choice of license, a recipient has the option to distribute
    1.32 + * your version of this file under either the CDDL, the GPL Version 2 or
    1.33 + * to extend the choice of license to its licensees as provided above.
    1.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    1.35 + * Version 2 license, then the option applies only if the new code is
    1.36 + * made subject to such option by the copyright holder.
    1.37 + *
    1.38 + * Contributor(s):
    1.39 + *
    1.40 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
    1.41 + */
    1.42 +package org.netbeans.modules.jackpot30.maven;
    1.43 +
    1.44 +import org.apache.maven.plugin.MojoExecutionException;
    1.45 +import org.apache.maven.plugin.MojoFailureException;
    1.46 +import org.apache.maven.project.MavenProject;
    1.47 +
    1.48 +/**
    1.49 + * @goal analyze
    1.50 + * @requiresDependencyResolution compile
    1.51 + * @author Jan Lahoda
    1.52 + */
    1.53 +public class RunAnalyze extends RunJackpot30 {
    1.54 +
    1.55 +    /**
    1.56 +     * @parameter expression="${project}"
    1.57 +     * @required
    1.58 +     * @readonly
    1.59 +     */
    1.60 +    private MavenProject project;
    1.61 +
    1.62 +    public void execute() throws MojoExecutionException, MojoFailureException {
    1.63 +        doRun(project, false);
    1.64 +    }
    1.65 +
    1.66 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java	Wed Nov 21 17:08:33 2012 +0100
     2.3 @@ -0,0 +1,63 @@
     2.4 +/*
     2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 + *
     2.7 + * Copyright 2012 Sun Microsystems, Inc. All rights reserved.
     2.8 + *
     2.9 + * The contents of this file are subject to the terms of either the GNU
    2.10 + * General Public License Version 2 only ("GPL") or the Common
    2.11 + * Development and Distribution License("CDDL") (collectively, the
    2.12 + * "License"). You may not use this file except in compliance with the
    2.13 + * License. You can obtain a copy of the License at
    2.14 + * http://www.netbeans.org/cddl-gplv2.html
    2.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    2.16 + * specific language governing permissions and limitations under the
    2.17 + * License.  When distributing the software, include this License Header
    2.18 + * Notice in each file and include the License file at
    2.19 + * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    2.20 + * particular file as subject to the "Classpath" exception as provided
    2.21 + * by Sun in the GPL Version 2 section of the License file that
    2.22 + * accompanied this code. If applicable, add the following below the
    2.23 + * License Header, with the fields enclosed by brackets [] replaced by
    2.24 + * your own identifying information:
    2.25 + * "Portions Copyrighted [year] [name of copyright owner]"
    2.26 + *
    2.27 + * If you wish your version of this file to be governed by only the CDDL
    2.28 + * or only the GPL Version 2, indicate your decision by adding
    2.29 + * "[Contributor] elects to include this software in this distribution
    2.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    2.31 + * single choice of license, a recipient has the option to distribute
    2.32 + * your version of this file under either the CDDL, the GPL Version 2 or
    2.33 + * to extend the choice of license to its licensees as provided above.
    2.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    2.35 + * Version 2 license, then the option applies only if the new code is
    2.36 + * made subject to such option by the copyright holder.
    2.37 + *
    2.38 + * Contributor(s):
    2.39 + *
    2.40 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
    2.41 + */
    2.42 +package org.netbeans.modules.jackpot30.maven;
    2.43 +
    2.44 +import org.apache.maven.plugin.MojoExecutionException;
    2.45 +import org.apache.maven.plugin.MojoFailureException;
    2.46 +import org.apache.maven.project.MavenProject;
    2.47 +
    2.48 +/**
    2.49 + * @goal apply
    2.50 + * @requiresDependencyResolution compile
    2.51 + * @author Jan Lahoda
    2.52 + */
    2.53 +public class RunApply extends RunJackpot30 {
    2.54 +
    2.55 +    /**
    2.56 +     * @parameter expression="${project}"
    2.57 +     * @required
    2.58 +     * @readonly
    2.59 +     */
    2.60 +    private MavenProject project;
    2.61 +
    2.62 +    public void execute() throws MojoExecutionException, MojoFailureException {
    2.63 +        doRun(project, true);
    2.64 +    }
    2.65 +
    2.66 +}
     3.1 --- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java	Wed Oct 31 18:56:14 2012 +0100
     3.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java	Wed Nov 21 17:08:33 2012 +0100
     3.3 @@ -51,21 +51,9 @@
     3.4  import org.codehaus.plexus.util.xml.Xpp3Dom;
     3.5  import org.netbeans.modules.jackpot30.cmdline.Main;
     3.6  
     3.7 -/**
     3.8 - * @goal analyze
     3.9 - * @requiresDependencyResolution compile
    3.10 - * @author Jan Lahoda
    3.11 - */
    3.12 -public class RunJackpot30 extends AbstractMojo {
    3.13 +public abstract class RunJackpot30 extends AbstractMojo {
    3.14  
    3.15 -    /**
    3.16 -     * @parameter expression="${project}"
    3.17 -     * @required
    3.18 -     * @readonly
    3.19 -     */
    3.20 -    private MavenProject project;
    3.21 -
    3.22 -    public void execute() throws MojoExecutionException, MojoFailureException {
    3.23 +    protected final void doRun(MavenProject project, boolean apply) throws MojoExecutionException, MojoFailureException {
    3.24          try {
    3.25              List<String> compileSourceRoots = new ArrayList<String>();
    3.26              compileSourceRoots.addAll((List<String>) project.getCompileSourceRoots());
    3.27 @@ -86,7 +74,12 @@
    3.28              String configurationFile = Utils.getJackpotConfigurationFile(project);
    3.29  
    3.30              List<String> cmdLine = new ArrayList<String>();
    3.31 -            cmdLine.add("--no-apply");
    3.32 +
    3.33 +            if (apply)
    3.34 +                cmdLine.add("--apply");
    3.35 +            else
    3.36 +                cmdLine.add("--no-apply");
    3.37 +
    3.38              cmdLine.add("--sourcepath");
    3.39              cmdLine.add(toClassPathString(compileSourceRoots));
    3.40              cmdLine.add("--classpath");