我不明白行家。最好使用螞蟻,但......我已經成功地創建罐子(帶有或不帶有依賴關係),我已經成功地複製蝙蝠亞軍腳本接近罐子,但現在我要創建這個jar和這隻蝙蝠拉鍊。所以我使用程序集插件並獲取BUUUM! CADAAAM!在我的配置中,它發生的情況是,它平行於罐子包裝執行。我寫的程序集文件:行家創建罐子拉鍊和一些文件
<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的組裝插件:
<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
:
- runner.bat
- jar_without_dependencies。罐子(它是Maven的JAR-插件吧?)
- jar_without_dependencies.j AR
而第三激怒了我。它包含: 而123目錄包含:
正如你看到的,我得到的罐子解壓的依賴,不含DIRS !!!!,並與DIR 123,這實際上是我想要的(呵呵組裝插件!做過某事!!!)。
我想與依賴類路徑的正確清單罐子。作爲一個選項,我想解壓依賴關係的jar(我知道關於彙編中的<unpack>false</unpack>
,但無法讓它工作)。我想將/ 123更改爲/並且無需排除文件即可獲得NORMAL JAR!我想兩個獨立的任務,以構建jar和zip(它是在Maven的配置文件完成的?)如螞蟻,我就寫了這樣的事情:
<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>
對不起,如果我太傳神,但我我對這種隱含的行爲真的很生氣。我真的堅持這一點。
試圖刪除 jar 。不起作用,因爲罐子是默認包裝... –
madhead
好吧,得到與罐子相關的工作。但仍然需要定製它。 – madhead