[ant] javac fails from commandline but works in eclipse? [message #294806] |
Thu, 17 November 2005 22:17  |
Eclipse User |
|
|
|
How to debug (better yet, fix :-) the failure of a javac task like
> serverGUI.jar:
> [javac] Compiling 37 source files to <a path/>
> [javac] javac: invalid target release: ${javac.target}
given that the same ant script works, with the same options set, under
eclipse? Details:
I have an ant script that builds two apps (a client and a server) and
runs them. I've been successfully running the script from eclipse
while developing the apps; to deploy I want to run from the
commandline. I'm required to checkout from an ssh-only CVS repository,
and my laptop runs winXP, so I've been running eclipse from a cygwin
bash shell running ssh-agent, then running the ant script from eclipse
with Run As>Ant Script etc.
I then tried to run the ant script directly from bash with a bash
script that sets up vars (ANT_HOME, which points to 1.6.5, is already
set in my environment) then calls ant:
> mkdir -p $BUILD_DIR
> pushd $BUILD_DIR
> cvs -d:ext:${CVS_ID}:${CVS_PATH} co $CVS_MODULE
> popd
> pushd $BUILD_DIR/$CS_MODULE
> ant runLocalSession
but I get the "javac: invalid target release" error above on the
compiles for both the server and client JARs. However my build.xml is
setting what appear to be reasonable values (which I am not
overriding)
> <project name="buildController" default="build.jars" basedir=".">
> <property name="basews" value="${ws}"/>
> <property name="baseos" value="${os}"/>
> <property name="basearch" value="${arch}"/>
> <property name="basenl" value="${nl}"/>
> <!-- Compiler settings. -->
> <property name="javacFailOnError" value="false"/>
> <property name="javacDebugInfo" value="on"/>
> <property name="javacDebug" value="true"/>
> <property name="javacVerbose" value="true"/>
> <property name="javacSource" value="1.3"/>
> <property name="javacTarget" value="1.2"/>
> <property name="compilerArg" value=""/>
> <path id="path_bootclasspath">
> <fileset dir="${java.home}/lib">
> <include name="*.jar"/>
> </fileset>
> </path>
> <property name="bootclasspath" refid="path_bootclasspath"/>
nor does Eclipse appear to be overriding them: when I inspect the
runconfig for the script I see, on the Properties tab,
javacSource 1.3
javacTarget 1.2
Some other things I tried, just to rule them out:
* not using cygwin. Running
> pushd %BUILD_DIR%
> cvs -d:ext:%CVS_ID%:%CS_PATH% co %CS_MODULE%
> popd
> pushd %BUILD_DIR%\%CS_MODULE%
> ant runLocalSession
from a cmd shell (after setting vars its way) draws the identical
error.
* using different Javas. I get the same failure whether my JAVA_HOME
points to 1.5.0_05 (which is the default Installed JRE in my
eclipse) or 1.4.2_06
What am I doing wrong? What else do I need to do to investigate?
Replies directly to me (as well as the newsgroup) are appreciated.
Feel free to forward, and TIA.
|
|
|
|
[ant, JUnit] testing ant script: AntRunner.getClassLoader throws CoreException [message #295133 is a reply to message #294806] |
Wed, 23 November 2005 21:08   |
Eclipse User |
|
|
|
context:
* eclipse 3.2-M3
* Sun java 1.5.0_05
* ant-1.6.5
I'm trying to test a build process. The process is currently contained
in a project in my workspace, and I kick it off by running a target in
the project's build.xml. This works now (both within eclipse and from
the commandline), but I'd like to have tests to prevent regression. I
have created a JUnit class (CcbTestAAABuildTest) in the project, the
fixture of which I'd like to run the build as directly as possible,
e.g. by just invoking the target programmatically. I saw
http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/ant_running_buildfiles_programmatical ly.htm
aka
http://127.0.0.1:60920/help/topic/org.eclipse.platform.doc.i sv/guide/ant_running_buildfiles_programmatically.htm
so am attempting to use AntRunner with code like
> /**
> * Tests are wrapped so that the long-running setUp() (i.e. running
> * the build) only runs once.
> */
> public static Test suite() {
> TestSuite suite = new TestSuite();
> suite.addTestSuite(CcbTestAAABuildTest.class);
> TestSetup wrapper = new TestSetup(suite) {
> protected void setUp() {
> oneTimeSetUp();
> }
> protected void tearDown() {
> oneTimeTearDown();
> }
> };
> return wrapper;
> }
> /**
> * Run the build.
> */
> public static void oneTimeSetUp() {
> try {
> System.out.println(
> "build script=\"" + bfp.getAbsolutePath() + "\"");
> runAntBuild(bfp.getAbsolutePath(), targets, null);
> } catch (Exception e) {
> e.printStackTrace();
> fail("failed due to exception: " + e.getMessage());
> }
> }
> public static void runAntBuild(
> String buildFileAbsPath, String[] targets, IProgressMonitor ipm)
> throws CoreException {
> AntRunner runner = new AntRunner();
> runner.setBuildFileLocation(buildFileAbsPath);
> runner.setExecutionTargets(targets);
> if (ipm == null) {
> runner.run();
> } else {
> runner.run(ipm);
> }
> }
But when I run the class via Run>JUnit, AntRunner fails with console
like
> build script="d:\eclipse\devspaces\NBA\buildController\build.xml"
> org.eclipse.core.runtime.CoreException[1]:
> java.lang.NullPointerException
> at org.eclipse.ant.core.AntRunner.getClassLoader(504)
> at org.eclipse.ant.core.AntRunner.getInternalAntRunner(374)
> at org.eclipse.ant.core.AntRunner.run(302)
> at org.eclipse.ant.core.AntRunner.run(453)
> at foo.bar.CcbTestAAABuildTest.runAntBuild(149)
> at foo.bar.CcbTestAAABuildTest.oneTimeSetUp(125)
> at foo.bar.CcbTestAAABuildTest$1.setUp(98)
> at junit.extensions.TestSetup$1.protect(18)
> at junit.framework.TestResult.runProtected(124)
> at junit.extensions.TestSetup.run(23)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(478)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(3 44)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( 196)
org.eclipse.ant.core.AntRunner.getClassLoader(504) is
> private ClassLoader getClassLoader() {
> if (customClasspath == null) {
* return AntCorePlugin.getPlugin().getNewClassLoader();
> }
> AntCorePreferences preferences =
> AntCorePlugin.getPlugin().getPreferences();
> List fullClasspath= new ArrayList();
> fullClasspath.addAll(Arrays.asList(customClasspath));
>
fullClasspath.addAll(Arrays.asList(preferences.getExtraClass pathURLs()));
> return new AntClassLoader((URL[])fullClasspath.toArray(new
URL[fullClasspath.size()]), preferences.getPluginClassLoaders());
> }
Is there something I can/must do to make this work? or is there a
better way to test the build process?
Please reply directly to me (as well as the newsgroup) if possible,
feel free to forward, and TIA.
|
|
|
Re: [ant, JUnit] testing ant script: AntRunner.getClassLoader throws CoreException [message #295160 is a reply to message #295133] |
Thu, 24 November 2005 16:30  |
Eclipse User |
|
|
|
Run it as a JUnit Plugin test.
You need the plugin framework etc so that the AntCorePlugin exists
HTH
Darins
"Tom Roche" <tlroche@us.ibm.com> wrote in message
news:438520BA.7080106@us.ibm.com...
>
> context:
> * eclipse 3.2-M3
> * Sun java 1.5.0_05
> * ant-1.6.5
>
> I'm trying to test a build process. The process is currently contained
> in a project in my workspace, and I kick it off by running a target in
> the project's build.xml. This works now (both within eclipse and from
> the commandline), but I'd like to have tests to prevent regression. I
> have created a JUnit class (CcbTestAAABuildTest) in the project, the
> fixture of which I'd like to run the build as directly as possible,
> e.g. by just invoking the target programmatically. I saw
>
> http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/ant_running_buildfiles_programmatical ly.htm
>
> aka
>
> http://127.0.0.1:60920/help/topic/org.eclipse.platform.doc.i sv/guide/ant_running_buildfiles_programmatically.htm
>
> so am attempting to use AntRunner with code like
>
> > /**
> > * Tests are wrapped so that the long-running setUp() (i.e. running
> > * the build) only runs once.
> > */
> > public static Test suite() {
> > TestSuite suite = new TestSuite();
> > suite.addTestSuite(CcbTestAAABuildTest.class);
> > TestSetup wrapper = new TestSetup(suite) {
> > protected void setUp() {
> > oneTimeSetUp();
> > }
> > protected void tearDown() {
> > oneTimeTearDown();
> > }
> > };
> > return wrapper;
> > }
>
> > /**
> > * Run the build.
> > */
> > public static void oneTimeSetUp() {
> > try {
> > System.out.println(
> > "build script=\"" + bfp.getAbsolutePath() + "\"");
> > runAntBuild(bfp.getAbsolutePath(), targets, null);
> > } catch (Exception e) {
> > e.printStackTrace();
> > fail("failed due to exception: " + e.getMessage());
> > }
> > }
>
> > public static void runAntBuild(
> > String buildFileAbsPath, String[] targets, IProgressMonitor ipm)
> > throws CoreException {
> > AntRunner runner = new AntRunner();
> > runner.setBuildFileLocation(buildFileAbsPath);
> > runner.setExecutionTargets(targets);
> > if (ipm == null) {
> > runner.run();
> > } else {
> > runner.run(ipm);
> > }
> > }
>
> But when I run the class via Run>JUnit, AntRunner fails with console
> like
>
> > build script="d:\eclipse\devspaces\NBA\buildController\build.xml"
> > org.eclipse.core.runtime.CoreException[1]:
> > java.lang.NullPointerException
> > at org.eclipse.ant.core.AntRunner.getClassLoader(504)
> > at org.eclipse.ant.core.AntRunner.getInternalAntRunner(374)
> > at org.eclipse.ant.core.AntRunner.run(302)
> > at org.eclipse.ant.core.AntRunner.run(453)
> > at foo.bar.CcbTestAAABuildTest.runAntBuild(149)
> > at foo.bar.CcbTestAAABuildTest.oneTimeSetUp(125)
> > at foo.bar.CcbTestAAABuildTest$1.setUp(98)
> > at junit.extensions.TestSetup$1.protect(18)
> > at junit.framework.TestResult.runProtected(124)
> > at junit.extensions.TestSetup.run(23)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(478)
> > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(3 44)
> > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( 196)
>
> org.eclipse.ant.core.AntRunner.getClassLoader(504) is
> > private ClassLoader getClassLoader() {
> > if (customClasspath == null) {
> * return AntCorePlugin.getPlugin().getNewClassLoader();
> > }
> > AntCorePreferences preferences =
> > AntCorePlugin.getPlugin().getPreferences();
> > List fullClasspath= new ArrayList();
> > fullClasspath.addAll(Arrays.asList(customClasspath));
> >
> fullClasspath.addAll(Arrays.asList(preferences.getExtraClass pathURLs()));
> > return new AntClassLoader((URL[])fullClasspath.toArray(new
> URL[fullClasspath.size()]), preferences.getPluginClassLoaders());
> > }
>
> Is there something I can/must do to make this work? or is there a
> better way to test the build process?
>
> Please reply directly to me (as well as the newsgroup) if possible,
> feel free to forward, and TIA.
|
|
|
Powered by
FUDForum. Page generated in 0.04131 seconds