2012-03-22 22 views
1

Javaベースのコマンドラインアプリとそのすべての依存関係をmavenとlaunch4jを使って単一の* .exeファイルにラップしたいと思います。launch4jとmavenを使ってJavaコマンドラインアプリケーションをラップする

今私はthis onethisのようにすべての同様の質問を読みましたが、動作させることはできません。

誰でも簡単なpom.xmlスニペットを提供できます。これはどのようにして必要なすべての依存関係を実現できますか? そして、私はEclipsesで実行する必要がありますか?

<!-- Launch4j --> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <version>1.4</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one --> 
       <shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar --> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.bluestemsoftware.open.maven.plugin</groupId> 
      <artifactId>launch4j-plugin</artifactId> 
      <version>1.5.0.0</version> 
      <executions> 

       <!-- Command-line exe --> 
       <execution> 
        <id>l4j-cli</id> 
        <phase>package</phase> 
        <goals> 
         <goal>launch4j</goal> 
        </goals> 
        <configuration> 
         <headerType>console</headerType> 
         <outfile>target/importer.exe</outfile> 
         <jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above --> 
         <errTitle>App Err</errTitle> 
         <classPath> 
          <mainClass>${mainClass}</mainClass> 
         </classPath>     
         <jre> 
          <minVersion>1.5.0</minVersion> 
          <maxVersion>1.6.0</maxVersion> 
          <initialHeapSize>128</initialHeapSize> 
          <maxHeapSize>1024</maxHeapSize> 
         </jre> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

私はlaunch4jを実行すると::ここで

私はSOからコピーしたものである(?これは正しいものである場合)Eclipseで目標をlaunch4j私が取得:

ゴールを実行できませんでした org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j (default-cli):プロジェクトのインポーターで:パラメータ 'headerType'、 'jre' のパラメータ org.bluestemsoftware.open.maven.plugin:launch4j-プラグイン:1.5.0.0:launch4j が見つからないか、または無効です - > [ヘルプ1]

たぶん私はちょうど...

を偽の目標を立ち上げています
+0

[this](https://github.com/vorburger/launch4j-maven-plugin)プラグインで試してみてはいかがですか?これは新しいと思われますか? – Raghuram

+0

vorburgerプラグインは有望そうですが、どの目標を実行する必要がありますか? – Drejc

+0

mvn installを実行します。必要なクラスが見つかりません:com.akathist.maven.plugins.launch4j.Launch4jMojo failure。これはvorburgerのデモ・アプリケーションにあります。 – Drejc

答えて

0

Drejc!

あなたの設定に非常に似た設定の.exeファイルを生成することができました。私の全体のポンポンを、以下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <packaging>jar</packaging> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>test</name> 

    <properties> 
     <mainClass>foo.App</mainClass> 
    </properties> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-shade-plugin</artifactId> 
       <version>1.4</version> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>shade</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one --> 
        <shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar --> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>com.akathist.maven.plugins.launch4j</groupId> 
       <artifactId>launch4j-maven-plugin</artifactId> 
       <executions> 
        <!-- Command-line exe --> 
        <execution> 
         <id>l4j-cli</id> 
         <phase>package</phase> 
         <goals> 
          <goal>launch4j</goal> 
         </goals> 
         <configuration> 
          <headerType>console</headerType> 
          <outfile>target/importer.exe</outfile> 
          <jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above --> 
          <classPath> 
           <mainClass>${mainClass}</mainClass> 
          </classPath> 
          <jre> 
           <minVersion>1.5.0</minVersion> 
           <initialHeapSize>128</initialHeapSize> 
           <maxHeapSize>1024</maxHeapSize> 
          </jre> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
      <version>LATEST</version> 
     </dependency> 
    </dependencies> 

</project> 

私はvorburgerの一つに、プラグインののgroupIdとたartifactIdを変更しましたが、alakaiのバージョンは、あまりにも動作するはずです。できたあなたは

  • (私はいくつかの「非常に小さい」アーティファクト/ゼロ依存アーティファクトと過去にいくつかの問題があった)あなたが宣言し、少なくとも1つの依存関係を持っている

    1. あなたは
    2. 正しいmainClassを設定した。そのことを確認してくださいReposからプラグインをダウンロードしてください

    このpomを単純なmavenのアーキタイプでテストしましたので、マシン上で動作しない理由はわかりません。何か問題があれば、ここで尋ねてください。

    .exeファイルを生成するには、ターミナルで「mvn clean package」を実行するか、Eclipseでプロジェクトを右クリックして 'Run as ...'> 'Maven build ...'ゴールテキストフィールドに「クリーンパッケージ」と入力します。

    関連する問題