Dependent ant task is executing before finishing the dependency task execution - java

I have written an ant script to build a plugin and publish feature as follows:
<project default="temp" name="build">
<target name="feature_export" depends="build-exility-Client">
<echo>inside feature_export</echo>
<pde.exportFeatures destination="C:\Users\akhilesh.kj\Desktop\Plugin" exportSource="false" exportType="directory" features="com.exility.exilant.feature" useJARFormat="true" />
</target>
<target name="temp" depends="feature_export">
<p2.publish.featuresAndBundles
metadataRepository="file:/d:/a"
artifactRepository="file:/d:/a"
publishArtifacts="true"
compress="true"
source="C:\Users\akhilesh.kj\Desktop\Plugin"/>
</target>
</project>
Here, first 'feature_export' is getting executed.But before completing the execution(exporting the plugin and feature) Task 'temp' get started.Since task 'temp' is using plugin and feature jar that is output of 'feature_export' task,So it is not giving result as expected.
All I want is that firstly, complete 'feature_export' task with proper output then start 'temp' task.
I tried with sleep and waitfor command but that does not work for me.
Please help!

This is a known limitation
Eclipse Bugtracker
It seems that they won't fix it.

Related

error while cleaning and building javafx app in netbeans, XML document structures must start and end within the same entity

I'm new to xml, and trying to deploy my javafx program, getting to run and clean I've got the following error, and couldn't find any answer regarding the solution thereof, so would appreciate if you helped me:
F:\IT\PROGRAMMING\LJPROJECTS\MyShutDownTheCompProgram\build.xml:67: XML document structures must start and end within the same entity.
The xml code goes as follows:
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="MyShutDownTheCompProgram" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<description>Builds, tests, and runs the project MyShutDownTheCompProgram.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. Those of them relevant for JavaFX project are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
-post-jfx-jar: called after FX SDK specific <fx:jar> task
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting a HTML postprocessor after javaFX SDK deployment:
<target name="-post-jfx-deploy">
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
<custompostprocess>
<fileset dir="${jfx.deployment.html}"/>
</custompostprocess>
</target>
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
<echo message="Calling jar task from JavaFX SDK"/>
<fx:jar ...>
...
</fx:jar>
</target>
For more details about JavaFX SDK Ant tasks go to
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
For list of available properties check the files
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
-->
<target name="-post-jfx-deploy">
<fx:deploy width="${javafx.run.width}" height="${javafx.run.height}"
nativeBundles="all"
outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}"
mainClass="${javafx.main.class}"/>
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}"
includes="*.jar"/>
</fx:resources>
<fx:info title="${application.title}"
vendor="${application.vendor}"/>
</fx:deploy>
</target>
You must have to end the tags you started before.
You have to use </project> at end of your XML file.
Open build.xml file from your Files tab. Usually there put two tags with the same name, and does the same job.The first one is <build> and the second is <defend> you should delete these extra two tags.

Execute Ant Script with Ant Tasks Programmatically

I have an Ant Script which uses Ant Task (I use this Task to execute QVTo Transformations).
The Ant Script is the following one:
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default" xmlns:qvto="http://www.eclipse.org/qvt/1.0.0/Operational">
<target name="default">
<taskdef name="http://www.eclipse.org/qvt/1.0.0/Operational:transformation" classname="org.eclipse.m2m.internal.qvt.oml.runtime.ant.QvtoAntTransformationTask">
<classpath>
<pathelement location="${basedir}/libAnt/antTasks.jar"/>
</classpath>
</taskdef>
<qvto:transformation uri="platform:/resource/QVToTransformation/transforms/QVTTransformation.qvto">
<in uri="platform:/resource/QVToTransformation/In/In.ecp" />
<out uri="platform:/resource/QVToTransformation/Out/Out.uml" />
<trace uri="platform:/resource/QVToTransformation/Trace/trace.qvtotrace"
generate="true" incrementalUpdate="false" />
</qvto:transformation>
</target>
</project>
The code I use in Java to execute Ant Script is the following one:
File AntFile = new File(this.getClass().getResource("qvto/AntQVTo.xml").getFile());
Project p = new Project();
p.setUserProperty(
"ant.file",
this.getClass().getResource("qvto/AntQVTo.xml").getFile()
);
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, AntFile);
p.executeTarget(p.getDefaultTarget());
The problem when I run my Java code is that it seems that Ant Task is not recognized at all, when I run the following error is returned:
Exception in thread "AWT-EventQueue-0" C:\path\to\AntTask\AntQVTo.xml:5: Problem: failed to create task or type http://www.eclipse.org/qvt/1.0.0/Operational:transformation
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
I don't have any problem if I execute my Ant Script directly in Eclipse, as this Task is by default defined in the Eclipse Preferences, into Ant->Runtime->Tasks.
The problem could be that Ant Script executed within Java Code isn't run as "Run in the same JRE as project".
I have that Ant Task defined in the plugin.xml which runs the Eclipse Application in the classpath, and also as an extension:
<extension point="org.eclipse.ant.core.antTasks">
<antTask
class="org.eclipse.m2m.internal.qvt.oml.runtime.ant.QvtoAntTransformationTask"
eclipseRuntime="true"
headless="true"
library="libAnt/antTasks.jar"
name="transformation"
uri="http://www.eclipse.org/qvt/1.0.0/Operational"
/>
</extension>
Does anyone know how could I fix my issue?
Thanks in advance and regards.
missing Apache IVY library, Download this library from here - apache and Copy the jar in your ant lib directory and add into class path.
Download the jar and install Ant (e.g., C:\Apps\Tools\apache-ant-1.9).
Download the jar and extract Ivy (e.g., C:\Users\UserName\Downloads\apache-ivy-2.4)
Copy C:\Users\UserName\Downloads\apache-ivy-2.4\ivy-2.4.jar into C:\Apps\Tools\apache-ant-1.9\lib.
Can you try changing
From:
<taskdef name="http://www.eclipse.org/qvt/1.0.0/Operational:transformation" classname="org.eclipse.m2m.internal.qvt.oml.runtime.ant.QvtoAntTransformationTask">
To:
<taskdef name="transformation" classname="org.eclipse.m2m.internal.qvt.oml.runtime.ant.QvtoAntTransformationTask">
And remove the namespace prefix to transformation task/element.

Failed due to exception from main class in others computers

i developed a JavaFX application and i deployed as .exe , and when i install at my computer everything works fine. but after i install .exe to another computer and i try to open app , it shows me an error:
Failed due to Exception from main class.
Can someone please help me with this error?
build.fxml
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="Main" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<description>Builds, tests, and runs the project Main.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. Those of them relevant for JavaFX project are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
-post-jfx-jar: called after FX SDK specific <fx:jar> task
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting a HTML postprocessor after javaFX SDK deployment:
<target name="-post-jfx-deploy">
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
<custompostprocess>
<fileset dir="${jfx.deployment.html}"/>
</custompostprocess>
</target>
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
<echo message="Calling jar task from JavaFX SDK"/>
<fx:jar ...>
...
</fx:jar>
</target>
For more details about JavaFX SDK Ant tasks go to
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
For list of available properties check the files
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
-->
</project>
I also tried to change build.fxml to this but still the same:
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="AutoMekanikAdmin" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<description>Builds, tests, and runs the project AutoMekanikAdmin.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. Those of them relevant for JavaFX project are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
-post-jfx-jar: called after FX SDK specific <fx:jar> task
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting a HTML postprocessor after javaFX SDK deployment:
<target name="-post-jfx-deploy">
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
<custompostprocess>
<fileset dir="${jfx.deployment.html}"/>
</custompostprocess>
</target>
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
<echo message="Calling jar task from JavaFX SDK"/>
<fx:jar ...>
...
</fx:jar>
</target>
For more details about JavaFX SDK Ant tasks go to
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
For list of available properties check the files
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
-->
<target name="post-jfx-deploy">
<fx:deploy verbose="true" nativeBundles="exe" outdir="${basedir}/${dist.dir}" outfile="${application.title}">
<fx:application name="${application.title}" mainClass="${javafx.main.class}" />
<fx:resources>
<fx:fileset dir="${basedir}/${dist.dir}" include="*.jar"/>
<fx:fileset dir="${basedir}/${dist.dir}" include=";ib/*.jar"/>
</fx:resources>
<fx:info title="${application.title}" vendor="${application.vendor}" />
<fx:info>
<fx:icon href="${basedir}/icon.ico"></fx:icon>
</fx:info>
<fx:preferences shortcut="true" />
</fx:deploy>
</target>
did you use any VM parameters while building? This SE post comes up when searching the error:JavaFX failed due to exception in main class.
try running the executable and the jar from the console, for debugging:
What is the exception? Try running the executable from the console and try running the executable jar from the console with java -jar . And post the results as part of your question.
running from console
This is java problem. If you don't add java to your exe bundle, then application use system java. You can add java to your exe bundle. Then, application use that java. If you use to create exe with ant then add this parameter in build.xml;
<javac includeantruntime="false" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="Cp1252">
<classpath>
<fileset dir="build/libs">
<include name="*"/>
</fileset>
</classpath>
</javac>
The problem was that these other computers didnt had JavaJDK installed , but they had only JavaJRE. So i executed jar file from CMD java -jar , and while it was executed it created database tables , that it should to .

How to compile and build C++ projects with Ant?

I have several Java components all are built by Ant, however I would like to add one more component (written in C++) and compile/build it in Ant as well.
Is there a tutorial which I can follow or a short way to achieve this?
Thanks in advance.
Call make as ant exec task
You can pass env variables to the make
<exec executable="make" dir="${cpp.project.dir}">
<env key="KEY" value="VALUE"/>
</exec>
Ant is ancient, but you still can do this with a lot of pain.
I would recommend to use modern build system Gradle which has C++ support as well. You can find tutorials on their web-site.
It seems like you are not the first trying to accomplish this kind of task:
Building C++ projects with ANT
Axis C++ ANT Build Guide
cpptasks for Apache Ant
Use this:
<?xml version="1.0"?>
<project name="hello" default="compile">
<taskdef resource="cpptasks.tasks"/>
<target name="compile">
<cc outfile="main" objdir="obj" outtype="executable">
<fileset dir="./" includes="*.cpp"/>
<compiler id="Linuxgcc" name="g++">
<compilerarg value="-fPIC"/>
</compiler>
<linker id="LinuxLinker" name="g++" libtool="true">
<linkerarg value="-g" if="debug"/>
<linkerarg value="-fPIC"/>
<libset libs="stdc++"/>
</linker>
</cc>
</target>
</project>
Make sure you place cpptasks.jar(http://www.java2s.com/Code/Jar/c/Downloadcpptasksjar.htm) in your ant's lib folder

Cannot execute <sequential> task with Ant

Since I updated my Java from JDK7u55 to JDK7u60, I am facing an issue while running my build. I am using Ant 1.6.5 on Windows Server 2003 Standard Edition. Below is the Ant task which causes a problem.
<!-- RUN JUNIT TASK -->
<target name="run_junit" description="Runs all JUnit tests in another JVM">
<sequential>
<move file="${MyProject}\bin\myApp.jar" tofile="${MyProject}\bin\myApp_original.jar"/>
<move file="${MyProject}\bin\myApp_test.jar" tofile="${MyProject}\bin\myApp.jar"/>
<exec executable="WinTail" spawn="true">
<arg value="${MyProject}\junit.log"/>
</exec>
<java classname="myProject.test.AllTests"
maxmemory="256m"
fork="true"
output="${MyProject}\junit.log"
dir="${MyProject}\bin"
append="true">
<jvmarg value="-Djdk.lang.Process.allowAmbigousCommands=true"/>
<arg value="${MyProject}\bin"/>
<classpath>
<fileset dir="${MyProject}\bin">
<include name="myApp.jar"/>
</fileset>
<pathelement path="${MyProject}\bin"/>
</classpath>
</java>
<move file="${MyProject}\bin\myApp.jar" tofile="${MyProject}\bin\myApp_test.jar"/>
<move file="${MyProject}\bin\myApp_original.jar" tofile="${MyProject}\bin\myApp.jar"/>
</sequential>
</target>
Once two JARs have been renamed, I start running all the tests using <java> task. The AllTests.java uses seperate thread to run each test. There are some tests which takes bit longer to finish and some actually don't respond. I used to kill them manually by using ProcessExplorer. Once that was done it used to execute next command which renames back the JARs to their original names. It used to work when I was using JDK7u55.
Now since I upgraded Java to JDK7u60, instead of waiting for all the tests to be finished, the last two <move> commands are attempted. This causes the build failure as <move> caanot proceed because the underlying JAR files are being used by the test classes. I get below error:
BUILD FAILED
C:\MyProject\build.xml:579: Unable to delete file C:\MyProject\bin\myApp.jar
I am wondering what has changed in JDK7u60 which caused this behavior. I checked the Release Notes of JDK7u60 but didn't get anything. Can someone please shed some light on this?
Firstly on windows it's not uncommon for files belonging to another process or thread to prevent the deletion of a file.
Secondly what exactly is the purpose of the sequential task in your ANT target? The documentation describes the tasks as follows:
Sequential is a container task - it can contain other Apache Ant
tasks. The nested tasks are simply executed in sequence. Sequential's
primary use is to support the sequential execution of a subset of
tasks within the parallel task
In your case there's no use of parallel...
Why don't you try to remove the sequential task and see if that fixes the problem.

Categories

Resources