1. Jan Lahoda
  2. jackpot30

Commits

Jan Lahoda  committed d9968e1

Bypass the bash script when running Jackpot from ant

  • Participants
  • Parent commits 9ea3bc5
  • Branches default

Comments (0)

Files changed (4)

File cmdline/ant/src/org/netbeans/modules/jackpot30/cmdline/ant/JackpotTask.java

View file
  • Ignore whitespace
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.taskdefs.Execute;
 import org.apache.tools.ant.taskdefs.LogStreamHandler;
-import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.CommandlineJava;
 import org.apache.tools.ant.types.Path;
 
 /**
         return this.classpath = new Path(getProject());
     }
 
+    public Path getClasspath() {
+        return classpath != null ? classpath : createClasspath();
+    }
+
     private String configFile;
 
     public void setConfigfile(String file) {
     @Override
     public void execute() throws BuildException {
         try {
-            Commandline cmdLine = new Commandline();
+            CommandlineJava cmdLine = new CommandlineJava();
 
             if (jackpotHome == null) {
                 throw new BuildException("Must specify jackpotHome");
             }
 
-            cmdLine.setExecutable(jackpotHome + "/jackpot");
-
             Path srcPath = src;
 
             if (srcPath == null) {
                 srcPath = new Path(getProject(), sourcepath);
             }
 
-            cmdLine.addArguments(new String[] {"-no-apply"});
-            cmdLine.addArguments(new String[] {"-sourcepath", srcPath.toString()});
-            cmdLine.addArguments(new String[] {"-classpath", classpath.toString()});
-            if (sourcelevel != null) cmdLine.addArguments(new String[] {"--source", sourcelevel});
-            if (configFile != null) cmdLine.addArguments(new String[] {"--config-file", configFile});
-            cmdLine.addArguments(srcPath.list());
+            cmdLine.createClasspath(getProject()).add(new Path(getProject(), jackpotHome + "/jackpot.jar"));
+            cmdLine.setClassname("org.netbeans.modules.jackpot30.cmdline.Main");
+
+            addArguments(cmdLine, "-no-apply");
+            addArguments(cmdLine, "-sourcepath", srcPath.toString());
+            addArguments(cmdLine, "-classpath", getClasspath().toString());
+            if (sourcelevel != null) addArguments(cmdLine, "--source", sourcelevel);
+            if (configFile != null) addArguments(cmdLine, "--config-file", configFile);
+            addArguments(cmdLine, srcPath.list());
 
             Execute exec = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
             exec.setCommandline(cmdLine.getCommandline());
         }
     }
 
+    private static void addArguments(CommandlineJava cmdLine, String... args) {
+        for (String arg : args) {
+            cmdLine.createArgument().setValue(arg);
+        }
+    }
+
 }

File cmdline/test/scripted/harness

View file
  • Ignore whitespace
      fi;
 }
 
+fail() {
+    write_failure_results_file $1;
+}
+
 write_passed_results_file() {
       cat >$RESULT_FILE <<EOF
 <?xml version="1.0" encoding="UTF-8" ?>

File cmdline/tool/test/scripted/config

View file
  • Ignore whitespace
 run_tool() {
     "${TOOL_NAME}"/"${TOOL_NAME}" "$@"
 }
+
+run_ant() {
+    ant -Djackpot.home="$PWD"/"$TOOL_NAME" "$@"
+}

File cmdline/tool/test/scripted/test-ant

View file
  • Ignore whitespace
+#!/bin/bash
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 2013 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License.  When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+#
+# Contributor(s):
+#
+# Portions Copyrighted 2013 Sun Microsystems, Inc.
+
+perform_test() {
+    create_file src/test/Test.java <<EOF
+package test;
+public class Test {
+    private void test() {
+        String s = "foo".intern();
+    }
+}
+EOF
+    create_file build.xml <<"EOF"
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="test" default="run" basedir=".">
+    <target name="run">
+        <fail unless="jackpot.home">${jackpot.home} must be specified</fail>
+        <taskdef name="jackpot" classname="org.netbeans.modules.jackpot30.cmdline.ant.JackpotTask" classpath="${jackpot.home}/jackpot-ant.jar"/>
+        <jackpot jackpotHome="${jackpot.home}">
+            <src>
+                <pathelement path="src" />
+            </src>
+        </jackpot>
+    </target>
+</project>
+EOF
+    create_file src/META-INF/upgrade/test.hint <<"EOF"
+$1.intern();;
+EOF
+
+    run_ant >output
+
+    if grep <output 'warning: \[test\] test' >/dev/null 2>/dev/null; then
+        fail "does not contain required output";
+    fi;
+}
+
+. `dirname $0`/harness