Bypass the bash script when running Jackpot from ant
authorJan Lahoda <jlahoda@netbeans.org>
Tue, 15 Jan 2013 16:13:16 +0100
changeset 924e5114e185f31
parent 923 b8b9154040e4
child 925 9132c333319f
child 927 fa494946f556
Bypass the bash script when running Jackpot from ant
cmdline/ant/src/org/netbeans/modules/jackpot30/cmdline/ant/JackpotTask.java
cmdline/test/scripted/harness
cmdline/tool/test/scripted/config
cmdline/tool/test/scripted/test-ant
     1.1 --- a/cmdline/ant/src/org/netbeans/modules/jackpot30/cmdline/ant/JackpotTask.java	Sun Jan 13 00:16:50 2013 +0100
     1.2 +++ b/cmdline/ant/src/org/netbeans/modules/jackpot30/cmdline/ant/JackpotTask.java	Tue Jan 15 16:13:16 2013 +0100
     1.3 @@ -44,7 +44,7 @@
     1.4  import org.apache.tools.ant.Task;
     1.5  import org.apache.tools.ant.taskdefs.Execute;
     1.6  import org.apache.tools.ant.taskdefs.LogStreamHandler;
     1.7 -import org.apache.tools.ant.types.Commandline;
     1.8 +import org.apache.tools.ant.types.CommandlineJava;
     1.9  import org.apache.tools.ant.types.Path;
    1.10  
    1.11  /**
    1.12 @@ -83,6 +83,10 @@
    1.13          return this.classpath = new Path(getProject());
    1.14      }
    1.15  
    1.16 +    public Path getClasspath() {
    1.17 +        return classpath != null ? classpath : createClasspath();
    1.18 +    }
    1.19 +
    1.20      private String configFile;
    1.21  
    1.22      public void setConfigfile(String file) {
    1.23 @@ -92,14 +96,12 @@
    1.24      @Override
    1.25      public void execute() throws BuildException {
    1.26          try {
    1.27 -            Commandline cmdLine = new Commandline();
    1.28 +            CommandlineJava cmdLine = new CommandlineJava();
    1.29  
    1.30              if (jackpotHome == null) {
    1.31                  throw new BuildException("Must specify jackpotHome");
    1.32              }
    1.33  
    1.34 -            cmdLine.setExecutable(jackpotHome + "/jackpot");
    1.35 -
    1.36              Path srcPath = src;
    1.37  
    1.38              if (srcPath == null) {
    1.39 @@ -110,12 +112,15 @@
    1.40                  srcPath = new Path(getProject(), sourcepath);
    1.41              }
    1.42  
    1.43 -            cmdLine.addArguments(new String[] {"-no-apply"});
    1.44 -            cmdLine.addArguments(new String[] {"-sourcepath", srcPath.toString()});
    1.45 -            cmdLine.addArguments(new String[] {"-classpath", classpath.toString()});
    1.46 -            if (sourcelevel != null) cmdLine.addArguments(new String[] {"--source", sourcelevel});
    1.47 -            if (configFile != null) cmdLine.addArguments(new String[] {"--config-file", configFile});
    1.48 -            cmdLine.addArguments(srcPath.list());
    1.49 +            cmdLine.createClasspath(getProject()).add(new Path(getProject(), jackpotHome + "/jackpot.jar"));
    1.50 +            cmdLine.setClassname("org.netbeans.modules.jackpot30.cmdline.Main");
    1.51 +
    1.52 +            addArguments(cmdLine, "-no-apply");
    1.53 +            addArguments(cmdLine, "-sourcepath", srcPath.toString());
    1.54 +            addArguments(cmdLine, "-classpath", getClasspath().toString());
    1.55 +            if (sourcelevel != null) addArguments(cmdLine, "--source", sourcelevel);
    1.56 +            if (configFile != null) addArguments(cmdLine, "--config-file", configFile);
    1.57 +            addArguments(cmdLine, srcPath.list());
    1.58  
    1.59              Execute exec = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
    1.60              exec.setCommandline(cmdLine.getCommandline());
    1.61 @@ -125,4 +130,10 @@
    1.62          }
    1.63      }
    1.64  
    1.65 +    private static void addArguments(CommandlineJava cmdLine, String... args) {
    1.66 +        for (String arg : args) {
    1.67 +            cmdLine.createArgument().setValue(arg);
    1.68 +        }
    1.69 +    }
    1.70 +
    1.71  }
     2.1 --- a/cmdline/test/scripted/harness	Sun Jan 13 00:16:50 2013 +0100
     2.2 +++ b/cmdline/test/scripted/harness	Tue Jan 15 16:13:16 2013 +0100
     2.3 @@ -72,6 +72,10 @@
     2.4       fi;
     2.5  }
     2.6  
     2.7 +fail() {
     2.8 +    write_failure_results_file $1;
     2.9 +}
    2.10 +
    2.11  write_passed_results_file() {
    2.12        cat >$RESULT_FILE <<EOF
    2.13  <?xml version="1.0" encoding="UTF-8" ?>
     3.1 --- a/cmdline/tool/test/scripted/config	Sun Jan 13 00:16:50 2013 +0100
     3.2 +++ b/cmdline/tool/test/scripted/config	Tue Jan 15 16:13:16 2013 +0100
     3.3 @@ -42,3 +42,7 @@
     3.4  run_tool() {
     3.5      "${TOOL_NAME}"/"${TOOL_NAME}" "$@"
     3.6  }
     3.7 +
     3.8 +run_ant() {
     3.9 +    ant -Djackpot.home="$PWD"/"$TOOL_NAME" "$@"
    3.10 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/cmdline/tool/test/scripted/test-ant	Tue Jan 15 16:13:16 2013 +0100
     4.3 @@ -0,0 +1,74 @@
     4.4 +#!/bin/bash
     4.5 +#
     4.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.7 +#
     4.8 +# Copyright 2013 Sun Microsystems, Inc. All rights reserved.
     4.9 +#
    4.10 +# The contents of this file are subject to the terms of either the GNU
    4.11 +# General Public License Version 2 only ("GPL") or the Common
    4.12 +# Development and Distribution License("CDDL") (collectively, the
    4.13 +# "License"). You may not use this file except in compliance with the
    4.14 +# License. You can obtain a copy of the License at
    4.15 +# http://www.netbeans.org/cddl-gplv2.html
    4.16 +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.17 +# specific language governing permissions and limitations under the
    4.18 +# License.  When distributing the software, include this License Header
    4.19 +# Notice in each file and include the License file at
    4.20 +# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    4.21 +# particular file as subject to the "Classpath" exception as provided
    4.22 +# by Sun in the GPL Version 2 section of the License file that
    4.23 +# accompanied this code. If applicable, add the following below the
    4.24 +# License Header, with the fields enclosed by brackets [] replaced by
    4.25 +# your own identifying information:
    4.26 +# "Portions Copyrighted [year] [name of copyright owner]"
    4.27 +#
    4.28 +# If you wish your version of this file to be governed by only the CDDL
    4.29 +# or only the GPL Version 2, indicate your decision by adding
    4.30 +# "[Contributor] elects to include this software in this distribution
    4.31 +# under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.32 +# single choice of license, a recipient has the option to distribute
    4.33 +# your version of this file under either the CDDL, the GPL Version 2 or
    4.34 +# to extend the choice of license to its licensees as provided above.
    4.35 +# However, if you add GPL Version 2 code and therefore, elected the GPL
    4.36 +# Version 2 license, then the option applies only if the new code is
    4.37 +# made subject to such option by the copyright holder.
    4.38 +#
    4.39 +# Contributor(s):
    4.40 +#
    4.41 +# Portions Copyrighted 2013 Sun Microsystems, Inc.
    4.42 +
    4.43 +perform_test() {
    4.44 +    create_file src/test/Test.java <<EOF
    4.45 +package test;
    4.46 +public class Test {
    4.47 +    private void test() {
    4.48 +        String s = "foo".intern();
    4.49 +    }
    4.50 +}
    4.51 +EOF
    4.52 +    create_file build.xml <<"EOF"
    4.53 +<?xml version="1.0" encoding="UTF-8"?>
    4.54 +<project name="test" default="run" basedir=".">
    4.55 +    <target name="run">
    4.56 +        <fail unless="jackpot.home">${jackpot.home} must be specified</fail>
    4.57 +        <taskdef name="jackpot" classname="org.netbeans.modules.jackpot30.cmdline.ant.JackpotTask" classpath="${jackpot.home}/jackpot-ant.jar"/>
    4.58 +        <jackpot jackpotHome="${jackpot.home}">
    4.59 +            <src>
    4.60 +                <pathelement path="src" />
    4.61 +            </src>
    4.62 +        </jackpot>
    4.63 +    </target>
    4.64 +</project>
    4.65 +EOF
    4.66 +    create_file src/META-INF/upgrade/test.hint <<"EOF"
    4.67 +$1.intern();;
    4.68 +EOF
    4.69 +
    4.70 +    run_ant >output
    4.71 +
    4.72 +    if grep <output 'warning: \[test\] test' >/dev/null 2>/dev/null; then
    4.73 +        fail "does not contain required output";
    4.74 +    fi;
    4.75 +}
    4.76 +
    4.77 +. `dirname $0`/harness