1

maven-assembly-plugin を使用して、[app-root]/target/my-project-war の下に war ファイルを作成します。[app-root]/war のようなアプリケーション ルートの下のフォルダーになるように、この war ファイルを解凍するにはどうすればよいですか?

target/**.war の代わりに war フォルダーが必要な理由は、mvn gae:deploy を使用してアプリ エンジンに直接デプロイできるからです。gae:deploy は maven-gae-plugin からのものであり、その構成では、war ファイルではなく appDir のみを指定できます。

pom.xml

<plugin>
     <groupId>net.kindleit</groupId>
     <artifactId>maven-gae-plugin</artifactId>
     <version>${gae.plugin.version}</version>
     <configuration>
             <unpackVersion>${gae.version}</unpackVersion>
             <serverId>appengine.google.com</serverId>
             <sdkDir>${gae.home}</sdkDir>
             <appDir>${basedir}/war</appDir>
             <splitJars>true</splitJars>
     </configuration>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
       <appendAssemblyId>false</appendAssemblyId>
       <descriptors>
               <descriptor>${basedir}/assembly-war.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
               <id>make-assembly</id>
               <phase>package</phase>
               <goals>
                   <goal>single</goal>
                   </goals>
        </execution>
    </executions>
 </plugin>

アセンブリ-war.xml

<assembly>
   <id>war</id>

   <formats>
       <format>war</format>
   </formats>

   <includeSiteDirectory>false</includeSiteDirectory>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
    ...
   </fileSets>
   <dependencySets>
   </dependencySets>
</assembly>

これが私のプロジェクトフォルダーです。War フォルダは太字です。

$ ls -l test-maven-play-plugin/
total 24
drwxr-xr-x   5 angeloh  staff   170 Jan 25 21:45 app
-rw-r--r--@  1 angeloh  staff  2962 Jan 25 23:58 assembly-war.xml
drwxr-xr-x   6 angeloh  staff   204 Jan 25 21:46 conf
drwxr-xr-x  26 angeloh  staff   884 Jan 25 22:42 lib
-rw-r--r--@  1 angeloh  staff  7380 Jan 26 00:05 pom.xml
drwxr-xr-x   4 angeloh  staff   136 Jan 26 00:04 precompiled
drwxr-xr-x   5 angeloh  staff   170 Jan 25 21:45 public
drwxr-xr-x   9 angeloh  staff   306 Jan 26 00:04 target
drwxr-xr-x   6 angeloh  staff   204 Jan 25 22:11 test
drwxr-xr-x   3 angeloh  staff   102 Jan 25 22:15 test-result
drwxr-xr-x   2 angeloh  staff    68 Jan 26 00:04 tmp
drwxr-xr-x   3 angeloh  staff   102 Jan 25 22:10 **war**

- - - - - - - - - - - [アップデート] - - - - - - - - - - -

少し進歩。これらの変更を行う場合:

pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    ......
    <configuration>
       ......
       <outputDirectory>${basedir}/war</outputDirectory> 
    </configuration>
    ......
</plugin>

アセンブリ-war.xml

<assembly>
   <id>war</id>

   <formats>
       <format>dir</format>
   </formats>
   ......
</assembly>

戦争の内容は war/test-play-1.0.0 に出力されます。ただし、war/test-play-1.0.0 ではなく、直接 war に使用したいです。

- - - - - - - - - - - [アップデート] - - - - - - - - - - -

最後に、これらの変更を行った後、うまくいきました。

pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    ......
    <configuration>
       ......
       <outputDirectory>${basedir}</outputDirectory>
       <finalName>war</finalName> 
    </configuration>
    ......
</plugin>
4

1 に答える 1

0

maven-war-plugin は、最初に Web アプリをディレクトリにビルドします。デフォルトでは、このディレクトリーは${project.build.directory}/${project.build.finalName}( webappDirectory構成プロパティーを参照) です。

maven-gae-plugin は、展開された war からデプロイされます。デフォルトでは、同じディレクトリです。( appDir構成プロパティを参照)

したがって、次のように実行できます。

mvn clean package gae:deploy

これに問題がある場合は、クラス ファイルとリソースを src/main/webapp/WEB-INF/classes にコピーし、依存関係を src/main/webapp/WEB-INF/lib にコピーする war:inplace ゴールの使用を検討できます。 .

于 2012-01-26T12:18:54.800 に答える