How to compile AIDL files in JAR project?

1,650 views
Skip to first unread message

aptem.t...@gmail.com

unread,
Sep 12, 2013, 6:25:08 AM9/12/13
to maven-androi...@googlegroups.com
I've seen that if project is APK or APKLIB the AIDL are compiled automaticaly, but if project is changed to JAR the AIDL are not compiled. 

How can I enable AIDL compilation in JAR project?

Manfred Moser

unread,
Sep 13, 2013, 3:50:40 PM9/13/13
to maven-androi...@googlegroups.com
> I've seen that if project is APK or APKLIB the AIDL are compiled
> automaticaly, but if project is changed to JAR the AIDL are not compiled.
>
> How can I enable AIDL compilation in JAR project?

You cant. The android maven plugin works on apk, apklib and soon aar
packaging. For jar packaging the maven jar plugin is used and it knows
nothing about android

aptem.t...@gmail.com

unread,
Sep 15, 2013, 3:58:55 AM9/15/13
to maven-androi...@googlegroups.com, man...@simpligility.com
Thanks,

I was able to compile AIDL using the ANT task, but I have problems to find the path to the Android build-tools, I don't know which version of android is used.

The path I used is hard coded:
<property name="aidl" location="${env.ANDROID_HOME}/build-tools/android-4.2.2/aidl${exe}"/>

Do you know how to find which version of Android is installed on the machine?

This is my complete ANT task:
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <id>generate-aidl</id>
        <phase>generate-sources</phase>
        <configuration>
          <target name="convert-aidl-files">
            <property name="aidl" location="${env.ANDROID_HOME}/build-tools/android-4.2.2/aidl${exe}"/>
            <apply executable="${aidl}" parallel="false">
              <arg value="-I${src.dir}"/>
              <arg value="-p${framework.aidl}"/>
              <arg value="-o${gen.dir}"/>
              <srcfile/>
              <fileset dir="${src.dir}">
                <include name="**\*.aidl"/>
              </fileset>
            </apply>
          </target>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>


Thanks in advance.

Manfred Moser

unread,
Sep 15, 2013, 9:45:17 PM9/15/13
to maven-androi...@googlegroups.com, man...@simpligility.com
> Thanks,
>
> I was able to compile AIDL using the ANT task, but I have problems to find
> the path to the Android build-tools, I don't know which version of android
> is used.
>
> The path I used is hard coded:
> <property name="aidl" location="${env.ANDROID_HOME}/build-tools/*
> android-4.2.2*/aidl${exe}"/>

At this stage you are completely building your own build tool and as such
are pretty much on your own. Personally I think what you are doing is a
bad idea.

manfred

Édouard Mercier

unread,
Nov 2, 2013, 10:47:11 AM11/2/13
to maven-androi...@googlegroups.com, man...@simpligility.com
Hello.

I'm not a Maven expert, why why don't you use the Build Helper Maven Plugin (http://mojo.codehaus.org/build-helper-maven-plugin/usage.html), by declaring the project exposing the AIDL files as an apklib packaging, and add the following build configuration (by me, it works) ?

     
<plugin>
       
<groupId>org.codehaus.mojo</groupId>
       
<artifactId>build-helper-maven-plugin</artifactId>
       
<version>1.8</version>
       
<executions>
         
<execution>
           
<id>attach-artifacts</id>
           
<phase>package</phase>
           
<goals>
             
<goal>attach-artifact</goal>
           
</goals>
           
<configuration>
             
<artifacts>
               
<artifact>
                 
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
                 
<type>jar</type>
               
</artifact>
             
</artifacts>
           
</configuration>
         
</execution>
       
</executions>
     
</plugin>



Reply all
Reply to author
Forward
0 new messages