1

我有一个在内部使用 dagger (1.1.0) 的 mavenized apklib。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>
4

1 回答 1

1

只需使用 maven-resources-plugin 将生成的源复制到您想要的位置。“目录”是源目录,在您的目标/...中,您应该将“阶段”修改为像“准备包”这样的后源生成阶段。

<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>
于 2013-09-19T18:13:05.633 回答