可能であれば、Tomcatのcontext.xmlファイルをWARファイルのMETA-INFディレクトリから削除したいと思います。 Mavenのcargo pluginでこれを行うことはできますか?私は正しい構成を見つけることができないようです。Tomcat6のcontext.xmlファイルをMaven Cargoプラグイン経由で提供することは可能ですか?
答えて
ユーレカ!この問題を研究して何日もして、私はついに非常に効果的な解決策を見つけました。鍵は、あなたのTomcat XMLコンテキスト断片化ファイルを取り出し、という名前のconf/Catalina/localhost
ディレクトリにドロップするために、貨物の<configfiles>
要素を使用することです。唯一の欠点は、これがコンテキスト定義をすべてのWebアプリケーションで利用できるようにすることですが、これはCargoだけがこのTomcatインスタンスを使用しているため、他のWebアプリケーションはありません。
<configuration> <!-- Deployer configuration -->
<type>standalone</type>
<properties>
<cargo.servlet.port>${tomcat6.port}</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<groupId>com.myapp<groupId>
<artifactId>myapp-war</artifactId>
<type>war</type>
<properties>
<context>${tomcat6.context}</context>
</properties>
</deployable>
</deployables>
<configfiles>
<configfile>
<file>${basedir}/../config/tomcat-context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>context.xml.default</tofile>
</configfile>
</configfiles>
</configuration>
最終結果のみをテストするためにこれ以上の偽のWARモジュールで、や戦争のこれ以上の合併:
は、ここでの設定です。これが誰かを助けることを願っています。
私はまだこれを行う方法は見つけられませんでしたが、私は自分のプロジェクトでその作品を取り巻く仕事を思いつきました。私は、次のプラグインの宣言実行し、「Webアプリケーション」プロジェクトを構築していた場合
dependencies
webapp
smoketest
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>create-war-smoketest</id>
<phase>verify</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<webappDirectory>${project.build.directory}/exploded</webappDirectory>
<primaryArtifact>false</primaryArtifact>
<classifier>smoketest</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/test/resources/smoketest</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>context.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
をそして、私は私を実行しているとき、私は現在、基本的に3サブモジュールとのプロジェクトを持っていますSmokeTestプロジェクトの貨物/ WebTestのスイートは、私はthusly私deployrables設定依存関係として、私の貨物構成でsmoketest WARファイルを指定します。
<deployables>
<deployable>
<groupId>${pom.groupId}</groupId>
<artifactId>webapp</artifactId>
<type>war</type>
<properties>
<context>smoketest</context>
</properties>
</deployable>
</deployables>
を依存リットルで
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>webapp</artifactId>
<version>${pom.version}</version>
<classifier>smoketest</classifier>
<type>war</type>
<scope>system</scope>
<!-- trick the dependency plugin to never look for it in the repo -->
<systemPath>${basedir}/../webapp/target/webapp-${pom.version}-smoketest.war</systemPath>
</dependency>
</dependencies>
これは非常に汚いですが、少なくとも今は...うまくいきます。 1つの簡単な注記:リポジトリでバージョンを探すことがないようにするという私のコメントは、この時点で間違っている可能性があります。私は、このトリックがある時点で依存関係プラグインへの変更によって壊れている可能性があると思います。
私もこれを試しました。それは私にとってもうまくいきます。私たちはWARファイルをフィルターに入れた状態で出荷することを望んでいない/できないので、廃絶したWARアーティファクトを排除することを望んでいました。 – HDave
これは、貨物1.1.1シームで新しいファイルを追加しないという事実を除いて機能しました。私はファイルを置き換えることしかできませんでした。 – Ralph