Question

I'm trying to convert Ant task to Maven's antrun plugin task.

The Ant task is like that:

<aidl executable="${aidl}"
    framework="${project.target.framework.aidl}"
    libraryBinAidlFolderPathRefid="project.library.bin.aidl.folder.path"
    genFolder="${gen.absolute.dir}"
    aidlOutFolder="${out.aidl.absolute.dir}">
    <source path="${source.absolute.dir}"/>
</aidl>

This code is from android sdk build.xml file.

Any idea how it should be like in Maven antrun plugin?

Was it helpful?

Solution

I'm posting the way I did it for now, in case someone is looking for the same solution.

Note that the code is not clean and not portable.

<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}"/>
          <property name="framework.aidl" location="${env.ANDROID_HOME}/platforms/android-17/framework.aidl"/>
          <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>
  • The maven-antrun-plugin is maven plugin to execute ant tasks.
  • The property aidl is pointing to the aidl.exe from Android SDK build-tools. This part of the script is using hard-coded values. The better way will be to discover the location dynamically, but unfortunately I've not found the way to do it yet.
  • The property framework.aidl is pointing to the framework.aidl file from Android SDK. This part of the script is using hard-coded values. The better way will be to discover the location dynamically, but unfortunately I've not found the way to do it yet.
  • The apply ant task is used to execute the aidl.exe with fileset as input argument.
  • The srcfile is used to mention the input files for the apply task. The srcfile is empty, but I've used the fileset below to filter only the files with *.aidl extension.

OTHER TIPS

It's more convenient to use android-maven-plugin and then:

mvn clean android:generate-sources
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top