[MSHARED-463] Upgrade to annotation based usage instead of XDoclet
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1712712 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 20ff47b..4b500bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,23 +1,27 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
+ or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
+ 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
+ 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
+ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-<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/xsd/maven-4.0.0.xsd">
+<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/xsd/maven-4.0.0.xsd"
+>
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -64,7 +68,7 @@
<name>Graham Leggett</name>
</contributor>
</contributors>
-
+
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -91,6 +95,7 @@
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
+
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
diff --git a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
index ed21831..5f2251c 100644
--- a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
+++ b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java
@@ -43,25 +43,23 @@
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
import org.apache.maven.shared.utils.io.IOUtil;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.sonatype.plexus.build.incremental.BuildContext;
/**
* @author Olivier Lamy
- * @plexus.component role="org.apache.maven.shared.filtering.MavenFileFilter" role-hint="default"
*/
+@Component( role = org.apache.maven.shared.filtering.MavenFileFilter.class, hint = "default" )
public class DefaultMavenFileFilter
extends BaseFilter
implements MavenFileFilter
{
- /**
- * @plexus.requirement
- */
+ @Requirement
private MavenReaderFilter readerFilter;
- /**
- * @plexus.requirement
- */
+ @Requirement
private BuildContext buildContext;
/** {@inheritDoc} */
diff --git a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java
index 6e608c6..c5821cd 100644
--- a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java
+++ b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java
@@ -28,11 +28,12 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
+import org.codehaus.plexus.component.annotations.Component;
/**
* @author Kristian Rosenvold
- * @plexus.component role="org.apache.maven.shared.filtering.MavenReaderFilter" role-hint="default"
*/
+@Component( role = org.apache.maven.shared.filtering.MavenReaderFilter.class, hint = "default" )
public class DefaultMavenReaderFilter
extends BaseFilter
implements MavenReaderFilter
diff --git a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
index b694caf..a6e76b7 100644
--- a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
+++ b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
@@ -37,6 +37,8 @@
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
import org.apache.maven.shared.utils.io.IOUtil;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -45,8 +47,8 @@
/**
* @author Olivier Lamy
- * @plexus.component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" role-hint="default"
*/
+@Component( role = MavenResourcesFiltering.class, hint = "default" )
public class DefaultMavenResourcesFiltering
extends AbstractLogEnabled
implements MavenResourcesFiltering, Initializable
@@ -58,11 +60,12 @@
private List<String> defaultNonFilteredFileExtensions;
- /**
- * @plexus.requirement
- */
+ @Requirement
private BuildContext buildContext;
+ @Requirement
+ private MavenFileFilter mavenFileFilter;
+
// ------------------------------------------------
// Plexus lifecycle
// ------------------------------------------------
@@ -79,11 +82,6 @@
this.defaultNonFilteredFileExtensions.add( "png" );
}
- /**
- * @plexus.requirement role-hint="default"
- */
- private MavenFileFilter mavenFileFilter;
-
/** {@inheritDoc} */
public void filterResources( List<Resource> resources, File outputDirectory, MavenProject mavenProject,
String encoding, List<String> fileFilters, List<String> nonFilteredFileExtensions,
diff --git a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
index 27263eb..8c198cc 100644
--- a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
@@ -48,7 +48,6 @@
File outputDirectory = new File( getBasedir(), "target/DefaultMavenResourcesFilteringTest" );
- @SuppressWarnings( "ResultOfMethodCallIgnored" )
protected void setUp()
throws Exception
{
@@ -73,8 +72,7 @@
projectProperties.put( "foo", "bar" );
projectProperties.put( "java.version", "zloug" );
mavenProject.setProperties( projectProperties );
- MavenResourcesFiltering mavenResourcesFiltering =
- (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() );
+ MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -118,12 +116,13 @@
Settings settings = new Settings();
settings.setLocalRepository( System.getProperty( "localRepository",
- System.getProperty( "maven.repo.local", "/path/to/local/repo" ) ) );
+ System.getProperty( "maven.repo.local",
+ "/path/to/local/repo" ) ) );
MavenSession session = new StubMavenSession( settings );
mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), session );
+ Collections.<String>emptyList(), session );
Properties result = new Properties();
FileInputStream in = null;
@@ -223,8 +222,9 @@
}
@SuppressWarnings( "ConstantConditions" )
- private void assertFiltering( File baseDir, File initialImageFile, boolean escapeTest, boolean additionnalProperties )
- throws Exception
+ private void assertFiltering( File baseDir, File initialImageFile, boolean escapeTest,
+ boolean additionnalProperties )
+ throws Exception
{
assertEquals( 7, outputDirectory.listFiles().length );
Properties result = new Properties();
@@ -362,7 +362,7 @@
resource.setDirectory( unitFilesDir );
resource.setFiltering( false );
mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", null,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
assertEquals( 7, outputDirectory.listFiles().length );
Properties result =
@@ -445,7 +445,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
@@ -482,11 +482,11 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
- assertNotNull( files);
+ assertNotNull( files );
assertEquals( 2, files.length );
File includeFile = new File( outputDirectory, "includefile.txt" );
assertTrue( includeFile.exists() );
@@ -524,7 +524,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
@@ -581,7 +581,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = targetPathFile.listFiles();
@@ -616,7 +616,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File targetPathFile = new File( outputDirectory, "testTargetPath" );
@@ -648,7 +648,7 @@
} );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", Collections.EMPTY_LIST,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
@@ -720,7 +720,7 @@
File output = new File( outputDirectory, "MSHARED-81" );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.EMPTY_LIST,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setEscapeString( "\\" );
@@ -730,7 +730,8 @@
Properties expectedFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/MSHARED-81",
- "expected-filtered.properties" ), null );
+ "expected-filtered.properties" ),
+ null );
System.out.println( "\nExpected:\n" );
expectedFilteredResult.list( System.out );
@@ -744,7 +745,8 @@
Properties expectedNonFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/MSHARED-81/resources",
- "unfiltered.properties" ), null );
+ "unfiltered.properties" ),
+ null );
assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) );
}
@@ -786,7 +788,7 @@
File output = new File( outputDirectory, "edge-cases" );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.EMPTY_LIST,
- Collections.<String> emptyList(), new StubMavenSession() );
+ Collections.<String>emptyList(), new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setEscapeString( "\\" );
@@ -796,7 +798,8 @@
Properties expectedFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/edge-cases",
- "expected-filtered.properties" ), null );
+ "expected-filtered.properties" ),
+ null );
System.out.println( "\nExpected:\n" );
expectedFilteredResult.list( System.out );
@@ -810,7 +813,8 @@
Properties expectedNonFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/edge-cases/resources",
- "unfiltered.properties" ), null );
+ "unfiltered.properties" ),
+ null );
assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) );
}
@@ -839,7 +843,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( Collections.singletonList( resource ), outputDirectory, mavenProject, "UTF-8",
- Collections.<String> emptyList(), Collections.<String> emptyList(),
+ Collections.<String>emptyList(), Collections.<String>emptyList(),
new StubMavenSession() );
mavenResourcesExecution.setFilterFilenames( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );