我不懂maven。更好地使用ant,但是...我已经设法创建jar(有或没有依赖项),我已经设法将bat runner脚本复制到jar附近,但现在我想用这个jar和这个bat创建zip。所以我使用汇编插件并得到 BUUUM!!!!卡达姆!在我的配置中,它与 jar 打包并行执行。我写了汇编文件:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>jg</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>/123</outputDirectory>
<excludes>
<exclude>assembly/**</exclude>
<exclude>runners/**</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
然后,我绑定了maven- assembly-plugin:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
<configuration>
<archive>
<manifest>
<mainClass>by.dev.madhead.lzwj.Main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
<!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
现在我把这个放进去./target
:
- 跑步者.bat
- jar_without_dependency.jar(它来自 maven-jar-plugin,对吧?)
- jar_without_dependency.jar
And the third angers me. It contains:
And the 123 directory contains:
正如你所看到的,我得到了带有解压依赖项的 jar,EXCLUDED DIRS!!!!,以及 dir 123,这实际上是我想要的(哦!程序集插件做到了!!!)。
我想要获取具有依赖项的 jar 并使用类路径正确地显示清单。作为一个选项,我想要带有解压依赖项的 jar (我知道<unpack>false</unpack>
在装配中,但无法使其工作)。我想将 /123 更改为 / 并获得没有排除文件的普通 JAR!我想要两个单独的任务来构建 jar 和 zip (是用 maven 中的配置文件完成的吗??) 就像在 ant 中一样,我会写这样的东西:
<target name="jar_with_deps" depends-on="compile">
<jar>
here i copy classes (excluding some dirs with runner script), and build manifest
</jar>
<copy>
copy bat file from src/main/resources/runner/runner.bat
</copy>
</target>
<target name="zip" depends-on="jar_with_deps">
<zip>
Get jar from previous target, get runner.bat. Put them in zip
</zip>
</target>
对不起,如果我太表达了,但我对这种含蓄的行为真的很生气。我真的被这个问题困扰了。