ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "T Master" <tmas...@iknowledgeinc.com>
Subject custom task problem... ARGHH!!
Date Tue, 14 Aug 2001 16:32:42 GMT

I have a developed a custom task on top of the metric tool javancss.

JavaNCSS' api allows me to construct it's main object.  However, ant fails
in runing this as it cannot find the imported classes (they do not reside in
my system classpath).
So I implemented code to support the nest <classpath> element and refids.
The code was copied from javac.
The Commandline class and Execute were then added.  Now I get error=2
errors.  I'm stuck.

Stefan/Conor:  I couldn't find documentation on what the error values 1 and
2 meant.

Here is a code snippet:        (I will attach the full source if anyone is
interestedm rather than emailing it to everyone on the mail list)
        if (classpath == null)
            classpath = Path.systemClasspath;
        else
            classpath = classpath.concatSystemClasspath("ignore");

        Commandline toExecute = new Commandline();
        toExecute.setExecutable("java javancss.Main -version");    // basic
usage specified here.  source file not specified now.
        // toExecute.createArgument().setValue("-classpath");
        // toExecute.createArgument().setPath(classpath);
        // toExecute.addArguments(files);//cmdArgs);
        Execute exe = new Execute();
        exe.setAntRun(project);
        exe.setWorkingDirectory(project.getBaseDir());
        try
        {
            exe.setCommandline(toExecute.getCommandline());
            int ret = exe.execute();
            if (ret != 0) {
                throw new BuildException("JavaNCSS returned "+ret,
location);
            }
        }
        catch (IOException e)
        {
            throw new BuildException("JavaNCSS failed: " + e, e, location);
        }


>From my build.xml file:
   <target depends="init" name="metrics">
        <javancss dest="results.xml" function="true" object="true"
package="true" xml="true">
            <fileset dir="${src.dir}">
                <patternset id="metric.files">
                    <include name="com/api/exception/ConnectionException.jav
a"/>
                </patternset>
            </fileset>
            <!--classpath refid="project.metric.class.path"/-->
        </javancss>
    </target>


My dev box is: O/S = win2000, ant = v1.3, have optional.jar.

Output:
parsing buildfile C:\dev\java\build\build.xml with URI =
file:C:/dev/java/build/build.xml
Setting ro project property: ant.project.name -> inext20
Setting project property: basedir -> C:\dev\java
Project base dir set to: C:\dev\java
   +Task: property
Loading C:\dev\java\build\inext20.properties
Setting project property: interrogator.buildfile -> interrogator-build.xml
Setting project property: appserver.buildfile -> appserver-build.xml
Setting project property: buildfile.dir -> build
Setting project property: src.dir -> src
Setting project property: src.test.dir -> test
Setting project property: buildtools.buildfile -> buildtools-build.xml
Setting project property: lib.build.dir -> lib/build
Setting project property: build.dir -> class
Setting project property: dist.dir -> jar
Setting project property: javadoc.dir -> docs/api
   +Task: taskdef
Finding class JavaNcssTask
Class org.apache.tools.ant.Task loaded from system loader
Class JavaNcssTask loaded from ant loader
 +User task: javancss     JavaNcssTask
   +DataType: path
   +DataType: path
   +DataType: patternset
   +DataType: patternset
   +DataType: patternset
   +DataType: patternset
 +Target: init
   +Task: tstamp
   +Task: mkdir
   +Task: mkdir
   +Task: mkdir
   +Task: mkdir
 +Target: compile
 +Target: compileAppServer
   +Task: ant
 +Target: compileInterrogator
   +Task: ant
 +Target: compileAllTests
   +Task: ant
   +Task: ant
 +Target: dist
 +Target: jarAppServer
   +Task: ant
 +Target: jarInterrogator
   +Task: ant
 +Target: jarBuildTools
   +Task: ant
 +Target: jarTests
   +Task: ant
   +Task: ant
 +Target: signjars
   +Task: signjar
   +Task: signjar
 +Target: deploy
   +Task: echo
 +Target: test
   +Task: echo
 +Target: metrics
Class java.lang.Throwable loaded from system loader
Class java.lang.SecurityException loaded from system loader
Class java.io.IOException loaded from system loader
Class java.io.OutputStream loaded from system loader
Class java.io.FileOutputStream loaded from system loader
Class org.apache.tools.ant.BuildException loaded from system loader
Class java.lang.System loaded from system loader
Class java.util.Vector loaded from system loader
Class org.apache.tools.ant.types.Commandline loaded from system loader
   +Task: javancss
Class org.apache.tools.ant.types.Path loaded from system loader
Class java.io.File loaded from system loader
Class org.apache.tools.ant.types.Reference loaded from system loader
Class org.apache.tools.ant.types.FileSet loaded from system loader
 +Target: rules
 +Target: ncss
   +Task: property
 +Target: dependencies
   +Task: property
   +Task: property
 +Target: main
 +Target: build
   +Task: ant
   +Task: ant
 +Target: buildAppServer
   +Task: ant
 +Target: buildInterrogator
   +Task: ant
 +Target: buildMetricTools
   +Task: ant
 +Target: javadocs
   +Task: echo
   +Task: javadoc
 +Target: fetch
   +Task: echo
   +Task: vssget
   +Task: echo
   +Task: vssget
 +Target: fetchLabel
   +Task: echo
   +Task: vssget
 +Target: clean
   +Task: echo
   +Task: delete
   +Task: delete
   +Task: delete
   +Task: delete
 +Target: cleanJars
   +Task: echo
   +Task: delete
   +Task: delete
 +Target: cleanClasses
   +Task: echo
   +Task: delete
   +Task: delete
 +Target: cleanJava
   +Task: echo
   +Task: delete
   +Task: delete
 +Target: cleanTests
   +Task: echo
   +Task: delete
Build sequence for target `metrics' is [init, metrics]
Complete build sequence is [init, metrics, cleanJava, cleanClasses,
compileAppServer, jarAppServer, cleanTests, deploy, fetchLabel,
buildAppServer, compileAllTests, jarTests, cleanJars, compileInterrogator,
jarInterrogator, dist, test, main, buildInterrogator, buildMetricTools,
compile, jarBuildTools, rules, dependencies, javadocs, clean, fetch, build,
ncss, signjars]
init:
Setting project property: DSTAMP -> 20010814
Setting project property: TSTAMP -> 0909
Setting project property: TODAY -> August 14 2001
metrics:
Class java.io.PrintStream loaded from system loader
Class org.apache.tools.ant.DirectoryScanner loaded from system loader
Class java.lang.StringBuffer loaded from system loader
Class org.apache.tools.ant.taskdefs.Execute loaded from system loader
Class org.apache.tools.ant.Project loaded from system loader
Execute:Java13CommandLauncher: "java javancss.Main -all
com\api\exception\ConnectionException.java"
build.xml [223] JavaNCSS failed: java.io.IOException: CreateProcess: "java
javancss.Main -all com\api\exception\ConnectionException.java" error=2
--- Nested Exception ---
java.io.IOException: CreateProcess: "java javancss.Main -all
com\api\exception\ConnectionException.java" error=2
        at java.lang.Win32Process.create(Native Method)
        at java.lang.Win32Process.<init>(Win32Process.java:66)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:551)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.jav
a:509)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:329)
        at JavaNcssTask.execute(JavaNcssTask.java:260)
        at org.apache.tools.ant.Target.execute(Target.java:153)
        at org.apache.tools.ant.Project.runTarget(Project.java:898)
        at org.apache.tools.ant.Project.executeTarget(Project.java:536)
        at org.apache.tools.ant.Project.executeTargets(Project.java:510)
        at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:263)
        at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:118)


Thanks,
T Master.


Mime
View raw message