I am using Eclipse's Ant view to run my build files. I have to run a couple of files in a specific order and I wonder whether there is any possibility to automate this (I'm sure there is...). However, they need to run subsequently, i.e. script two may not start until script one finished successfully. Most of my Ant scripts trigger Maven commands.
Is there any Eclipse plugin or feature that can assist me in running my Ant files automatically? Maybe even shutdown and restart my Java EE server before and after building?
I'd like to double-click just once and have my toolchain work, while I... get myself another cup of coffee.
I can think of two options:
Write a wrapper Ant script/target that calls the others in the desired order. It's been a number of years since I wrote any Ant but I remember doing that, probably using the <ant> task. It might make sense to simply define a target that has dependencies/prerequisites in the right sequence (in conjunction with the <import> task to pull in the separate buildfiles). Here is a discussion about the difference between these two approaches.
Use Eclipse's External Tool feature to invoke a batch/shell script that calls each Ant target.
This is what I finally came up with:
<project default="all" basedir=".." name="Build all projects">
<property name="folder.project.a" value="MyProjectA" />
<property name="folder.project.b" value="MyOtherProjectB" />
<!-- Target to build all projects -->
<target name="all" depends="projectA, projectB" />
<target name="projectA">
<echo>Building project A.</echo>
<ant antfile="${folder.project.a}/my_build_file.xml" />
</target>
<target name="projectB">
<echo>Building project B.</echo>
<ant antfile="${folder.project.b}/my_other_build_file.xml" />
</target>
</project>
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.
When faced with the unenviable task of cleaning all generated project artefacts/resources in a stock-standard Java EE/Tomcat configuration, I generally do one (or all) of 3 things:
Project/Clean
Right-click my server, and delete any artefacts (can't remember the exact command)
Source/Clean
I'm now playing around with the Google Eclipse Plugin for Appengine, which uses an inbuilt Jetty server.
Firstly, the plugin doesn't have any options to clean out generated class files before redeploying (well, not that I can see anyway). And secondly, the sever is not available as a configuration option.
Are there any quick fixes available to clean all artefacts/resources in my war/WEB-INF directory?
You can easily make it about one click and not unenviable. Just use ant and pattern matching. Open the ant view in Eclipse and add your file and it's just a click away.
Before 1.7 when app size was more limited, I used to copy almost everything out so I could upload it and serve from the blobstore (GWT permutations galore!). I was doing this alot!!!
see these for details http://ant.apache.org/manual/Types/fileset.html and http://ant.apache.org/manual/Tasks/delete.html
Here's my simple code example:
<target name="moveXprojectGae">
<delete includeemptydirs="true">
<fileset dir="XprojectGae" includes="**/*"/>
</delete>
<move todir="XprojectGae">
<fileset dir="war/XprojectGae">
<exclude name="**.rpc"/>
<exclude name="**nocache.js"/>
</fileset>
</move>
</target>
I want to deploy my ASP.NET MVC site and have the following script.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\MyProjName\MyProjName.csproj"/>
<PropertyGroup>
<NewInstallDir>C:\DeployFolder\</NewInstallDir>
<BinDir>$(NewInstallDir)bin\</BinDir>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="..\MySlnName.sln"
Properties="Configuration=Release;Platform=Any CPU;OutputPath=$(BinDir)" />
<Copy SourceFiles="#(Content->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(Content->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<Copy SourceFiles="#(None->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(None->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<MakeDir Directories="#(Folder->'$(NewInstallDir)%(RelativeDir)')" />
</Target>
</Project>
Main idea.
I copied binary to C:\DeployFolder (take structure of folder from sources). I build my dll to C:\DeployFolder\Bin (I don't have this folder in sources folder so I need separately copy this).
I run my script - all works instead of copy DLLs to OutputPath. Same scripts works for other asp.net mvc project. I have no idea what is wrong in this case.
I complete this issue with workaround but I would like to know what is wrong with this script.
The first thing I'd try is to replace your use of the deprecated $(OutputPath) with $(OutDir). From when I've seen this error, 9 times out of 10 it is due to a mismatch between the Platform/Configuration requested and how a particular project is actually defined. Take care to keep track of the discrepency between "Any CPU" (with a space) preferred by solution files and "AnyCPU" actually used inside project files for $(Platform). Some project wizards only set up an "x86" Platform or otherwise omit "AnyCPU" which can cause the OutputPath to be empty.
Beyond that, the approach of importing a project file and then building a solution (presumbably that includes the very same project" is a bit off center. Consider making the deployment changes you desire within the project file itself, through an import. You can either wire into the existing build targets at the right place, or perhaps add an additional target.
currently I'm developing in eclipse 3.5 in different project web applications for tomcat 6.0.24.
For each of this project I have written a ant build file to generate the war file to deploy the project to the tomcat container.
So I have to run for each project the ant build file (a lot of clicks, and a waste of time).
Question: Is there a possibility to run all needed ant build files with a single click, from a single project or whatever?
#thelost
thank you very much for your hint, you brought me on the right way,
I solved the problem:
<target name="build">
<ant antfile="jar-build.xml" target="GEN-JAR_FILES" />
<ant antfile="war-service01.xml" target="SVC01-WAR"/>
<ant antfile="war-service02.xml" target="SVC02-WAR"/>
</target>
best regards, Alex
Sure. E.g., you could create a master build file and use the Exec task.
I'm just getting into TDD, and from looking around, the general concensis seems to be to have a one to one mapping from a code project to a test project. My question is, if you follow this route, and have multiple test assemblies, what is the best way to run these as part of an NAnt script? If it makes a difference, I am using NUnit as my testing framework.
You can create a "test project" via the NUnit GUI, and save it to a file. In the GUI, you can add to the project the test dlls, which in turn reference the ones under test.
You can then pass that file to the NUnit console from within NAnt. e.g.
<property name="nunit.output" value="${dir.reports.nunit}\nunit-results.xml" />
<property name="nunit.input" value="proj.nunit" />
<exec program="${dir.tools}\nunit\bin\nunit-console.exe" failonerror="true">
<arg value="${nunit.input}" />
<arg value="/xml:${nunit.output}" />
</exec>
This way, NAnt need not know about the test dlls, just the NUnit project that contains that information.
I'd suggest the best way to go about this is to compile both projects from NAnt individually using the CSC command referencing each project file (csproj) rather than the solution. Then use the nunit-console command (as a separate Nant task) to execute your tests.
Whether you have one build large script/file that does this or separate separate ones for each project or task is up to you (or how complex your projects are).
The way I have my team's builds set up is that I have one 'master' build script which calls into other build scripts to perform specific tasks. For example 'master' calls 'compile' and then 'test' (passing in the results of the 'compile' script appropriately). This way the compilation of my core project is separated from the automated testing.