[MWAR-379] manifest goal violates general Maven principle and creates file into src/main/..
o Removed the whole goal cause everything can be handled with
MavenArchiver configuration.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1756987 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugins/war/WarManifestMojo.java b/src/main/java/org/apache/maven/plugins/war/WarManifestMojo.java
deleted file mode 100644
index 7d1901b..0000000
--- a/src/main/java/org/apache/maven/plugins/war/WarManifestMojo.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.apache.maven.plugins.war;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archiver.MavenArchiver;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.jar.Manifest;
-import org.codehaus.plexus.archiver.jar.ManifestException;
-import org.codehaus.plexus.archiver.war.WarArchiver;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.WriterFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * Generate a manifest for this webapp. The manifest file is created in the <code>warSourceDirectory</code>.
- *
- * @author Mike Perham
- * @version $Id$
- */
-// CHECKSTYLE_OFF: LineLength
-@Mojo( name = "manifest", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true, requiresDependencyResolution = ResolutionScope.RUNTIME )
-// CHECKSTYLE_ON: LineLength
-public class WarManifestMojo
- extends AbstractWarMojo
-{
- /**
- * The WAR archiver.
- */
- @Component( role = Archiver.class, hint = "war" )
- private WarArchiver warArchiver;
-
- /**
- * Executes this mojo on the current project.
- *
- * @throws MojoExecutionException if an error occurred while building the webapp
- */
- public void execute()
- throws MojoExecutionException
- {
- File manifestDir = new File( getWarSourceDirectory(), "META-INF" );
- if ( !manifestDir.exists() )
- {
- manifestDir.mkdirs();
- }
- File manifestFile = new File( manifestDir, "MANIFEST.MF" );
- MavenArchiver ma = new MavenArchiver();
- ma.setArchiver( warArchiver );
- ma.setOutputFile( manifestFile );
-
- PrintWriter printWriter = null;
- try
- {
- Manifest mf = ma.getManifest( getSession(), getProject(), getArchive() );
- printWriter = new PrintWriter( WriterFactory.newWriter( manifestFile, WriterFactory.UTF_8 ) );
- mf.write( printWriter );
- printWriter.close();
- printWriter = null;
- }
- catch ( ManifestException e )
- {
- throw new MojoExecutionException( "Error preparing the manifest: " + e.getMessage(), e );
- }
- catch ( DependencyResolutionRequiredException e )
- {
- throw new MojoExecutionException( "Error preparing the manifest: " + e.getMessage(), e );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error preparing the manifest: " + e.getMessage(), e );
- }
- finally
- {
- IOUtil.close( printWriter );
- }
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/war/WarManifestMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarManifestMojoTest.java
deleted file mode 100644
index 7e04c07..0000000
--- a/src/test/java/org/apache/maven/plugins/war/WarManifestMojoTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package org.apache.maven.plugins.war;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.apache.maven.archiver.MavenArchiveConfiguration;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * @author Allan Ramirez
- */
-public class WarManifestMojoTest
- extends AbstractMojoTestCase
-{
- File testPom;
-
- WarManifestMojo mojo;
-
- public void testEnvironment()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/basic-manifest-test/plugin-config.xml" );
- }
-
- public void testBasicManifest()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/basic-manifest-test/plugin-config.xml" );
-
- mojo.execute();
-
- File warSourceDir = (File) getVariableValueFromObject( mojo, "warSourceDirectory" );
-
- File manifestDir = new File( warSourceDir, "META-INF" );
-
- File manifest = new File( manifestDir, "MANIFEST.MF" );
-
- assertTrue( manifest.exists() );
- }
-
- public void testManifestWithClasspath()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/manifest-with-classpath/plugin-config.xml" );
-
- MavenArchiveConfiguration config = (MavenArchiveConfiguration) getVariableValueFromObject( mojo, "archive" );
-
- mojo.execute();
-
- assertTrue( config.getManifest().isAddClasspath() );
-
- File warSourceDir = (File) getVariableValueFromObject( mojo, "warSourceDirectory" );
-
- File manifestDir = new File( warSourceDir, "META-INF" );
-
- File manifest = new File( manifestDir, "MANIFEST.MF" );
-
- assertTrue( manifest.exists() );
-
- String content = FileUtils.fileRead( manifest );
-
- int idx = content.indexOf( "Class-Path" );
-
- assertTrue( idx >= 0 );
- }
-
- public void testManifestWithMainClass()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/manifest-with-main-class/plugin-config.xml" );
-
- MavenArchiveConfiguration config = (MavenArchiveConfiguration) getVariableValueFromObject( mojo, "archive" );
-
- mojo.execute();
-
- assertEquals( "org.dummy.test.SomeClass", config.getManifest().getMainClass() );
-
- File warSourceDir = (File) getVariableValueFromObject( mojo, "warSourceDirectory" );
-
- File manifestDir = new File( warSourceDir, "META-INF" );
-
- File manifest = new File( manifestDir, "MANIFEST.MF" );
-
- assertTrue( manifest.exists() );
-
- String content = FileUtils.fileRead( manifest );
-
- int idx = content.indexOf( "Main-Class" );
-
- assertTrue( idx >= 0 );
- }
-
- public void testManifestWithOtherAttributes()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/manifest-with-other-attrs/plugin-config.xml" );
-
- MavenArchiveConfiguration config = (MavenArchiveConfiguration) getVariableValueFromObject( mojo, "archive" );
-
- DefaultArtifact da = new DefaultArtifact( "org.apache.test", "xyz", "2.0.0", Artifact.SCOPE_COMPILE, "jar", "", null );
- mojo.getProject().setArtifact( da );
-
- mojo.execute();
-
- assertTrue( config.getManifest().isAddExtensions() );
-
- File warSourceDir = (File) getVariableValueFromObject( mojo, "warSourceDirectory" );
-
- File manifestDir = new File( warSourceDir, "META-INF" );
-
- File manifest = new File( manifestDir, "MANIFEST.MF" );
-
- assertTrue( manifest.exists() );
-
- String content = FileUtils.fileRead( manifest );
-
- int idx = content.indexOf( "Specification-Title" );
-
- assertTrue( idx >= 0 );
-
- idx = content.indexOf( "Specification-Vendor" );
-
- assertTrue( idx >= 0 );
-
- idx = content.indexOf( "Implementation-Vendor" );
-
- assertTrue( idx >= 0 );
- }
-
- public void testManifestWithCustomAttributes()
- throws Exception
- {
- loadMojo( "target/test-classes/unit/manifest/manifest-with-custom-attrs/plugin-config.xml" );
-
- DefaultArtifact da = new DefaultArtifact( "org.apache.test", "xyz", "2.0.0", Artifact.SCOPE_COMPILE, "jar", "", null );
- mojo.getProject().setArtifact( da );
-
- MavenArchiveConfiguration config = (MavenArchiveConfiguration) getVariableValueFromObject( mojo, "archive" );
-
- mojo.execute();
-
- assertTrue( config.getManifest().isAddExtensions() );
-
- File warSourceDir = (File) getVariableValueFromObject( mojo, "warSourceDirectory" );
-
- File manifestDir = new File( warSourceDir, "META-INF" );
-
- File manifest = new File( manifestDir, "MANIFEST.MF" );
-
- assertTrue( manifest.exists() );
-
- String content = FileUtils.fileRead( manifest );
-
- int idx = content.indexOf( "Specification-Title" );
-
- assertTrue( idx >= 0 );
-
- idx = content.indexOf( "Custom-Version" );
-
- assertTrue( idx >= 0 );
-
- }
-
- public void loadMojo( String pluginXml )
- throws Exception
- {
- testPom = new File( getBasedir(), pluginXml );
-
- mojo = (WarManifestMojo) lookupMojo( "manifest", testPom );
-
- assertNotNull( mojo );
- }
-}
diff --git a/src/test/resources/unit/manifest/basic-manifest-test/plugin-config.xml b/src/test/resources/unit/manifest/basic-manifest-test/plugin-config.xml
deleted file mode 100644
index 4c99b21..0000000
--- a/src/test/resources/unit/manifest/basic-manifest-test/plugin-config.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.war.stub.MavenProjectBasicStub" />
- <warSourceDirectory>${basedir}/target/test-classes/unit/manifest/basic-manifest-test/src/main</warSourceDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/manifest/manifest-with-classpath/plugin-config.xml b/src/test/resources/unit/manifest/manifest-with-classpath/plugin-config.xml
deleted file mode 100644
index fd94630..0000000
--- a/src/test/resources/unit/manifest/manifest-with-classpath/plugin-config.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub"/>
- <warSourceDirectory>
- ${basedir}/target/test-classes/unit/manifest/manifest-with-classpath/src/main</warSourceDirectory>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar b/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar
deleted file mode 100644
index e69de29..0000000
--- a/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact1-1.0-SNAPSHOT.jar
+++ /dev/null
diff --git a/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar b/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar
deleted file mode 100644
index e69de29..0000000
--- a/src/test/resources/unit/manifest/manifest-with-classpath/sample-artifacts/maven-artifact2-1.0-SNAPSHOT.jar
+++ /dev/null
diff --git a/src/test/resources/unit/manifest/manifest-with-custom-attrs/plugin-config.xml b/src/test/resources/unit/manifest/manifest-with-custom-attrs/plugin-config.xml
deleted file mode 100644
index 60bc2d9..0000000
--- a/src/test/resources/unit/manifest/manifest-with-custom-attrs/plugin-config.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.war.stub.MavenProjectBasicStub"/>
- <warSourceDirectory>
- ${basedir}/target/test-classes/unit/manifest/manifest-with-custom-attrs/src/main</warSourceDirectory>
- <archive>
- <manifest>
- <addExtensions>true</addExtensions>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- </manifest>
- <manifestEntries>
- <Custom-Version>2.0</Custom-Version>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/manifest/manifest-with-main-class/plugin-config.xml b/src/test/resources/unit/manifest/manifest-with-main-class/plugin-config.xml
deleted file mode 100644
index 078b547..0000000
--- a/src/test/resources/unit/manifest/manifest-with-main-class/plugin-config.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub" />
- <warSourceDirectory>${basedir}/target/test-classes/unit/manifest/manifest-with-main-class/src/main</warSourceDirectory>
- <archive>
- <manifest>
- <mainClass>org.dummy.test.SomeClass</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/manifest/manifest-with-other-attrs/plugin-config.xml b/src/test/resources/unit/manifest/manifest-with-other-attrs/plugin-config.xml
deleted file mode 100644
index 66d2484..0000000
--- a/src/test/resources/unit/manifest/manifest-with-other-attrs/plugin-config.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.war.stub.MavenProjectBasicStub"/>
- <warSourceDirectory>
- ${basedir}/target/test-classes/unit/manifest/manifest-with-other-attrs/src/main</warSourceDirectory>
- <archive>
- <manifest>
- <addExtensions>true</addExtensions>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>