Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 使用依赖项创建jar,并排除特定的源文件_Java_Maven_Maven Shade Plugin - Fatal编程技术网

Java 使用依赖项创建jar,并排除特定的源文件

Java 使用依赖项创建jar,并排除特定的源文件,java,maven,maven-shade-plugin,Java,Maven,Maven Shade Plugin,我想使用Maven创建一个jar,其中包含一个特定的依赖工件,并排除一些源java文件 目前我使用以下代码段: <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <executions> <executi

我想使用Maven创建一个jar,其中包含一个特定的依赖工件,并排除一些源java文件

目前我使用以下代码段:

            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                        <id>shadedJar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedClassifierName>classifier</shadedClassifierName>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <artifactSet>
                                <includes>
                                    <include>com.google.guava:guava</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
            </executions>
org.apache.maven.plugins
maven阴影插件
荫罩
包裹
阴凉处
分级机
符合事实的
错误的
番石榴:番石榴

因此,jar确实包含“guava”工件文件,但我也希望排除一些源文件(例如src/main/java/my.package/下的特定文件),我如何才能做到这一点?

我使用shade创建jar,但我不需要eclipse、txt和其他仅与开发相关的文件

这是我的代码,也许你可以添加并使用它

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                        <exclude>.settings/**</exclude>
                                        <exclude>*.classpath</exclude>
                                        <exclude>*.project</exclude>
                                        <exclude>*.txt</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

org.apache.maven.plugins
maven阴影插件
2.2
包裹
阴凉处
错误的
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
.设置/**
*.classpath
*.项目
*.txt

确切的源文件是什么?我想排除模块源代码中/src/main/java/my.package文件夹下的一些特定文件。@如果您能用我的一般答案解决您的问题,请将帖子标记为正确答案,票证就会完成