acceleoCompiler not showing output in console output with ant - eclipse

I am using acceleoCompiler inside an ant script and when i run the ant script everything shows an output except acceleoCompiler.
For instance, [javac] and [mkdir] shows up. But nothing relating to acceleoCompiler shows up. Am i doing something wrong?
The ant script:
<eclipse.refreshLocal resource="${F_FOLDER}/bin/" depth="infinite"/>
<eclipse.refreshLocal resource="${FE_FOLDER}/bin/" depth="infinite"/>
<mkdir dir="${F_OUTPUT}"/>
<mkdir dir="${FE_OUTPUT}"/>
<javac
srcdir="${F_SRC}generator/"
destdir="${FR_OUTPUT}"
executable="${JAVA_JDK}/javac"
fork="true"
includeantruntime="false"
failonerror="false"
/>
<javac
srcdir="${FE_SRC}generator/"
destdir="${FE_OUTPUT}"
executable="${JAVA_JDK}/javac"
fork="true"
includeantruntime="false"
failonerror="false"
/>
<acceleoCompiler sourceFolder="${F_SRC}"
outputFolder="${F_OUTPUT}"
dependencies=""
binaryResource="true"
packagesToRegister="org.eclipse.emf.ecore.EcorePackage">
</acceleoCompiler>
<acceleoCompiler sourceFolder="${F_SRC}"
outputFolder="${FE_OUTPUT}"
dependencies=""
binaryResource="true"
packagesToRegister="org.eclipse.emf.ecore.EcorePackage">
</acceleoCompiler>

The absence of logging messages doesn't mean you're doing anything wrong. If you look at the source for mkdir or javac you'll see that they call the Ant Task method log() in most cases. The Acceleo Ant task however only calls log() if it finds a problem - if all is well it is silent and enigmatic.
References:
Ant mkdir task source.
AcceleoCompiler source via the Acceleo wiki FAQ.

Related

When using ant in eclipse, standard input does not work?

In demo.Main.main method I do
System.in.read()
In build.xml there is the target
<target name="run">
<java classname="demo.Main" fork="false">
<classpath refid="classpath" />
</java>
</target>
When I go to Eclipse's Console and I give something in , System.in.read() does not see it.
Ant does not support System.in.read().
Use the Ant task <input> for user input instead.

Using eclipse in order to find the opencv native library doesn't work

I'm attempting to use opencv on an ubuntu installation and am following this tutorial. Everything seemed fine and it even listed amongst the installed parts so I proceeded into this tutorial. This went well up until the moment where you have to add opencv as a user library as it was not amongst the (completely empty) list of libraries found. I have looked throughout the opencv folder and can't find anything like a library either am I missing something? Any idea on how to fix this?
Note that it did manage to produce .jar file however the library is still missing. If it matters opencv is installed in usr/local/src.
If in order fix this you require any extra information feel free to ask in the comments.
This might have something to do with the problem:
ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
thijs#thijs-ulap:/usr/local/src/opencv-2.4.8/opencv/build/bin$ ant -DocvJarDir=path/to/dir/containing/opencv-248.jar -DocvLibDir=/usr/local/src/opencv-2.4.8/opencv/build/bin /opencv_java248/native/library
Buildfile: /usr/local/src/opencv-2.4.8/opencv/build/bin/build.xml
BUILD FAILED
Target "/opencv_java248/native/library" does not exist in the project "SimpleSample".
Total time: 0 seconds
This is my build.xml:
<property name="src.dir" value="src"/>
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="${ant.project.name}"/>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<sysproperty key="java.library.path" path="${ocvLibDir}"/>
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>
<target name="rebuild" depends="clean,jar"/>
<target name="rebuild-run" depends="clean,run"/>
running
ulap:/usr/local/src/opencv-2.4.8/opencv/samples/java/ant$ ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
gave me:
clean:
compile:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
[javac] Compiling 1 source file to /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/classes
jar:
[mkdir] Created dir: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar
[jar] Building jar: /usr/local/src/opencv-2.4.8/opencv/samples/java/ant/build/jar/SimpleSample.jar
run:
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java248 in java.library.path
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
[java] at java.lang.Runtime.loadLibrary0(Runtime.java:844)
[java] at java.lang.System.loadLibrary(System.java:1051)
[java] at SimpleSample.<clinit>(Unknown Source)
[java] Could not find the main class: SimpleSample. Program will exit.
[java] Java Result: 1
rebuild-run:
BUILD SUCCESSFUL
Total time: 1 second
According to the first tutorial (how to build OpenCV from source), the result should be a JAR file and a .so native lib in the bin/ directory of your OpenCV directory. In the "SETTING UP ECLIPSE FOR USING OPENCV (JAVA) IN UBUNTU" tutorial, you must create the User Library by following the steps in the tutorial. That process involves browsing your file system to select the OpenCV JAR that was produced by the first tutorial and then selecting the .so file as the native library. Eclipse will not automatically "find" your OpenCV library, you have to configure it to know about it, that's what the second tutorial is doing.
I think you were running the wrong command with ant. You can read the manual here: https://ant.apache.org/manual/running.html
Below is the format to run ant:
ant [options] [target [target2 [target3] ...]]
So maybe your command line should look like:
ant -DocvJarDir=/usr/local/src/opencv-2.4.8/opencv/build/bin rebuild-run
given that /usr/local/src/opencv-2.4.8/opencv/build/bin contains the opencv-248.jar
As shown on your build.xml file that the property ocvJarDir is pointing to the location of the classpath requires to build the project:
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
And you need to specify the target "rebuild-run" in the command line since your build.xml does not have a default target specified.
Try installing 2.4.6 version. I have similar problems when installing in VS. Older version worked. Maybe it's the same in Eclipse, too.

Unable to deploy JavaFX applicaiton with external libraries in a JAR

I'm developing a JavaFX application in Eclipse. The app has external libraries, like log4j and others and runs perfectly from Eclipse. I've tried deploying it from Eclipse as a Runnable jar through the Eclipse built-in feature, and it runs well on some computers, while on others it would give me an obscure Undefined Link error. After digging around it seems JavaFX needs to be specially packaged either through an ANT script or through the javafxpackager application.
For the life of me I can't seem to deploy a runnable jar through either of those methods. Trying either of those methods, I get an Exception. Things I've tried:
Build the JavaFX application through an ANT script, below is a snippet of the relevant parts of the build script
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${javafx.sdk.path}/jre/lib" includes="jfxrt.jar"/>
</path>
<target name="compile" depends="clean">
<echo>Compiling the source</echo>
<mkdir dir="${classes.dir}"/>
<!-- Copy over the misc files into the classes dir -->
<copy todir="${classes.dir}/bundles">
<fileset dir="${src.dir}/bundles"/>
</copy>
<copy todir="${classes.dir}/css">
<fileset dir="${src.dir}/css"/>
</copy>
<copy todir="${classes.dir}/img">
<fileset dir="${src.dir}/img"/>
</copy>
<copy todir="${classes.dir}/views">
<fileset dir="${src.dir}/views"/>
</copy>
<copy todir="${classes.dir}/bundles">
<fileset dir="${src.dir}/bundles"/>
</copy>
<copy file="${src.dir}/log4j2.xml" todir="${classes.dir}"/>
<javac target="1.7" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" debug="on">
</javac>
</target>
<target name="jar" depends="compile">
<echo>Creating the main jar file</echo>
<mkdir dir="${distro.dir}" />
<fx:jar destfile="${distro.dir}/main.jar" verbose="true">
<fx:platform javafx="2.1+" j2se="7.0"/>
<fx:application mainClass="${main.class}"/>
<!-- What to include into result jar file?
Everything in the build tree-->
<fileset dir="${classes.dir}"/>
<!-- Define what auxilary resources are needed
These files will go into the manifest file,
where the classpath is defined -->
<fx:resources>
<fx:fileset dir="${distro.dir}" includes="main.jar"/>
<fx:fileset dir="." includes="${lib.dir}/**" type="jar"/>
<fx:fileset dir="." includes="."/>
</fx:resources>
<!-- Make some updates to the Manifest file -->
<manifest>
<attribute name="Implementation-Vendor" value="${app.vendor}"/>
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Class-Path" value="${lib.dir}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
</fx:jar>
</target>
Compiling/generating the jar through the ant script, I get a window pop up for half a second and "Exception in Application start method" in the console, with no stack trace. I've tried runnning java with the -XX:-OmitStackTraceInFastThrow flag, but it still won't give me a stack trace.
Running through javafxpackager gives the following error:
RenderJob.run: internal exception
java.lang.UnsatisfiedLinkError: com.sun.prism.d3d.D3DContext.nSetBlendEnabled(JZ
Z)I
at com.sun.prism.d3d.D3DContext.nSetBlendEnabled(Native Method)
at com.sun.prism.d3d.D3DContext.initState(D3DContext.java:84)
at com.sun.prism.d3d.D3DResourceFactory.(D3DResourceFactory.java:5
7)
at com.sun.prism.d3d.D3DPipeline.createResourceFactory(D3DPipeline.java:
147)
at com.sun.prism.d3d.D3DPipeline.getD3DResourceFactory(D3DPipeline.java:
153)
at com.sun.prism.d3d.D3DPipeline.findDefaultResourceFactory(D3DPipeline.
java:179)
at com.sun.prism.d3d.D3DPipeline.getDefaultResourceFactory(D3DPipeline.j
ava:201)
at com.sun.prism.GraphicsPipeline.getDefaultResourceFactory(GraphicsPipe
line.java:97)
at com.sun.javafx.tk.quantum.QuantumRenderer$3.run(QuantumRenderer.java:
143)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at com.sun.prism.render.RenderJob.run(RenderJob.java:37)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Quantu
mRenderer.java:98)
at java.lang.Thread.run(Thread.java:724)
You can deploy your application using javafxpackager. If you deploy a self contained application, the Java Runtime Environment will be bundled with your application and it will run on any machine whether the right version of Java is installed or not.
(You should have javafxpackager in your jdk directory under the bin folder.)
Look for your compiled files (.class) in your eclipse workspace folder. They should be in the bin directory.
Create a createjar folder and inside it create a classes and a out folder. Copy all of your .class files in the classes folder. Also include in the classes folder all jar needed by your application.
Now on the command line go inside the createjar directory and run this command :
"C:\path\to\jdk\jdk1.7.0_25\bin\javafxpackager.exe" -createjar -appclass package.MainClass -srcdir classes -outdir out -outfile NameOfYourJar -classpath "" -v
This should create a runnable jar in the out directory. You will need it for the next step.
Now create a deploy folder alongside the createjar folder.
Inside the deploy folder make to other directories dist and packages.
In the dist folder copy your freshly created jar from above plus all the dependencies/ressources it will need.
Go back on the command line (if you ever left it) and go in the deploy directory. Run the following command from there :
"C:\path\to\jdk\jdk1.7.0_25\bin\javafxpackager.exe" -deploy -native -outdir packages -outfile NameOfYourApp -srcdir dist -srcfiles NameOfYourJar.jar -appclass package.MainClass -name "Name of You Application" -title "Title of your application"
Once it is done it should have created all you need to deploy your app including native .exe file to run on Windows platform. This is the self contained application ! To be able to run it you need to go into bundles\NameOfYourApp\app and paste here all dependencies/ressource your app needs.
At last, double click on YourApp.exe and it should run even on machines without Java installed.
With ant files you have two main options: <fx:jar> and <fx:deploy>. The former just produces a jar that allows you to refer to your dependencies if they are in the same file as the jar. You can unpack the jar and look at the MANIFEST file produced to see how they are added to the javafx classpath.
<fx:deploy> allows you to pull in dependencies, but requires that you build a platform-specific installer. It can't be done using a jar. Apparently NetBeans allows you to create a stand-alone jar but I have not tested with that.
you do not package javafxrt.jar with your app
e(fx)clipse would have produced the ant-script for your if you use it

Setup Netbeans project on Jenkins

I have a Netbeans Project that I'm trying to build from Jenkins, using ant, in a linux environment.
I have copied the CopyLibStack.jar to /var/lib/Jenkins/nblibs/ and setup in the ant task with the following properties:
-Dj2ee.server.home="/var/lib/jenkins/tomcat/"
-Dlibs.CopyLibs.classpath=/var/lib/jenkins/nblibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
But it doesn’t work; it fails on a <copyfiles> task
If I install Jenkins on windows and set the properties to:
-Dj2ee.server.home="C:\Archivos de programa\Apache Software Foundation\Tomcat 6.0"
-Dlibs.CopyLibs.classpath=C:\\.jenkins\\nblibs\\org-netbeans-modules-java-j2seproject-copylibstask.jar
The project build without problems
If I run the ant task from the terminal with:
ant -file build.xml do-dist test -Dlibs.CopyLibs.classpath="/var/lib/jenkins/nblibs/copylibstask.jar" -Dj2ee.server.home="/var/lib/jenkins/tomcat/"
it builds fine too
I think that the problem is in the user jenkins, but I don't know how to fix it.
What can I do?
I had the same problem, which I have fixed :) (I'm using ubuntu 12.04). Find build.properties in ".netbeans/7.0" and look for the lib that you are missing... copy it to project.properties
Ex:
libs.CopyLibs.classpath=/opt/netbeans-7.0.1/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.javaee-api-6.0.classpath=/opt/netbeans-7.0.1/enterprise/modules/ext/javaee-api-6.0.jar
I found a recipe in this link basically you have to have Netbeans installed on your server so you can reuse the build.xml generated by Netbeans.
Create a file jenkins-build.xml at the same level as your build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="BioGatewayWS Stub" default="build" basedir=".">
<!-- create private folders -->
<mkdir dir="nbproject/private"/>
<!--- set variables needed by Ant when outside of Netbeans -->
<propertyfile file="nbproject/private/private.properties">
<!--<entry key="user.properties.file" value="/opt/NetBeans8/build.properties"/>-->
<entry key="user.properties.file" value="C:\Users\jm\AppData\Roaming\NetBeans\8.2\build.properties"/>
</propertyfile>
<!-- Build targets - these just chain a call to the original build file-->
<target name="build">
<!-- <ant dir="${basedir}" target="build"/>-->
<ant dir="${basedir}" target="default"/>
</target>
<target name="clean">
<ant dir="${basedir}" target="clean"/>
</target>
</project>
and run Ant:
ant -file jenkins-build.xml clean
ant -file jenkins-build.xml build
Thanks to the original author matt

Ant script stops executing targets after the target build-war-deploy of a gwt project

I have an ant script which does in the beginning some checks and then compiles the code and deploys it to the tomcat server. The script for the build-war-deploy process looks like this:
<target name="build-war-deploy" depends="clean-up,gwtc,check-settings" description="Package GWT app to web archive and deploy to web server">
<war basedir="${war.dir}" destfile="${deploy.dir}/${app.name}.war" webxml="${webinf.dir}/web.xml">
<!-- <include name="WEB-INF/**" /> -->
<webinf dir="${webinf.dir}/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
This target works perfectly fine, meaning after running the ant script the application is indeed deployed on tomcat.
After the build-war-deploy target I need to do some cleanup processes and therefore I created some other targets and added an dependency to the build-war-deploy target so that it is being executed afterwards.
<target name="cleanup" depends="build-war-deploy" description="clean up processes">
<exec dir="./" executable="python" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
</target>
However, after the ant script executes the build-war-deploy target it stops and says that the build was successful. Does anyone know why it did not perform the last target?
build-war-deploy:
[war] Building war: C:\Apache Tomcat\apache-tomcat-6.0.33\webapps\test.war
BUILD SUCCESSFUL
Total time: 2 minutes 22 seconds
I would try using an outputproperty. Perhaps the python file is executing -- not doing what you want but executing and returning the results which you never see. I mean if the python script returns an error message, doesn't ant view that as successfully executing?
Something like:
<exec dir="./" executable="python" outputproperty="outProp" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
<echo>${outProp}</echo>
outputproperty: The name of a property in which the output of the command should be stored. Unless the error stream is redirected to a separate file or stream, this property will include the error output.