私はこのために既存の方法を見つけられなかったので、次のロジックを使用しています。これは、カスタマイズされた耳を構築するプラグインです。これは、XMLファイルに必要な依存関係を追加し、それらをアーカイブに組み込みます。私は推移的な依存関係にも興味があるので、getDependencyArtifacts
の代わりにgetArtifacts
を使用しています。
Collection<Artifact> dependencies = new ArrayList<Artifact>();
dependencies.addAll(project.getArtifacts());
for (Iterator<Artifact> it=dependencies.iterator(); it.hasNext();) {
Artifact dependency = it.next();
String scope = dependency.getScope();
String type = dependency.getType();
if (dependency.isOptional() || !"jar".equals(type) || "provided".equals(scope) || "test".equals(scope) || "system".equals(scope)) {
getLog().debug("Pruning dependency " + dependency);
it.remove();
}
}
Maven War Pluginのソースをご覧ください。特に、ArtifactsPackagingTaskクラスは、戦争へのアーティファクトの追加を処理します。http://svn.apache.org/viewvc/maven/plugins/tags/maven-war-plugin-2.1.1/src/main/java/org /apache/maven/plugin/war/packaging/ArtifactsPackagingTask.java?view=markup –