Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
[MSHARED-463] Upgrade to annotation based usage instead of XDoclet
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1712712 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
khmarbaise committed Nov 5, 2015
1 parent ed10f2b commit c83aa1a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
17 changes: 11 additions & 6 deletions maven-filtering/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>
Expand Down Expand Up @@ -64,7 +68,7 @@
<name>Graham Leggett</name>
</contributor>
</contributors>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
Expand All @@ -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>
Expand Down
Expand Up @@ -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} */
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -58,11 +60,12 @@ public class DefaultMavenResourcesFiltering

private List<String> defaultNonFilteredFileExtensions;

/**
* @plexus.requirement
*/
@Requirement
private BuildContext buildContext;

@Requirement
private MavenFileFilter mavenFileFilter;

// ------------------------------------------------
// Plexus lifecycle
// ------------------------------------------------
Expand All @@ -79,11 +82,6 @@ public void initialize()
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,
Expand Down
Expand Up @@ -48,7 +48,6 @@ public class DefaultMavenResourcesFilteringTest

File outputDirectory = new File( getBasedir(), "target/DefaultMavenResourcesFilteringTest" );

@SuppressWarnings( "ResultOfMethodCallIgnored" )
protected void setUp()
throws Exception
{
Expand All @@ -73,8 +72,7 @@ public void testSimpleFiltering()
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" );
Expand Down Expand Up @@ -118,12 +116,13 @@ public void testSessionFiltering()

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;
Expand Down Expand Up @@ -223,8 +222,9 @@ public void testWithMavenResourcesExecutionWithAdditionnalProperties()
}

@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();
Expand Down Expand Up @@ -362,7 +362,7 @@ public void testNoFiltering()
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 =
Expand Down Expand Up @@ -445,7 +445,7 @@ public void testIncludeOneFile()

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();
Expand Down Expand Up @@ -482,11 +482,11 @@ public void testIncludeOneFileAndDirectory()

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() );
Expand Down Expand Up @@ -524,7 +524,7 @@ public void testExcludeOneFile()

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();
Expand Down Expand Up @@ -581,7 +581,7 @@ public void testTargetAbsolutePath()

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();
Expand Down Expand Up @@ -616,7 +616,7 @@ public void testTargetPath()

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" );
Expand Down Expand Up @@ -648,7 +648,7 @@ public void testEmptyDirectories()
} );
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 );

Expand Down Expand Up @@ -720,7 +720,7 @@ public void testMSHARED81()
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( "\\" );

Expand All @@ -730,7 +730,8 @@ public void testMSHARED81()

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 );
Expand All @@ -744,7 +745,8 @@ public void testMSHARED81()

Properties expectedNonFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/MSHARED-81/resources",
"unfiltered.properties" ), null );
"unfiltered.properties" ),
null );

assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) );
}
Expand Down Expand Up @@ -786,7 +788,7 @@ public void testEdgeCases()
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( "\\" );

Expand All @@ -796,7 +798,8 @@ public void testEdgeCases()

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 );
Expand All @@ -810,7 +813,8 @@ public void testEdgeCases()

Properties expectedNonFilteredResult =
PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/edge-cases/resources",
"unfiltered.properties" ), null );
"unfiltered.properties" ),
null );

assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) );
}
Expand Down Expand Up @@ -839,7 +843,7 @@ public void testFilterFileName()

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 );
Expand Down

0 comments on commit c83aa1a

Please sign in to comment.