I try to install leJOS NXJ on my MAC OS X and run it's sample, but after I do what it wants and export NXJ_Home Path file and etc. and install netbeans plugin and create it sample project (Creating your own project using the Netbeans Plugin). I also follow this structure and replace desire classes.jar from intsall leJOS NXJ installation's lib folder.
I export these 4 lines:
My-macbook-pro:~ AR$ export NXJ_HOME=/Users/AR/Documents/Research-kar/JAVA/lejos_nxj
My-macbook-pro:~ AR$ export DYLD_LIBRARY_PATH=$NXJ_HOME/bin
My-macbook-pro:~ AR$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
My-macbook-pro:~ AR$ export PATH=$PATH:$JAVA_HOME/bin:$NXJ_HOME/binamirrezas-macbook-pro:~ AR$
This is leJOS NXJ sample code:
package org.lejos.example;
import lejos.nxt.*;
/**
* Example leJOS Project with an ant build file
*
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
Button.waitForPress();
}
}
and this is related build.xml file:
<project name="Example" default="uploadandrun">
<description>
org.lejos.example.HelloWorld build file
</description>
<!-- set properties for this build -->
<property environment = "env"/>
<property file="build.properties"/>
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="program" value="Example"/>
<property name="main.class" value="org.lejos.example.HelloWorld"/>
<property name="binary" value="${build}/${program}.nxj" />
<!-- deletes generated files -->
<target name="clean" description="clean up all generated files">
<delete dir="build"/>
</target>
<target name="compile" depends="clean"
description="compile the source " >
<!-- Compile the java code from ${src} to ${build} -->
<mkdir dir="${build}"/>
<javac srcdir="${src}" destdir="${build}">
<bootclasspath>
<pathelement location="${nxj.classes.home}/lib/classes.jar"/>
</bootclasspath>
</javac>
</target>
<target name="link" depends="compile"
description="link the binary " >
<!-- Link the binary and create a signature file -->
<java classname="js.tinyvm.TinyVM">
<arg value="--bootclasspath"/>
<arg path="${nxj.classes.jar}" />
<arg value="--classpath"/>
<arg path="${build}" />
<arg value="--writeorder" />
<arg value="LE" />
<arg value="${main.class}"/>
<arg value="-o"/>
<arg value="${binary}"/>
<arg value="-v"/>
<classpath>
<pathelement location="${nxj.jtools.jar}"/>
<pathelement location="${nxj.commons.jar}"/>
<pathelement location="${nxj.bcel.jar}"/>
</classpath>
</java>
</target>
<target name="upload" depends="link"
description="upload the binary" >
<java classname="lejos.pc.tools.NXJUpload" fork="true">
<jvmarg value="-Djava.library.path=${nxj.library.path}"/>
<jvmarg value="-Dnxj.home=${nxj.home}"/>
<arg value="${binary}"/>
<classpath>
<pathelement location="${nxj.jtools.jar}"/>
<pathelement location="${nxj.pctools.jar}"/>
<pathelement location="${nxj.pccomm.jar}"/>
<pathelement location="${nxj.commons.jar}"/>
<pathelement location="${nxj.bcel.jar}"/>
<pathelement location="${nxj.bluecove.jar}"/>
<pathelement location="${nxj.bluecove-gpl.jar}"/>
</classpath>
</java>
</target>
<target name="uploadandrun" depends="link"
description="upload and run the binary" >
<java classname="lejos.pc.tools.NXJUpload" fork="true">
<jvmarg value="-Djava.library.path=${nxj.library.path}"/>
<jvmarg value="-Dnxj.home=${nxj.home}"/>
<arg value="${binary}"/>
<arg value="-r"/>
<classpath>
<pathelement location="${nxj.jtools.jar}"/>
<pathelement location="${nxj.pctools.jar}"/>
<pathelement location="${nxj.pccomm.jar}"/>
<pathelement location="${nxj.commons.jar}"/>
<pathelement location="${nxj.bcel.jar}"/>
<pathelement location="${nxj.bluecove.jar}"/>
<pathelement location="${nxj.bluecove-gpl.jar}"/>
</classpath>
</java>
</target>
<!-- used only for modifying the Netbeans NXJPlugin -->
<target name="Zip for Netbeans" description="Zip the application to the sample project">
<property name="build.classes.dir" location="/build"/>
<property name="plugin" location="../NXJPlugin/src/nxjplugin/"/>
<zip basedir="." destfile="${plugin}/NXJSampleProject.zip">
<exclude name="**/build/"/>
<exclude name="**/bin/"/>
<exclude name="**/dist/"/>
<exclude name="**/nbproject/private/"/>
</zip>
</target>
</project>
and this is ide-file-targets.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="org.lejos.example-IDE">
<target name="run-selected-file-in-src">
<fail unless="run.class">Must set property 'run.class'</fail>
<ant antfile="build.xml" target="uploadandrun">
<property name="main.class" value="${run.class}"/>
</ant>
</target>
<target name="compile-selected-files-in-src">
<ant antfile="build.xml" target="compile"/>
</target>
</project>
I get this error:
run-selected-file-in-src:
clean:
Deleting directory /Users/AR/Documents/NetBeansProjects/NXJSample/build
compile:
Created dir: /Users/AR/Documents/NetBeansProjects/NXJSample/build
Compiling 1 source file to /Users/AR/Documents/NetBeansProjects/NXJSample/build
/Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:3: package lejos.nxt does not exist
import lejos.nxt.*;
/Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:13: cannot find symbol
symbol : variable Button
location: class org.lejos.example.HelloWorld
Button.waitForPress();
^
2 errors
/Users/AR/Documents/NetBeansProjects/NXJSample/nbproject/ide-file-targets.xml:5: The following error occurred while executing this line:
/Users/AR/Documents/NetBeansProjects/NXJSample/build.xml:24: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
[1]: http://lejos.sourceforge.net/
a little bit late but may other like me are looking for a solution. I am new on leJOS and Netbeans and Java (starting tonight).
My environment is WindowsXP with Netbeans 6.9.1.
leJOS is installed in C:/Programme/leJOS NXJ
First Project: HelloWorld
I fixed it by setting the nxj.home var in the build.properties file laying in the project root directory (here /HelloWorld/ and build.xml is also there).
The nxj.home has to point to the leJOS installation path. In my case:
nxj.home=C:/Programme/leJOS NXJ
Hope it helps
Joe.
Related
I am a beginner in Ant and GWT and I was creating a new Ant project in GWT by following the steps mentioned on this GWT page: webAppCreator under the Creating an Ant project section. I was able to create this project successfully but I got the error build.xml does not exist! in the Command Prompt log. I am unable to fix this problem even after following all the steps mentioned here : ant build.xml file doesn't exist.
Here is my Command Prompt log:
C:\Users\TEST>webAppCreator -junit D:\SELENIUM\junit-4.10.jar -out foo com.example.foo.Foo
Generating from templates: [sample, eclipse, readme, _eclipse-test, _sample-test, ant]
Created directory foo
Created directory foo\src
Created directory foo\src\com\example\foo
Created directory foo\src\com\example\foo\client
Created directory foo\src\com\example\foo\server
Created directory foo\src\com\example\foo\shared
Created directory foo\test
Created directory foo\test\com\example\foo
Created directory foo\war
Created directory foo\war\WEB-INF
Created directory foo\test\com\example\foo\client
Created file foo\src\com\example\foo\Foo.gwt.xml
Created file foo\src\com\example\foo\client\GreetingService.java
Created file foo\src\com\example\foo\client\GreetingServiceAsync.java
Created file foo\src\com\example\foo\client\Foo.java
Created file foo\src\com\example\foo\server\GreetingServiceImpl.java
Created file foo\src\com\example\foo\shared\FieldVerifier.java
Created file foo\war\WEB-INF\web.xml
Created file foo\war\Foo.css
Created file foo\war\Foo.html
Created file foo\war\favicon.ico
Created file foo\.classpath
Created file foo\.project
Created file foo\Foo.launch
Created file foo\README.txt
Created file foo\FooSuite-dev.launch
Created file foo\FooSuite-prod.launch
Created file foo\test\com\example\foo\FooJUnit.gwt.xml
Created file foo\test\com\example\foo\FooSuite.java
Created file foo\test\com\example\foo\client\FooTest.java
Created file foo\build.xml
C:\Users\TEST>ant build
Buildfile: build.xml does not exist!
Build failed
C:\Users\TEST>ant devmode
Buildfile: build.xml does not exist!
Build failed
Here is my build.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Foo" default="build" basedir=".">
<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />
<!-- Configure path to GWT SDK -->
<property name="gwt.sdk" location="D:/GWT/gwt-2.8.1/gwt-2.8.1" />
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<pathelement location="${gwt.sdk}/gwt-dev.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar"/>
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
<!-- Add any additional non-server libs (such as JUnit) here -->
</path>
<target name="libs" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
<!-- Add any additional server libs that need to be copied -->
</target>
<target name="javac" depends="libs" description="Compile java source to bytecode">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.7" target="1.7" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java"/>
</copy>
</target>
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="512m">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="com.example.foo.Foo"/>
</java>
</target>
<target name="devmode" depends="javac" description="Run development mode (pass -Dgwt.args=-nosuperDevMode to fallback to classic DevMode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode" maxmemory="1g">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/gwt-codeserver.jar"/>
</classpath>
<arg value="-startupUrl"/>
<arg value="Foo.html"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY, -logLevel DEBUG or -nosuperDevMode -->
<arg line="${gwt.args}"/>
<arg value="com.example.foo.Foo"/>
<arg value="com.example.foo.Foo"/>
</java>
</target>
<target name="javac.tests" depends="javac" description="Compiles test code">
<javac srcdir="test" includes="**" encoding="utf-8"
source="1.7" target="1.7" nowarn="true"
destdir="war/WEB-INF/classes"
debug="true" debuglevel="lines,vars,source">
<classpath location="D:\SELENIUM\junit-4.10.jar"/>
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="test.dev" depends="javac.tests" description="Run development mode tests">
<mkdir dir="reports/htmlunit.dev" />
<junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
<sysproperty key="gwt.args" value="-devMode -logLevel WARN -war www-test" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
<pathelement location="D:\SELENIUM\junit-4.10.jar" />
</classpath>
<batchtest todir="reports/htmlunit.dev" >
<fileset dir="test" >
<include name="**/*Suite.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test.prod" depends="javac.tests" description="Run production mode tests">
<mkdir dir="reports/htmlunit.prod" />
<junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
<sysproperty key="gwt.args" value="-logLevel WARN -war www-test" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
<pathelement location="D:\SELENIUM\junit-4.10.jar" />
</classpath>
<batchtest todir="reports/htmlunit.prod" >
<fileset dir="test" >
<include name="**/*Suite.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test" description="Run development and production mode tests">
<antcall target="test.dev" />
<antcall target="test.prod" />
</target>
<target name="build" depends="gwtc" description="Build this project" />
<target name="war" depends="build" description="Create a war file">
<zip destfile="Foo.war" basedir="war"/>
</target>
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/foo" failonerror="false" />
</target>
</project>
Can someone please help me to fix this issue?
It seems your build.xml is created in a foo folder.
See this output:
Created file foo\build.xml
Go to the foo directory and then run ant.
C:\Users\TEST>ant build
Buildfile: build.xml does not exist!
Build failed
It means build file is absent in TEST directory. Checking your logs you have one in the :\Users\TEST\foo. So you should navigate into foo than try command via terminal one more time.
if you are on Mac :
brew install ant;
brew install ivy;
ant ivy-bootstrap ;
then go to top of ant project;
run ant
This is my build.xml using ant.
<?xml version="1.0" encoding="UTF-8"?>
<project name="compile" default="css.concatenate" basedir=".">
<property name="charset" value="utf-8"/>
<!-- compile LESS -->
<target name="css.concatenate">
<concat destfile="${basedir}/src/main/webapp/cons/cons.less">
<fileset dir="${basedir}/src/main/webapp/less">
<include name="*.less"/>
</fileset>
</concat>
<echo>cons is done!</echo>
</target>
<target name="lessc" depends="css.concatenate">
<echo>now in compression</echo>
<java classname="CpLess" fork="true">
<arg value="${basedir}/src/main/webapp/cons"/><!-- input folder that contains less file -->
<arg value="${basedir}/src/main/webapp/css"/><!-- output folder -->
<classpath>
<pathelement location="${basedir}/lib/commons-logging.jar"/>
<pathelement location="${basedir}/lib/js.jar"/>
<pathelement location="${basedir}/lib/lesscss-engine.jar"/>
<pathelement location="${basedir}/lib/yuicompressor.jar"/>
<pathelement location="${basedir}/lib/zkjszips.jar"/>
<pathelement location="${basedir}/lib/zkless.jar"/>
<pathelement location="${basedir}/lib/zul.jar"/> <!-- only needed if using _zkmixins.less -->
</classpath>
</java>
</target>
<target name="rename" depends="lessc">
<echo>renaming...</echo>
<rename src="${basedir}/src/main/webapp/css/cons.css.dsp" dest="${basedir}/src/main/webapp/css/core.css"/>
<delete file="${basedir}/src/main/webapp/css/cons.css.dsp.src"/>
<echo>rename done</echo>
</target>
<target name="trasition" >
<echo> in trasition </echo>
</target>
</project>
When I run this, it comes into the error like this:
Buildfile: C:\Users\di_yu\workspace\lessCompiler\build.xml
css.concatenate:
[echo] cons is done!
lessc:
[echo] now in compression
[java] Compiling... C:\Users\di_yu\workspace\lessCompiler\src\main\webapp\cons\cons.less
css.concatenate:
[echo] cons is done!
css.concatenate:
[echo] cons is done!
lessc:
[echo] now in compression
[java] Compiling... C:\Users\di_yu\workspace\lessCompiler\src\main\webapp\cons\cons.less
rename:
[echo] renaming...
[rename] DEPRECATED - The rename task is deprecated. Use move instead.
[delete] Deleting: C:\Users\di_yu\workspace\lessCompiler\src\main\webapp\css\cons.css.dsp.src
[echo] rename done
trasition:
[echo] in trasition
BUILD FAILED
Target "precompile-templates" does not exist in the project "compile".
Total time: 4 seconds
As you can see, it says "precompile-templates" target is not exist. However, I didn't call this task at all. I just delete it from my build.xml and there are no other targets related to it. How does the error come? PS: I use eclipse's run as ANT to run this build.xml.
Did you change the target you want to run after you deleted the unnecessary targets from the file? It looks to me like the run configuration is still using the old target. Use
The problem is that you created a target "precompile-templates", you subsequently deleted it ... and Eclipse is "remembering" the now-obsolete target.
SUGGESTION:
1) "File > Save all", 2) "Project > Clean project" 3) "Run As, Ant build"
See if that works!
Actually, I found out the problem. I still use the old configuration to run the build.xml. The solution is like this:
right click on the build.xml
click 'run as...' then click the external configuration tool
delete the selected launch configurations.
Para aquel que le interese
buil.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="less.compile" default="css.concatenate" basedir=".">
<!-- compile LESS -->
<target name="css.concatenate">
<concat destfile="${basedir}/WebContent/cons/index.less">
<fileset dir="${basedir}/WebContent/less/import">
<include name="*.less"/>
</fileset>
</concat>
<echo>cons is done!</echo>
</target>
<target name="css.lessc">
<java classname="CpLess" fork="true">
<arg value="${basedir}/WebContent/cons"/><!-- output folder -->
<arg value="${basedir}/WebContent/less"/><!-- output folder -->
<classpath>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/commons- logging.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/js.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/lesscss-engine-1.3.3.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/yuicompressor-2.4.7.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zkjszips.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zkless.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zul.jar"/><!-- only needed if using _zkmixins.less -->
</classpath>
</java>
</target>
<target name="lessc">
<java classname="CpLess" fork="true">
<arg value="C:/WKSLuna000/PruebasZul/WebContent/lesssrc"/><!-- output folder -->
<arg value="C:/WKSLuna000/PruebasZul/WebContent/lessbuild"/><!-- output folder -->
<classpath>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/commons-logging.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/js.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/lesscss-engine-1.3.3.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/yuicompressor-2.4.7.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zkjszips.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zkless.jar"/>
<pathelement location="${basedir}/WebContent/WEB-INF/lib/zul.jar"/><!-- only needed if using _zkmixins.less -->
</classpath>
</java>
</target>
</project>
En la carpeta cons/
/zk/
_header.less
_zkminis.less
_skvariables.less
En la carpeta less/
/import/
0index.less
button.less
....
/zk/
_header.less
_zkminis.less
_skvariables.less
Archivo 0index.less:
#import "../bootstrap/less/variables.less";
#import "../bootstrap/less/mixins.less";
#import "zk/_header.less";
I have an ant build file for a java project the project tree looks like this :
DataBaseFidling.
|-->src (contains production code source)
|-->tests (contains tests code source)
|-->bin (contains .class)
|-->reports(contains junit xml reports)
|-->build.xml
Whenever I import this project with eclipse using "Java Project From Existing Ant Build File", eclipse does not reconize the tests folder as a source folder.
What to do to fix this?
Here is the ant build file :
The DatabaseFidling Project.
<property name="src.dir" location="./src/" />
<property name="tests.dir" location="./tests/" />
<property name="bin.dir" location="./bin/" />
<property name="lib.dir" location="/home/chedy/workspace/lib"/>
<target name="clean">
<delete verbose="true">
<fileset dir="${bin.dir}"/>
</delete>
</target>
<target name="compile">
<javac srcdir="${src.dir}" destdir="${bin.dir}">
</javac>
<javac srcdir="${tests.dir}" destdir="${bin.dir}">
<classpath>
<pathelement location="${lib.dir}/junit4.jar"/>
<pathelement location="${lib.dir}/mockito-all-1.9.5.jar"/>
<pathelement location="${lib.dir}/SQLScriptRunner.jar"/>
</classpath>
</javac>
</target>
<target name="test" depends="compile">
<junit printsummary="yes" fork="true" >
<formatter type="xml"/>
<classpath>
<pathelement path="${bin.dir}"/>
<pathelement location="${lib.dir}/junit4.jar"/>
<pathelement location="${lib.dir}/mockito-all-1.9.5.jar"/>
<pathelement location="${lib.dir}/SQLScriptRunner.jar"/>
<pathelement location="${lib.dir}/mysql-connector-java-5.1.23-bin.jar" />
</classpath>
<batchtest todir="./report">
<fileset dir="${bin.dir}">
<include name="**/**Test*.*"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="run" depends="compile">
<java classname="com.esprit.is.Main" fork="true">
<classpath>
<pathelement path="${bin.dir}"/>
<pathelement location="${lib.dir}/mysql-connector-java-5.1.23-bin.jar" />
</classpath>
</java>
</target>
</project>
You can manually add the test folder as a source folder. Right click the project, Build Path -> Configure Build Path -> Java Build Path. In the Source tab, click Link Source then browse to your folder.
The compile target had to contain one javac task which compiles both the src and test folders.
I am trying to write ant script for my project but at javac i am facing this issue:
80: package com.sun.xml.internal.fastinfoset.util does not exist
[javac] import com.sun.xml.internal.fastinfoset.util.StringArray;
[javac] ^
JAVA_HOME is set to jdk1.6
ANT_HOME is set to apache-ant-1.8.4
build file is
<?xml version="1.0" ?>
<project name="project" default="war">
<property name="location" location="D:\Project"></property>
<property name="project-location" location="${location}\project"></property>
<path id="Web App Libraries.libraryclasspath">
<fileset dir="${project-location}/web/WEB-INF/lib"/>
</path>
<path id="EAR Libraries.libraryclasspath"/>
<path id="compile.classpath">
<pathelement location="${project-location}/web/WEB-INF/classes"/>
<path refid="Web App Libraries.libraryclasspath"/>
<path refid="EAR Libraries.libraryclasspath"/>
</path>
<path id="Server Library [JBoss v4.2] (unbound).libraryclasspath"/>
<target name="init" >
<mkdir dir="D:/JBOSSHOME/build/classes"/>
<mkdir dir="D:/JBOSSHOME/dist" />
</target>
<target name="compile" depends="init" >
<javac destdir="D:/JBOSSHOME/build/classes" debug="true" srcdir="${project-location}/src">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="D:/JBOSSHOME/project.war" webxml="${project-location}/web/WEB-INF/web.xml">
<fileset dir="${project-location}/web"/>
<lib dir="${project-location}/web/WEB-INF/lib"/>
<classes dir="D:/JBOSSHOME/build/classes"/>
</war>
</target>
any help or pointer would be much appreciated ty!
com.sun.internal packages are NOT recommended to use , because
they are not guaranteed to be available across environments
support to those classes are also not guaranteed
i got a problem by executing groovy from an ant file.
In Eclipse with a launcher, everything works fine but wehn i run the ant file i got the following output:
Main.groovy: 71: unable to resolve class InitializeDatabase
[groovyc] # line 71, column 40. [groovyc] java.lang.Object
javaClassInstance = new InitializeDatabase()
[groovyc]
[groovyc] 1 error
InitializeDatabase is a java class in the same package..
public class InitializeDatabase {
public void test() {
System.out.println("Hello Groovy");
}
}
I guess the problem is located at the ant file:
<project name="tp" basedir="." default="dbsetup">
<target name="dbsetup">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar" />
</classpath>
</taskdef>
<delete dir="bin" />
<mkdir dir="bin" />
<groovyc srcdir="src" destdir="bin" />
<java classname="groovy.ui.GroovyMain" dir="../.." fork="true" failonerror="true">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar"/>
<pathelement location="bin"/>
</classpath>
<arg line="build/scripts/src/build/Main.groovy" />
</java>
</target>
</project>
Can someone help me please?
You need to include the javac task inside your groovyc one. Change:
<groovyc srcdir="src" destdir="bin" />
to
<groovyc srcdir="src" destdir="build">
<javac/>
</groovyc>
And it should work fine. As it says here:
Joint compilation means that the Groovy compilation will parse the
Groovy source files, create stubs for all of them, invoke the Java
compiler to compile the stubs along with Java sources, and then
continue compilation in the normal Groovy compiler way. This allows
mixing of Java and Groovy files without constraint.
...
The right way of working is, of course, to use a nested tag and all
the attributes and further nested tags as required.
Here is the final file which works great.
Thanks to tim_yates!
<target name="dbsetup">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar" />
</classpath>
</taskdef>
<delete dir="bin" />
<mkdir dir="bin" />
<groovyc srcdir="src" destdir="bin">
<javac source="1.6" target="1.6" debug="on" />
</groovyc>
<java classname="groovy.ui.GroovyMain" dir="../.." fork="true" failonerror="true">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar"/>
<pathelement location="bin"/>
</classpath>
<arg line="build/scripts/src/build/access/AccessDbSetup.groovy" />
</java>
</target>