Adding configurationFile to the configuration, adding showgui goal.
1.1 --- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java Mon Sep 10 23:36:09 2012 +0200
1.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java Tue Sep 11 08:40:30 2012 +0200
1.3 @@ -39,9 +39,7 @@
1.4 package org.netbeans.modules.jackpot30.maven;
1.5
1.6 import java.io.File;
1.7 -import java.io.FileOutputStream;
1.8 import java.io.IOException;
1.9 -import java.io.OutputStream;
1.10 import java.util.ArrayList;
1.11 import java.util.List;
1.12 import org.apache.maven.artifact.DependencyResolutionRequiredException;
1.13 @@ -69,29 +67,32 @@
1.14 public void execute() throws MojoExecutionException, MojoFailureException {
1.15 try {
1.16 String sourceLevel = "1.5";
1.17 - for (Object o : project.getBuild().getPlugins()) {
1.18 - if (!(o instanceof Plugin)) continue;
1.19 - Plugin p = (Plugin) o;
1.20 - if (!"org.apache.maven.plugins".equals(p.getGroupId())) continue;
1.21 - if (!"maven-compiler-plugin".equals(p.getArtifactId())) continue;
1.22 - if (p.getConfiguration() instanceof Xpp3Dom) {
1.23 - Xpp3Dom configuration = (Xpp3Dom) p.getConfiguration();
1.24 - Xpp3Dom source = configuration.getChild("source");
1.25 + Xpp3Dom sourceLevelConfiguration = Utils.getPluginConfiguration(project, "org.apache.maven.plugins", "maven-compiler-plugin");
1.26
1.27 - if (source != null) {
1.28 - sourceLevel = source.getValue();
1.29 - }
1.30 + if (sourceLevelConfiguration != null) {
1.31 + Xpp3Dom source = sourceLevelConfiguration.getChild("source");
1.32 +
1.33 + if (source != null) {
1.34 + sourceLevel = source.getValue();
1.35 }
1.36 }
1.37 +
1.38 + String configurationFile = Utils.getJackpotConfigurationFile(project);
1.39 +
1.40 List<String> cmdLine = new ArrayList<String>();
1.41 - cmdLine.add("-no-apply");
1.42 - cmdLine.add("-sourcepath");
1.43 + cmdLine.add("--no-apply");
1.44 + cmdLine.add("--sourcepath");
1.45 cmdLine.add(toClassPathString((List<String>) project.getCompileSourceRoots()));
1.46 - cmdLine.add("-classpath");
1.47 + cmdLine.add("--classpath");
1.48 cmdLine.add(toClassPathString((List<String>) project.getCompileClasspathElements()));
1.49 - cmdLine.add("-source");
1.50 + cmdLine.add("--source");
1.51 cmdLine.add(sourceLevel);
1.52
1.53 + if (configurationFile != null) {
1.54 + cmdLine.add("--config-file");
1.55 + cmdLine.add(configurationFile);
1.56 + }
1.57 +
1.58 for (String sr : (List<String>) project.getCompileSourceRoots()) {
1.59 cmdLine.add(sr);
1.60 }
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/ShowGuiJackpot30.java Tue Sep 11 08:40:30 2012 +0200
2.3 @@ -0,0 +1,84 @@
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 java.io.IOException;
2.45 +import java.util.ArrayList;
2.46 +import java.util.List;
2.47 +import org.apache.maven.plugin.AbstractMojo;
2.48 +import org.apache.maven.plugin.MojoExecutionException;
2.49 +import org.apache.maven.plugin.MojoFailureException;
2.50 +import org.apache.maven.project.MavenProject;
2.51 +import org.netbeans.modules.jackpot30.cmdline.Main;
2.52 +
2.53 +/**
2.54 + * @goal showgui
2.55 + * @author Jan Lahoda
2.56 + */
2.57 +public class ShowGuiJackpot30 extends AbstractMojo {
2.58 +
2.59 + /**
2.60 + * @parameter expression="${project}"
2.61 + * @required
2.62 + * @readonly
2.63 + */
2.64 + private MavenProject project;
2.65 +
2.66 + public void execute() throws MojoExecutionException, MojoFailureException {
2.67 + try {
2.68 + String configurationFile = Utils.getJackpotConfigurationFile(project);
2.69 +
2.70 + if (configurationFile == null)
2.71 + throw new MojoExecutionException("No configuration file specified, cannot show configuration GUI");
2.72 +
2.73 + List<String> cmdLine = new ArrayList<String>();
2.74 +
2.75 + cmdLine.add("--config-file");
2.76 + cmdLine.add(configurationFile);
2.77 + cmdLine.add("--show-gui");
2.78 +
2.79 + Main.compile(cmdLine.toArray(new String[0]));
2.80 + } catch (IOException ex) {
2.81 + throw new MojoExecutionException(ex.getMessage(), ex);
2.82 + } catch (ClassNotFoundException ex) {
2.83 + throw new MojoExecutionException(ex.getMessage(), ex);
2.84 + }
2.85 + }
2.86 +
2.87 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/Utils.java Tue Sep 11 08:40:30 2012 +0200
3.3 @@ -0,0 +1,82 @@
3.4 +/*
3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.6 + *
3.7 + * Copyright 2012 Sun Microsystems, Inc. All rights reserved.
3.8 + *
3.9 + * The contents of this file are subject to the terms of either the GNU
3.10 + * General Public License Version 2 only ("GPL") or the Common
3.11 + * Development and Distribution License("CDDL") (collectively, the
3.12 + * "License"). You may not use this file except in compliance with the
3.13 + * License. You can obtain a copy of the License at
3.14 + * http://www.netbeans.org/cddl-gplv2.html
3.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.16 + * specific language governing permissions and limitations under the
3.17 + * License. When distributing the software, include this License Header
3.18 + * Notice in each file and include the License file at
3.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
3.20 + * particular file as subject to the "Classpath" exception as provided
3.21 + * by Sun in the GPL Version 2 section of the License file that
3.22 + * accompanied this code. If applicable, add the following below the
3.23 + * License Header, with the fields enclosed by brackets [] replaced by
3.24 + * your own identifying information:
3.25 + * "Portions Copyrighted [year] [name of copyright owner]"
3.26 + *
3.27 + * If you wish your version of this file to be governed by only the CDDL
3.28 + * or only the GPL Version 2, indicate your decision by adding
3.29 + * "[Contributor] elects to include this software in this distribution
3.30 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
3.31 + * single choice of license, a recipient has the option to distribute
3.32 + * your version of this file under either the CDDL, the GPL Version 2 or
3.33 + * to extend the choice of license to its licensees as provided above.
3.34 + * However, if you add GPL Version 2 code and therefore, elected the GPL
3.35 + * Version 2 license, then the option applies only if the new code is
3.36 + * made subject to such option by the copyright holder.
3.37 + *
3.38 + * Contributor(s):
3.39 + *
3.40 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
3.41 + */
3.42 +package org.netbeans.modules.jackpot30.maven;
3.43 +
3.44 +import org.apache.maven.model.Plugin;
3.45 +import org.apache.maven.project.MavenProject;
3.46 +import org.codehaus.plexus.util.xml.Xpp3Dom;
3.47 +
3.48 +/**
3.49 + *
3.50 + * @author lahvac
3.51 + */
3.52 +public class Utils {
3.53 +
3.54 + public static Xpp3Dom getPluginConfiguration(MavenProject project, String groupId, String artifactId) {
3.55 + for (Object o : project.getBuild().getPlugins()) {
3.56 + if (!(o instanceof Plugin)) continue;
3.57 +
3.58 + Plugin p = (Plugin) o;
3.59 +
3.60 + if ( groupId.equals(p.getGroupId())
3.61 + && artifactId.equals(p.getArtifactId())) {
3.62 + if (p.getConfiguration() instanceof Xpp3Dom) {
3.63 + return (Xpp3Dom) p.getConfiguration();
3.64 + }
3.65 + break;
3.66 + }
3.67 + }
3.68 +
3.69 + return null;
3.70 + }
3.71 +
3.72 + public static String getJackpotConfigurationFile(MavenProject project) {
3.73 + Xpp3Dom configuration = getPluginConfiguration(project, "org.netbeans.modules.jackpot30", "jackpot30-maven-plugin");
3.74 +
3.75 + if (configuration != null) {
3.76 + Xpp3Dom configurationFileElement = configuration.getChild("configurationFile");
3.77 +
3.78 + if (configurationFileElement != null) {
3.79 + return configurationFileElement.getValue();
3.80 + }
3.81 + }
3.82 +
3.83 + return null;
3.84 + }
3.85 +}