Skip to content

Commit 9316dfd

Browse files
authored
Drop legacy and make components pure JSR330 (#84)
Drop Plexus Container alltogether, components are now pure JSR330, also move from oldie PlexuesTestCase to Junit4 generally.
1 parent 6ffc902 commit 9316dfd

36 files changed

+320
-188
lines changed

pom.xml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@
3030
</distributionManagement>
3131

3232
<properties>
33-
<cobertura.skip>true</cobertura.skip>
3433
<javaVersion>8</javaVersion>
34+
<sisuVersion>0.3.5</sisuVersion>
35+
<slf4jVersion>1.7.36</slf4jVersion>
36+
<cobertura.skip>true</cobertura.skip>
3537
<project.build.outputTimestamp>2022-05-02T06:11:29Z</project.build.outputTimestamp>
3638
</properties>
3739

3840
<dependencies>
41+
<!-- JSR330 -->
3942
<dependency>
40-
<groupId>org.codehaus.plexus</groupId>
41-
<artifactId>plexus-utils</artifactId>
42-
<version>3.4.2</version>
43+
<groupId>javax.inject</groupId>
44+
<artifactId>javax.inject</artifactId>
45+
<version>1</version>
4346
</dependency>
47+
4448
<dependency>
4549
<groupId>org.codehaus.plexus</groupId>
46-
<artifactId>plexus-container-default</artifactId>
47-
<scope>test</scope>
48-
<version>2.1.1</version>
50+
<artifactId>plexus-utils</artifactId>
51+
<version>3.4.2</version>
4952
</dependency>
5053
<dependency>
5154
<groupId>com.google.code.findbugs</groupId>
@@ -58,17 +61,63 @@
5861
<artifactId>commons-io</artifactId>
5962
<version>2.11.0</version>
6063
</dependency>
64+
65+
<!-- Tests -->
6166
<dependency>
6267
<groupId>junit</groupId>
6368
<artifactId>junit</artifactId>
6469
<version>4.13.2</version>
6570
<scope>test</scope>
71+
<exclusions>
72+
<exclusion>
73+
<groupId>org.hamcrest</groupId>
74+
<artifactId>hamcrest-core</artifactId>
75+
</exclusion>
76+
</exclusions>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.hamcrest</groupId>
80+
<artifactId>hamcrest</artifactId>
81+
<version>2.2</version>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.slf4j</groupId>
86+
<artifactId>slf4j-simple</artifactId>
87+
<version>${slf4jVersion}</version>
88+
<scope>test</scope>
89+
</dependency>
90+
<!-- Sisu and dependencies -->
91+
<dependency>
92+
<groupId>org.eclipse.sisu</groupId>
93+
<artifactId>org.eclipse.sisu.inject</artifactId>
94+
<version>${sisuVersion}</version>
95+
<scope>test</scope>
96+
</dependency>
97+
<dependency>
98+
<groupId>com.google.inject</groupId>
99+
<artifactId>guice</artifactId>
100+
<version>5.1.0</version>
101+
<scope>test</scope>
66102
</dependency>
67-
68103
</dependencies>
69104

70105
<build>
71106
<plugins>
107+
<plugin>
108+
<groupId>org.eclipse.sisu</groupId>
109+
<artifactId>sisu-maven-plugin</artifactId>
110+
<version>${sisuVersion}</version>
111+
<executions>
112+
<execution>
113+
<id>index-project</id>
114+
<goals>
115+
<goal>main-index</goal>
116+
<goal>test-index</goal>
117+
</goals>
118+
</execution>
119+
</executions>
120+
</plugin>
72121
<plugin>
73122
<groupId>org.apache.maven.plugins</groupId>
74123
<artifactId>maven-scm-publish-plugin</artifactId>
@@ -128,7 +177,7 @@
128177
<configuration>
129178
<signature>
130179
<groupId>org.codehaus.mojo.signature</groupId>
131-
<artifactId>java17</artifactId>
180+
<artifactId>java18</artifactId>
132181
<version>1.0</version>
133182
</signature>
134183
</configuration>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.codehaus.plexus.components.io.filemappers;
2+
3+
/*
4+
* Copyright 2007 The Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import javax.inject.Named;
20+
21+
/**
22+
* Alias for {@link IdentityMapper}
23+
*/
24+
@Named
25+
public class DefaultFileMapper extends IdentityMapper
26+
{
27+
}

src/main/java/org/codehaus/plexus/components/io/filemappers/FileExtensionMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
2021

2122
/**
2223
* An implementation of {@link FileMapper}, which changes the files extension.
2324
*/
25+
@Named( FileExtensionMapper.ROLE_HINT )
2426
public class FileExtensionMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/filemappers/FileMapper.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
*/
2222
public interface FileMapper
2323
{
24-
/**
25-
* Role used to register component implementations with the container.
26-
*/
27-
public static final String ROLE = FileMapper.class.getName();
28-
29-
/**
30-
* The default role-hint: "default".
31-
*/
32-
public static final String DEFAULT_ROLE_HINT = "default";
33-
3424
/**
3525
* Maps the given source name to a target name.
3626
*
@@ -40,5 +30,5 @@ public interface FileMapper
4030
* @throws IllegalArgumentException
4131
* The source name is null or empty.
4232
*/
43-
public String getMappedFileName( String pName );
33+
String getMappedFileName( String pName );
4434
}

src/main/java/org/codehaus/plexus/components/io/filemappers/FlattenFileMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
2021

2122
/**
2223
* Implementation of a flattening file mapper: Removes all directory parts.
2324
*/
25+
@Named( FlattenFileMapper.ROLE_HINT )
2426
public class FlattenFileMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/filemappers/IdentityMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
2021

2122
/**
2223
* Default implementation of {@link FileMapper}, which performs the identity mapping: All names are left unchanged.
2324
*/
25+
@Named( IdentityMapper.ROLE_HINT )
2426
public class IdentityMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/filemappers/MergeFileMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
2021

2122
/**
2223
* A file mapper, which maps to a constant target name.
2324
*/
25+
@Named( MergeFileMapper.ROLE_HINT )
2426
public class MergeFileMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/filemappers/PrefixFileMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
2021

2122
/**
2223
* A file mapper, which maps by adding a prefix.
2324
*/
25+
@Named( PrefixFileMapper.ROLE_HINT )
2426
public class PrefixFileMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/filemappers/RegExpFileMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
21+
2022
import java.util.regex.Matcher;
2123
import java.util.regex.Pattern;
2224

2325
/**
2426
* Implementation of a file mapper, which uses regular expressions.
2527
*/
28+
@Named( RegExpFileMapper.ROLE_HINT )
2629
public class RegExpFileMapper
2730
extends AbstractFileMapper
2831
{

src/main/java/org/codehaus/plexus/components/io/filemappers/SuffixFileMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
*/
1616

1717
import javax.annotation.Nonnull;
18+
import javax.inject.Named;
1819

1920
/**
2021
* A file mapper, which maps by adding a suffix to the filename.
2122
* If the filename contains dot, the suffix will be added before.
2223
* Example: {@code directory/archive.tar.gz => directory/archivesuffix.tar.gz}
2324
*/
25+
@Named( SuffixFileMapper.ROLE_HINT )
2426
public class SuffixFileMapper extends AbstractFileMapper
2527
{
2628
/**

src/main/java/org/codehaus/plexus/components/io/fileselectors/AllFilesFileSelector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
*/
1818

1919
import javax.annotation.Nonnull;
20+
import javax.inject.Named;
21+
import javax.inject.Singleton;
2022

2123
/**
2224
* The default file selector: Selects all files.
2325
*/
26+
@Singleton
27+
@Named( AllFilesFileSelector.ROLE_HINT )
2428
public class AllFilesFileSelector implements FileSelector
2529
{
2630
/**
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.codehaus.plexus.components.io.fileselectors;
2+
3+
/*
4+
* Copyright 2007 The Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import javax.inject.Named;
20+
import javax.inject.Singleton;
21+
22+
/**
23+
* Alias for {@link AllFilesFileSelector}
24+
*/
25+
@Singleton
26+
@Named
27+
public class DefaultFileSelector extends AllFilesFileSelector
28+
{
29+
}

src/main/java/org/codehaus/plexus/components/io/fileselectors/FileSelector.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@
2424
*/
2525
public interface FileSelector
2626
{
27-
/**
28-
* Role used to register component implementations with the container.
29-
*/
30-
public static final String ROLE = FileSelector.class.getName();
31-
32-
/**
33-
* The default role-hint: "default".
34-
*/
35-
public static final String DEFAULT_ROLE_HINT = "default";
36-
3727
/**
3828
* Returns, whether the given file is selected.
3929
* @param fileInfo An instance of FileInfo with the files meta data.

src/main/java/org/codehaus/plexus/components/io/fileselectors/IncludeExcludeFileSelector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424

2525
import javax.annotation.Nonnull;
2626
import javax.annotation.Nullable;
27+
import javax.inject.Named;
2728

2829
/**
2930
* This file selector uses a set of patterns for including/excluding
3031
* files.
3132
*/
33+
@Named( IncludeExcludeFileSelector.ROLE_HINT )
3234
public class IncludeExcludeFileSelector
3335
implements FileSelector
3436
{

src/main/java/org/codehaus/plexus/components/io/functions/SymlinkDestinationSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
*/
2424
public interface SymlinkDestinationSupplier
2525
{
26-
public String getSymlinkDestination()
26+
String getSymlinkDestination()
2727
throws IOException;
2828
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.codehaus.plexus.components.io.resources;
2+
3+
/*
4+
* Copyright 2007 The Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import javax.inject.Named;
20+
21+
/**
22+
* Alias for {@link PlexusIoFileResourceCollection}
23+
*/
24+
@Named
25+
public class DefaultPlexusIoFileResourceCollection
26+
extends PlexusIoFileResourceCollection
27+
{
28+
}

src/main/java/org/codehaus/plexus/components/io/resources/EncodingSupported.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ public interface EncodingSupported
2727
* Supplies the encoding to be used for decoding filenames/paths
2828
* @param charset The charset to use
2929
*/
30-
public void setEncoding( Charset charset );
30+
void setEncoding( Charset charset );
3131
}

src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResourceCollection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
import javax.inject.Named;
20+
1921
import org.codehaus.plexus.components.io.attributes.FileAttributes;
2022
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
2123
import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes;
@@ -39,6 +41,7 @@
3941
* Implementation of {@link PlexusIoResourceCollection} for the set
4042
* of files in a common directory.
4143
*/
44+
@Named( PlexusIoFileResourceCollection.ROLE_HINT )
4245
public class PlexusIoFileResourceCollection
4346
extends AbstractPlexusIoResourceCollectionWithAttributes
4447
{

0 commit comments

Comments
 (0)