好的...所以我似乎自己解決了一個解決方案。我知道這個問題是相對特殊的再次...因爲我所有的問題似乎是:-)
解決方案是創建一個maven模塊包含PlexusIoResourceCollection的自定義實現,並從components.xml文件放在「META-INF/plexus」目錄中。
加入這個作爲一個依賴於我的組裝插件後,我能夠的exe文件嵌入到我的罐子:-)
這裏談到的組件的代碼:
package npanday.plugin.archiver;
import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* Created with IntelliJ IDEA.
* User: cdutz
* Date: 02.03.12
* Time: 12:04
*/
public class PlexusIoExeResourceCollection extends PlexusIoCompressedFileResourceCollection {
@Override
protected String getDefaultExtension() {
return ".exe";
}
@Override
protected InputStream getInputStream(File file) throws IOException {
// Simply return an InputStream to the resource file.
// This will make it embed the source as a whole.
return new FileInputStream(file);
}
@Override
public String getPath() {
// Without overriding this, the exe would be included with its full path.
// This way it is included directly in the root of the result archive.
return super.getFile().getName();
}
}
這裏在META-INF /叢/ components.xml的配置XML
<component-set>
<components>
<component>
<role>org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection</role>
<role-hint>exe</role-hint>
<implementation>npanday.plugin.archiver.PlexusIoExeResourceCollection</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
</components>
</component-set>
最後使用在我的組裝插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.npanday.plugins</groupId>
<artifactId>maven-exe-archiver-plugin</artifactId>
<version>${npanday.version}</version>
</dependency>
</dependencies>
</plugin>
希望它能幫助我。
是的,程序集插件應該沒問題。你可以顯示你想要的jar文件的內容是什麼? – 2012-03-02 07:46:36
我會回答你的問題在一個主要的「答案」的原因SO我想要搞亂我的linebreaks :-) – 2012-03-02 08:04:19