通过Maven build

时间:2015-07-16 12:51:46

标签: java android maven

我正在将基于Gradle的Android项目转换为Maven,并且在包含SimpleXML Framework时遇到了速度提升。

在Gradle中我可以在导入库时指定以下内容:

compile('org.simpleframework:simple-xml:2.7.+') {
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'

我怎么能在Maven中这样做?我曾尝试使用Shade插件,但我认为我弄得一团糟。这是我的尝试:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <artifactSet>
                    <excludes>
                      <exclude>stax</exclude>
                      <exclude>stax-api</exclude>
                      <exclude>xpp3</exclude>
                    </excludes>
                  </artifactSet>
                </configuration>
              </execution>
            </executions>
          </plugin>

2 个答案:

答案 0 :(得分:2)

我认为你想要的是这里描述的: https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

基本上,在要排除某些内容的库的<depdency>标记内,您可以添加<exclusions>。链接示例:

<dependencies>
<dependency>
  <groupId>sample.ProjectA</groupId>
  <artifactId>Project-A</artifactId>
  <version>1.0</version>
  <scope>compile</scope>
  <exclusions>
    <exclusion>  <!-- declare the exclusion here -->
      <groupId>sample.ProjectB</groupId>
      <artifactId>Project-B</artifactId>
    </exclusion>
  </exclusions> 
</dependency>

答案 1 :(得分:0)

尝试使用maven-compiler-plugin它适用于我

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <excludes>
      <exclude>**/src/main/java/*.java</exclude>
    </excludes>
  </configuration>

相关问题