我正在尝试将 Ant 任务转换为 Maven 的 antrun 插件任务。
Ant 任务是这样的:
<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>
此代码来自android sdk build.xml文件。
知道它在 Maven antrun 插件中应该是什么样子吗?
最佳答案
我现在发布我的做法,以防有人正在寻找相同的解决方案。
请注意,代码不干净且不可移植。
<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>
maven-antrun-plugin
是执行 ant 任务的 maven 插件。aidl
属性指向 Android SDK 构建工具中的 aidl.exe。 脚本的这一部分使用硬编码值。更好的方法是动态发现位置,但不幸的是,我还没有找到这样做的方法。- 属性
framework.aidl
指向Android SDK 中的framework.aidl 文件。 脚本的这一部分使用硬编码值。更好的方法是动态发现位置,但不幸的是,我还没有找到这样做的方法。 apply
ant 任务用于以fileset
作为输入参数执行 aidl.exe。srcfile
用于提及apply
任务的输入文件。srcfile
是空的,但我使用下面的fileset
只过滤扩展名为 *.aidl 的文件。
关于android - 如何使 Maven 的 antrun 任务从 AIDL 文件生成源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17802715/