我有一个mavenized apklib,内部使用dagger(1.1.0)。 maven构建使用适当的适配器类在构建输出文件夹中生成annotations
文件夹。但是,这些不包含在生成的apklib中。
在apklib中包含生成的源的构建过程的正确配置是什么?
我正在使用maven v3.0.4,android-maven-plugin v3.6.0和maven-compiler-plugin v3.1
编辑:这是我的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx</groupId>
<artifactId>yyy</artifactId>
<version>0.0.1</version>
<packaging>apklib</packaging>
<properties>
<maven.build.timestamp.format>yyMMdddHHmm</maven.build.timestamp.format>
<android.version>4.3</android.version>
<versionCode>${maven.build.timestamp}</versionCode>
<android.sdk.platform>18</android.sdk.platform>
</properties>
<dependencies>
<!-- Other dependencies... -->
<dependency>
<groupId>com.squareup.dagger</groupId>
<artifactId>dagger</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.squareup.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>1.1.0</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<dependencies>
<dependency>
<groupId>com.squareup.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:1)
只需使用maven-resources-plugin即可将生成的源复制到所需位置。 “directory”是源目录,位于目标/ ... 你应该将“阶段”修改为像“prepare-package”这样的后期源生成阶段。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources1</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>${project.build.directory}/...</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/...</directory><!-- source dir-->
<include>**/*</include>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>