In my ant build I am including a second ant build file (build.xml):
<project name="Including" default="echoC" basedir=".">
<include file="build.xml" as="Included"/>
<target name="echoC" depends="Included.echoB">
<echo>C</echo>
</target>
</project>
build.xml is in the same directory as the including build file and everything is working fine actually. I can run the target echoC and also the target echoB from the included build file is executed first.
What is irritating however is that Eclipse is displaying the error message Target Included.echoB does not exist in this project in the Ant Editor. Does anybody know how to get rid of that?
Thanks a lot for your support!
This seems a bug in Eclipse according to https://bugs.eclipse.org/bugs/show_bug.cgi?id=412809. The comments suggest there is no support for the task in the editor.
Using the import task instead works fine.
Related
I've build an osgi plug-in to wrap a jar files. I've been following this guide.
In the last step, I can´t “Build all” to generate the update site because an error said that couldn't find the ant classpath
Any idea?
Thanks
The version that i'm using is Release 9.0.1FP9
Revision 20170815.0729-FP9 (Release 9.0.1FP9)
Try running Ant on the command line to see the full output. Here is a GitHub project showing specifically how to run Ant tasks for Domino.
Here also are some details about setting the Ant classpath for a given build in build.xml:
<!-- create our ant classpath using the fileset task -->
<path id="class.path">
<!-- include all jars in the lib directory and all sub-directories -->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
I find that Eclipse plugins often just assemble and execute terminal commands, but when they fail they tend not to be great at making clear the cause. Often, running the equivalent commands in the terminal (be they ant, maven, etc.) is clearer when failures occur because you'll see the full error output. And it gives you the added benefit--sometimes--of having a clearer understanding of what's happening under the hood.
I'm trying to set up a project to run junit tests at build time, so that every member of the team and the Jenkins build server runs the tests when it builds.
I believe we have set up a fairly standard webproject in Netbeans, but I can't seem to find anyone solving this problem on stackoverflow or google.
How would you go about doing this?
Go to file: /nbproject/build-impl.xml and fidn the dist target. It should look like this:
<target depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>
Copy paste it into /build.xml, and add the "test" target into it:
<target depends="init,compile,test,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>
This was in Netbeans 7.3. It now builds and runs the tests on every build, also on the Jenkins build server.
Never modify your build-impl.xml! Netbeans regenerates this file when you perform any changes to your project.
The better approach would be to modify your build.xml and add a post-jar task:
<target name="-post-jar" depends="test"/>
Windows 7 Professional
Eclipse 3.7.2
I am migrating over to Eclipse from another IDE. I am compiling my project with the same ANT build.xml file I was using before. I do it by
highlighting my project in the project view
expanding the tree node
finding my build.xml file there
right clicking my build.xml file
choosing Run as > Ant Build
Works great, but every few builds Eclpise eats my log4j.properties file located at:
C:\AllProjects\Workspace\acme\war\WEB-INF\classes\log4j.properties
Eclipse basically eats all files in WEB-INF\classes that are not *.class files.
What am I doing to make this happen and how can I stop it?
Thanks
Since you're using ant instead of Eclipse to build, you could try turning off the setting to build the project automatically.
Select your project, then in the menu bar at the top of the screen, select Project and uncheck the Build Automatically option.
Edit: Second opinion
I would add an ant task to copy the log4j property file into your WEB-INF/classes folder every time you do a build. One nice advantage of this is that you can have a different property file for different build types (debug, release, etc.) and not worry about manually making changes to it. Also, this should make it easier to manage if you're using version control.
Copy your log4j.properties file to your source directory and add something like this to your ant build file:
<target name="copy-log4j-property-file">
<copy file="src/log4j.properties" todir="WEB-INF/classes" />
</target>
<target name="build" depends="copy-log4j-property-file">
<!-- the rest of your build things here -->
</target>
After selecting in Project explorer:
Properties > Java Compiler > Building > Output Folder
Uncheck "Scrub output folders when cleaning projects"
It is a solution for me ( though maybe not everyone ) because I use a time test ANT build.xml to do my compiling, building and cleaning for me. I just leave Eclipse's auto builds on so I get those nice error notifications as a I type, before I compile.
I am trying to get ANT to create an HTML report of a JUNIT test in Eclipse but after I created the ANT build I get the following errors when I run it:
[junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900
[junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
What do I need to do to fix this?
Here are the sections of my Build.xml I am trying to run:
<target name="Home">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="Home" todir="${junit.output.dir}"/>
<classpath refid="Home.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
When I got this error I had to right click on my build.xml file in Eclipse, choose the "Run as Ant build..." option (3rd one in the menu) then click the JRE tab and select the "Run in the same JRE as the workspace" option and then proceeded to run the script. For some reason this fixed the problem. I honestly don't know why.
The Eclipse Bug is clearly documented Bug 384757. The analysis suggests that Oracle introduced the bug. I need Java version 7 but JunitReport needs Java version 5 and early versions of Java version 6. The obvious way is to add the "bootclasspath" argument to the Ant junitreport task while the Java problem is fixed by Oracle in a future release. Unfortunately Ant task junitreport does not support the bootclasspath option. Is this something the people supporting Ant could do?
I met this situation while running my java program on Ubuntu 12.04 with *java 1.7.0_51* on Eclipse SDK Juno. I take Bhagyaraj's suggestion which is using apache-ant-1.9.2 instead.
(p.s. The default ant version of Eclipse Juno is *org.apache.ant_1.8.3*, and I use apache-ant-1.9.3)
You may following my steps to setup.
Download apache-ant-1.9.3-bin.zip and extract to a place where you want.
Open your eclipse and choose Window --> Preferences
You can see the Preferences window. On the left hand side please choose ant --> runtime
Now focus on right hand-site of the window. Make sure you are now on Classpath tab and choose Ant Home Entries(Default).The buttons on the right which is Ant Home... is now click-able.
No doubt, click on Ant Home... button and choose the folder where your ant-1.9.3 is. In this step, if you choose wrong folder, Eclipse may show the error message something like Specified Ant home does not contain a "lib" directory. If you choose the right directory, Ant Home Entries(Default) will become **Ant Home Entries()
Don't forget to click apply.
After change those, while you right click on build.xml file and choose Run --> 1 Ant Build, the error message won't show because your ant is now 1.9.3.
I also download apache-ant-1.8.4 to run my build file, but the error can't be solved.
I used the jdk1.6.45 and latest apache-ant-1.9.2-bin\
Problem solved.
As per note on MikeBach
This is bug#,
please read:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757
Fixed in Ant.
Regards,
Bhagyaraj
If you are using Eclipse/JUnit report with JDK 1.7, please use JDK 1.6. There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe. This may be a similar report: https://netbeans.org/bugzilla/show_bug.cgi?id=201022
I've tried using a few different JRE/JDK settings (all 1.6 and 1.7) with various problems (this or lack of access to XSL file in jar) for each.
It's not a perfect solution obviously but I don't seem to run into these issues if the JUnit report is "raw" in the buildfile -- not wrapped in a target.
Poor workaround obviously in that targets are an important aspect of Ant but sometimes for reporting build targets/dependencies aren't so mission critical. It's not so much of an issue for me yet because I'm running these reports in kindof a one-off fashion rather than as part of a build.
The Bug was introduced in Java 7u5 according to this comment.
Another comment explains how to workaround it, changing the bootclasspath. (DISCLAIMER: I didn't try and test this.)
This solution, however, worked fine for me:
Download ant-1.9.4
Eclipse>>Preferences>>Ant>>Runtime>>AntHomeEntries
Remove all 1.8.x classpath entries
Add all libs from 1.9.4 instead
According to Ant Changes, this has been fixed since 1.9.1
Hey guys, I have a j2ee app which I am building with Netbeans. My task is to modify the build.xml so that after the app builds, ANT deploys the app to a server, runs Junit tasks on the app, and then un-deploys the app. So far I have the deploy and un-deploy working but I'm running into some trouble running the junit tasks.
I have a client project in Netbeans where my junit tasks lie. My trouble is that when this project is built, it doesn't compile my junit tests into the .jar. This causes problems when I run my ant junit tasks and ANT cannot find the appropriate .class files for the junit tests.
In the Netbeans Project Properties it allows me to set "Source Package Folders" and "Test Package Folders". If I add the "test" folder into the "Source Package Folders" and build the project it compiles the tests and includes them with the jar. This works, however it prevents me from running my junit tests as tests in netbeans which slows development.
Has anyone had any experience with solving such a problem? There may be a simple solution I am overlooking so if anyone has a word of advice I would appreciate it. Thanks in advance.
-Brad
If I understand what you're asking,
You shouldn't need to compile the test classes into the jar. Just compile them into some directory, say 'classes'. Then just include this directory in the fileset nested element for the junit task.
A simple example,
<target name="junit">
<junit printsummary="true">
<classpath>
<pathelement location="${classes.dir}"/>
</classpath>
<test name="test.class.TestClass"/>
</junit>
</target>
Had to point my junit task to the correct classpath. Was pointing to the exact directory of the .class files(project1/classes/com/blah/blah2/blah3) which is incorrect. Set classpath to project1/classes and it worked. Noob mistake.