Skip to content

Drop legacy and make components pure JSR330 #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 58 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@
</distributionManagement>

<properties>
<cobertura.skip>true</cobertura.skip>
<javaVersion>8</javaVersion>
<sisuVersion>0.3.5</sisuVersion>
<slf4jVersion>1.7.36</slf4jVersion>
<cobertura.skip>true</cobertura.skip>
<project.build.outputTimestamp>2022-05-02T06:11:29Z</project.build.outputTimestamp>
</properties>

<dependencies>
<!-- JSR330 -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.4.2</version>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<scope>test</scope>
<version>2.1.1</version>
<artifactId>plexus-utils</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand All @@ -58,17 +61,63 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<!-- Sisu and dependencies -->
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>${sisuVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>${sisuVersion}</version>
<executions>
<execution>
<id>index-project</id>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
Expand Down Expand Up @@ -128,7 +177,7 @@
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java17</artifactId>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.codehaus.plexus.components.io.filemappers;

/*
* Copyright 2007 The Codehaus Foundation.
*
* Licensed 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 javax.inject.Named;

/**
* Alias for {@link IdentityMapper}
*/
@Named
public class DefaultFileMapper extends IdentityMapper
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* An implementation of {@link FileMapper}, which changes the files extension.
*/
@Named( FileExtensionMapper.ROLE_HINT )
public class FileExtensionMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@
*/
public interface FileMapper
{
/**
* Role used to register component implementations with the container.
*/
public static final String ROLE = FileMapper.class.getName();

/**
* The default role-hint: "default".
*/
public static final String DEFAULT_ROLE_HINT = "default";

/**
* Maps the given source name to a target name.
*
Expand All @@ -40,5 +30,5 @@ public interface FileMapper
* @throws IllegalArgumentException
* The source name is null or empty.
*/
public String getMappedFileName( String pName );
String getMappedFileName( String pName );
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* Implementation of a flattening file mapper: Removes all directory parts.
*/
@Named( FlattenFileMapper.ROLE_HINT )
public class FlattenFileMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* Default implementation of {@link FileMapper}, which performs the identity mapping: All names are left unchanged.
*/
@Named( IdentityMapper.ROLE_HINT )
public class IdentityMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* A file mapper, which maps to a constant target name.
*/
@Named( MergeFileMapper.ROLE_HINT )
public class MergeFileMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* A file mapper, which maps by adding a prefix.
*/
@Named( PrefixFileMapper.ROLE_HINT )
public class PrefixFileMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Implementation of a file mapper, which uses regular expressions.
*/
@Named( RegExpFileMapper.ROLE_HINT )
public class RegExpFileMapper
extends AbstractFileMapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;

/**
* A file mapper, which maps by adding a suffix to the filename.
* If the filename contains dot, the suffix will be added before.
* Example: {@code directory/archive.tar.gz => directory/archivesuffix.tar.gz}
*/
@Named( SuffixFileMapper.ROLE_HINT )
public class SuffixFileMapper extends AbstractFileMapper
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
*/

import javax.annotation.Nonnull;
import javax.inject.Named;
import javax.inject.Singleton;

/**
* The default file selector: Selects all files.
*/
@Singleton
@Named( AllFilesFileSelector.ROLE_HINT )
public class AllFilesFileSelector implements FileSelector
{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.codehaus.plexus.components.io.fileselectors;

/*
* Copyright 2007 The Codehaus Foundation.
*
* Licensed 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 javax.inject.Named;
import javax.inject.Singleton;

/**
* Alias for {@link AllFilesFileSelector}
*/
@Singleton
@Named
public class DefaultFileSelector extends AllFilesFileSelector
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@
*/
public interface FileSelector
{
/**
* Role used to register component implementations with the container.
*/
public static final String ROLE = FileSelector.class.getName();

/**
* The default role-hint: "default".
*/
public static final String DEFAULT_ROLE_HINT = "default";

/**
* Returns, whether the given file is selected.
* @param fileInfo An instance of FileInfo with the files meta data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Named;

/**
* This file selector uses a set of patterns for including/excluding
* files.
*/
@Named( IncludeExcludeFileSelector.ROLE_HINT )
public class IncludeExcludeFileSelector
implements FileSelector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
*/
public interface SymlinkDestinationSupplier
{
public String getSymlinkDestination()
String getSymlinkDestination()
throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.codehaus.plexus.components.io.resources;

/*
* Copyright 2007 The Codehaus Foundation.
*
* Licensed 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 javax.inject.Named;

/**
* Alias for {@link PlexusIoFileResourceCollection}
*/
@Named
public class DefaultPlexusIoFileResourceCollection
extends PlexusIoFileResourceCollection
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public interface EncodingSupported
* Supplies the encoding to be used for decoding filenames/paths
* @param charset The charset to use
*/
public void setEncoding( Charset charset );
void setEncoding( Charset charset );
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

import javax.inject.Named;

import org.codehaus.plexus.components.io.attributes.FileAttributes;
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes;
Expand All @@ -39,6 +41,7 @@
* Implementation of {@link PlexusIoResourceCollection} for the set
* of files in a common directory.
*/
@Named( PlexusIoFileResourceCollection.ROLE_HINT )
public class PlexusIoFileResourceCollection
extends AbstractPlexusIoResourceCollectionWithAttributes
{
Expand Down
Loading