Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Maven build排除某些类_Java_Android_Maven - Fatal编程技术网

Java 通过Maven build排除某些类

Java 通过Maven build排除某些类,java,android,maven,Java,Android,Maven,我正在将一个基于Gradle的Android项目转换为Maven,当涉及到包括 在Gradle中,我可以在导入库时指定以下内容: compile('org.simpleframework:simple-xml:2.7.+') { exclude module: 'stax' exclude module: 'stax-api' exclude module: 'xpp3' 请问我在Maven怎么做?我试过使用Shade插件,但我想我把它弄得一团糟

我正在将一个基于Gradle的Android项目转换为Maven,当涉及到包括

在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>

org.apache.maven.plugins
maven阴影插件
2.4.1
包裹
阴凉处
斯塔克斯
斯塔克斯api
xpp3

尝试使用maven编译器插件,它对我很有用

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

org.apache.maven.plugins
maven编译器插件
**/src/main/java/*.java

我想这里描述了您想要的:

基本上,在要排除某些内容的库的
标记中,添加
。链接中的示例:

<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>

示例项目a
项目A
1
编译
示例项目B
B项目

您能解释一下这是做什么用的吗?太好了,谢谢。我以前见过这个,但不知道组/工件ID——我必须进入我的maven repo并打开pom.xml for SimpleXML框架才能获得这些。希望它能帮助别人。