I have a project with a linked source folder. This project depends on another (remote service) project, so the aidl files and the classes passed across the remote interface are in a common_src
linked folder shared between the two projects. This work just fine with Eclipse builds, (one source file, two projects, changes in one project are reflected in the other, just as it should be).
I'd now like to do an Ant build from the command line. I managed to get another project with a single src directory building across all targets using the example build.xml
from the SDK tools. It imports ant_rules_r3.xml
automatically and once the source.dir
and out.dir
are defined in the build.properties
it's all fairly painless.
Turning to the project with the src
and common_src
folders, I can't get it to build. Firstly I cut and pasted the compile target and all those it depends upon into the build.xml
above the setup task. I added and defined the element common_src
to the build.properties
and added the last line shown below to the -compile target
(copied from ant_rules_r3.xml
) into the build xml
:
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<src path="${common_src}" /><!--ADDED-->
which got it further on in the build process - it could find the .java files in common_src but not the .aidl files. No surprise I realised as the aidl is a separate target. I then added
<src path="${common_src}" />
to the -aidl target in the build xml, and it failed with:
BUILD FAILED
C:\dev\projects\Eclipse\AndroidWorkspace\MapProject\build.xml:77: aidl doesn't
support the nested "src" element.
So that's got me well and truly stuck. Ideally I'd like to modify just the build.properties file to include the common_src and pass it to the ant_rules_r3.xml but I can't think of a way of doing it. I'd be most grateful if anyone can suggest how it can be done.
I had a similar issue, but it seems to have been resolved for me by the following setting in my build.properties file:
source.dir = src;../other_project/src
I used a relative path to link my src to other_project, but you should be able to use an absolute path. If you do, you should probably put it in local.properties instead.
Note: according to the comments in build.properties, if my SDK version < 2.0 I would use this instead:
source-folder = src;../other_project/src
Just in case there's any interest, I thought I'd answer my own question which is now solved.
1) I defined the common_src in the build.properties
2) Added the line
<src path="${common_src}"
in an overriden compile target in the build.xml above the setup (plus overrode all the targets it depended on by cutting/pasting from the ant_rules_r3.xml) 3) Added a new target 'aidl2' the same as 'aidl' in build.xml but which had the line
<source path="${common_src}"
instead of
<source path="${source.absolute.dir}" .
Made aidl depend on aidl2. Overrode all the targets aidl depended on.
I also added lines like :
key.store=xxxxxxxxxxxxx
key.alias=xxxxxxxxxxxxx
key.store.password=xxxxxxxxxxxxx
key.alias.password=xxxxxxxxxxxxx
to the build.xml which automated the input of passwords. I finally added an install_release target to make an automatic one command build, rease and install process.
I can't comment because I don't have enough reputation but it if adding a source folder works with previous answers, it fails later when building jar :
compile: [javac] Compiling 463 source files to /home/xxx/documents/eclipse/xxx/deploy/xxx/bin/classes [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] Creating empty /home/xxx/documents/eclipse/xxx/deploy/xxx/bin/classes/fr/xxx/android/socialintegration/facebook/package-info.class [echo] Creating library output jar file... BUILD FAILED /home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:570: The following error occurred while executing this line: /home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:680: The following error occurred while executing this line: /home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:744: /home/xxx/documents/eclipse/xxx/deploy/xxx/src;../xxxdata/src does not exist.
The faulty part is in the building of the jar that use source.absolute.dir as a filset which in invalid for ant.
But I don't have any workaround for now and I don't understand why others have managed to make it work ... (I'm also using sdk r20)
Add ;
separated list of sources to your ant.properties
(don't forget to include default src
as well):
source.dir=src-other;src
Above works fine with Android SDK Tools Revision 20.0.3+ (Project Target: Android 2.2+, API level: 8+).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With