How to Build Multiple Android Projects in one go - java

I have one Android Project. I created Junit test project for the same. I can build the both projects using ANT script independently. Now, I want to write the script which will call this ANT scripts and build the project. How I can do it ?
I am currently using Windows-Xp, eclipse- Galileo, jdk - 6

Use the ant task in ant.
You can then write a "binding" build.xml file which calls all of the other "build.xml" files with the appropriate tasks (in whatever appropriate order).
An example (from the manual)
<ant antfile="subproject/subbuild.xml" target="compile"/>
Which would then call the "compile" target in the subproject/subbuild.xml file.

Related

The project uses build.properties from another NetBeans installation

When using trying to build a NetBeans project created with a previous version, I get the following confirmation dialog:
Build Project
The project ... uses build.properties from another NetBeans installation.
Build Anyway
Use this installation
Update
What would these options do?
No matter which options I choose, I do not notice any difference in the build process.
Using NetBeans Development with projects created on NetBeans 8.1.
it depends on what type of dependencies you are using in your project, to be on safe side , I'd prefer clicking Update which it'll update current project's build properties with the external one,
also here's what (wiki.netbeans.org) have about build.properties file:
"If you edit build.xml by hand, you can of course arrange to build other projects (or any Ant scripts) as part of your build, using the or tasks. Note that a build-impl.xml, when building a foreign project, calls its build.xml (rather than skipping to its build-impl.xml), so you can freely mix a hand-customized project with IDE-customized projects."
thanks

How to Invoke two or more ant targets from eclipse?

I use ant plugin for eclipse.
from comman line I can write
ant clean all
What analog can I use with plugin?
UPDATE
what I can click after?
You can create one of the target and specify depends property of the targets you want to execute.
Refer to below sample code
<project name="some name" default="executeMultipleTargets">
<target name="executeMultipleTargets" depends="myTarget1,target2,target3,clean" >
<echo>Build Successfull....</echo>
</target>
</project>
Ant is considered an external tool. So you do not have a run configuration but an external tool configuration for ant runs. There even exists a sub-point "Ant Builds" in that window.
It is very strange that you do not have the option run as ant build when right-clicking an ant build file. I can only assume, you do not have the appropriate plugin (although that is installed by default).
But maybe you are satisfid by just creating an external tool configuration for running ant.
You can specify multiple targets in Ant GUI: open your build.xml file and in outline view right click desired target. Then select "Run as -> Ant build..." and check all desired targets.
You can go on eclipse-> external tools configurations, select in Targets tab your preferable ant targets and be executed in order.

Can I call an ant script from another ant script? What have I to do?

I am pretty new in Ant (I came from Maven) and I have a doubt if I can do the following operation using Ant.
I have 5 projects in my Eclipse workspace. One of this project is the main project, the others are dependencies of the main project.
In this time I have a single big (and confusing) ant project in the main project that do the following operation:
1) Compile dependencies project and create the jars of all these dependencies project and copy these jar into a directory named lib that is into the main project
2) Compile and create the jar file for the main project (that use the others created jar)
This version of the ant script is not appreciated by my boss because it appears to be a bit 'confusing and he ask to me to do the following refactor of ant script:
1) Create an ant script for each dependencies project. This script compile the related project and create the related jar into a directory named Release that is into the current project (this is pretty simple).
2) Create an ant script for the main project that call all the ant script for each dependencies project
Can I do this thing? If it is possible what have I to do to call an ant script from another ant script?
Tnx
Andrea
I use the same method to compile all my projects.
use this command
<ant antfile="../<project-dir>/build.xml" dir="../<project-dir>" />
Yes. Use the import function so your current build script knows where the other build script is. Then you should be able to call operations on the other script.
https://ant.apache.org/manual/Tasks/import.html

Java, Eclipse, Ant, JUnit, Hudson, SVN, native libraries; can they all coexist?

What is the most proper way to accomplish all of the following:
Create a project in Eclipse
With an Apache Ant buildfile
That Hudson (or another more recommended CI system?) uses
And support for JUnit tests that are run by both Ant/Hudson and Eclipse
And check the proper folder structure into SVN so that future developers can replicate the build, and Hudson can automatically grab from SVN and run the Ant file to build/test/deploy the project
And the project has native libraries, if that makes any difference (I've already written an Ant task that can download and unzip the proper library files depending on the OS)
I already have my project with some source files and an Ant file, but I've been having trouble integrating it with Eclipse in an organized manner, so I would really love to start from a fresh Eclipse project, set it up correctly, and then copy my Ant file and my source files piece-by-piece into the project in the most Eclipse-compatible way.
I will be continuing to play around with everything in an attempt to get it working as I like it. But if you have experience with this sort of thing, perhaps at your workplace, please give as much information as you can.
My main goal here is to learn this once and use it in my future projects. For now, I am developing a client-server application consisting of a JOGL applet frontend (using JNLP files) and an unattended server app. Up until now I've been doing it all by hand: writing and building in Eclipse, dragging the applet jar into my FTP client, SSHing the server jar and restarting it by hand, and all with no testing process. I'm hoping that by the end, the build process will be something like this: test locally on my machine with a copy of the native libraries; commit code changes to SVN; Hudson svn updates, uses the Ant buildfile to compile and run all JUnit tests; if all the tests pass, it proceeds to copy the server jar to my dedicated server and restart the running server instance, and then copy the client jar to my web server.
When I start a new project, I generally take the following steps:
Create a new Java project in Eclipse, using the Java project wizard and opting to keep source and class files in separate directories ('src' and 'class')
Set up the project in Eclipse with the package structure you want
Create a new repository (or folder in your repository) for the project, with the normal /trunk/ /branches/ /tags/ set up
Using your SVN client, import the contents of the project folder Eclipse made for the project (at the level where the 'src' and 'class' directories are) into the trunk of the repository
Confirm everything is in Subversion correctly (check the trunk out to a new location)
Using Eclipse, delete the project (and the files on disk)
Create a new project using the 'Checkout projects from SVN' wizard, using the trunk of the repository
Create your Ant script, ensure the project builds correctly, and add the Ant script to the repository
Now, from Hudson:
Create a new job and set the Subversion URL to the root of the repository
Add a build set that will use Ant (I've always had to install my own version of Ant and ensure it's configured correctly to have this work) and will call the Ant script you
Use 'Build Now' to see if the job will build correctly
You can invoke your JUnit tests from Ant in the build script (first compile them with the javac task, then run them with the junit task). Hudson will track the test results if you ask it to.
You can use a shell script build step to copy your server jar to where it's needed, and restart the server instance. Like Mnementh said, it sounds like you've got the native libraries sorted...
If you are not tied to using ant, and are prepared to use Maven, then it is simply a matter of setting up Maven with the Eclipse plugin which generates the Eclipse projects for you.
Hudson already knows how to build Maven projects, so that is taken care of.
So long as you can pull your projects into eclipse, then it will be able to run the unit tests, and hudson can use the previously mentioned maven support to run the unit tests as well.
If you use Maven, then you will want to follow it's guidelines on how to create a project, here is a good starting point.
Hope this helps.
At our company we actually use Eclipse, Java, Ant, SVN, Junit and Hudson. That is all you mentioned except the native libraries. If you said your ant-buildscript already works with the native libraries that problem seems solved too. To integrate it well into eclipse you could do it in two ways: Use Ant also from Eclipse (has downsides) or the developer has to install the native library for his machine properly, so that Eclipse can compile without a problem and for continuous integration it will be downloaded by Ant.

build.xml in Java project

What is the file build.xml?
I was wondering if it is a possibility to import this project in Eclipse or Netbeans using this build.xml. I tried to import the project but I get some errors since one part is created using J2ME and the other J2SE and I guess this file should be the configuration.
build.xml usually is an ant build script.
It contains information necessary to build the project to produce the desired output, be it Javadocs, a compiled project, or a JAR file.
I believe Eclipse has ant built-in, so it should be possible to execute the build.xml by choosing "Run As..." and "Ant Build".
The build.xml file, if it is an ant script, is not used to import the project into an IDE like Eclipse or Netbeans. A build script is used to build the project (or produce some desired output) rather than an mechanism for importing the project into an IDE.
As mentioned by #coobird this is an ant build file. Although IDEs such as Eclipse and Netbeans have ant support built-in, it is also possible to run ant from the command-line and this may be the simplest way to get started if the project has been well created.
See http://ant.apache.org/
for docs.
If you want to try this approach, install ant, cd to the directory with build.xml and issue
ant
Eclipse can be told to build using an Ant script, but you can also use Ant itself.
build.xml file is an Ant(Apache) script.
you can find more information on Ant & build.xml here
In java project build.xml file is used write the ant script.
And from that ant script you can generate war file and can deploy on Tomcat server

Categories