Skip to content

Commit 94d29ac

Browse files
committed
Drop legacy
Drop: - plexus container default - legacy plexus APIs like Contextualizable - drop Plexus Logger uses - some minor cleanups for Java8 level - converted Plexus XML to JSR330
1 parent 337214c commit 94d29ac

File tree

122 files changed

+1820
-895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1820
-895
lines changed

pom.xml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
<properties>
3434
<javaVersion>8</javaVersion>
35+
<sisuVersion>0.3.5</sisuVersion>
36+
<slf4jVersion>1.7.36</slf4jVersion>
3537
<project.build.outputTimestamp>2022-06-10T17:04:57Z</project.build.outputTimestamp>
3638
</properties>
3739

@@ -49,13 +51,25 @@
4951
</contributors>
5052

5153
<dependencies>
52-
<!-- Plexus dependencies -->
54+
<!-- Plexus container dependencies -->
5355
<dependency>
54-
<groupId>org.codehaus.plexus</groupId>
55-
<artifactId>plexus-container-default</artifactId>
56-
<version>2.1.1</version>
56+
<groupId>javax.inject</groupId>
57+
<artifactId>javax.inject</artifactId>
58+
<version>1</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.eclipse.sisu</groupId>
62+
<artifactId>org.eclipse.sisu.plexus</artifactId>
63+
<version>${sisuVersion}</version>
5764
<scope>provided</scope>
5865
</dependency>
66+
<dependency>
67+
<groupId>com.google.inject</groupId>
68+
<artifactId>guice</artifactId>
69+
<version>5.1.0</version>
70+
<scope>provided</scope>
71+
</dependency>
72+
<!-- Plexus dependencies -->
5973
<dependency>
6074
<groupId>org.codehaus.plexus</groupId>
6175
<artifactId>plexus-utils</artifactId>
@@ -78,6 +92,11 @@
7892
<version>1.21</version>
7993
</dependency>
8094
<!-- Other dependencies -->
95+
<dependency>
96+
<groupId>org.slf4j</groupId>
97+
<artifactId>slf4j-api</artifactId>
98+
<version>${slf4jVersion}</version>
99+
</dependency>
81100
<dependency>
82101
<groupId>org.iq80.snappy</groupId>
83102
<artifactId>snappy</artifactId>
@@ -101,6 +120,23 @@
101120
<artifactId>junit</artifactId>
102121
<version>4.13.2</version>
103122
<scope>test</scope>
123+
<exclusions>
124+
<exclusion>
125+
<groupId>org.hamcrest</groupId>
126+
<artifactId>hamcrest-core</artifactId>
127+
</exclusion>
128+
</exclusions>
129+
</dependency>
130+
<dependency>
131+
<groupId>org.hamcrest</groupId>
132+
<artifactId>hamcrest</artifactId>
133+
<version>2.2</version>
134+
<scope>test</scope>
135+
</dependency>
136+
<dependency>
137+
<groupId>org.slf4j</groupId>
138+
<artifactId>slf4j-simple</artifactId>
139+
<version>${slf4jVersion}</version>
104140
</dependency>
105141
</dependencies>
106142

@@ -127,12 +163,15 @@
127163
<version>2.7</version>
128164
</plugin>
129165
<plugin>
130-
<groupId>org.codehaus.plexus</groupId>
131-
<artifactId>plexus-component-metadata</artifactId>
166+
<groupId>org.eclipse.sisu</groupId>
167+
<artifactId>sisu-maven-plugin</artifactId>
168+
<version>${sisuVersion}</version>
132169
<executions>
133170
<execution>
171+
<id>index-project</id>
134172
<goals>
135-
<goal>generate-metadata</goal>
173+
<goal>main-index</goal>
174+
<goal>test-index</goal>
136175
</goals>
137176
</execution>
138177
</executions>

src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java

Lines changed: 26 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import java.util.NoSuchElementException;
3535
import java.util.Set;
3636
import javax.annotation.Nonnull;
37-
import org.codehaus.plexus.PlexusConstants;
38-
import org.codehaus.plexus.PlexusContainer;
37+
import javax.inject.Inject;
38+
import javax.inject.Provider;
39+
3940
import org.codehaus.plexus.archiver.manager.ArchiverManager;
4041
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
41-
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
4242
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
4343
import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes;
4444
import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier;
@@ -49,21 +49,22 @@
4949
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
5050
import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
5151
import org.codehaus.plexus.components.io.resources.proxy.PlexusIoProxyResourceCollection;
52-
import org.codehaus.plexus.context.Context;
53-
import org.codehaus.plexus.context.ContextException;
54-
import org.codehaus.plexus.logging.AbstractLogEnabled;
55-
import org.codehaus.plexus.logging.Logger;
56-
import org.codehaus.plexus.logging.console.ConsoleLogger;
57-
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
52+
import org.slf4j.Logger;
53+
import org.slf4j.LoggerFactory;
54+
5855
import static org.codehaus.plexus.archiver.util.DefaultArchivedFileSet.archivedFileSet;
5956
import static org.codehaus.plexus.archiver.util.DefaultFileSet.fileSet;
6057

6158
public abstract class AbstractArchiver
62-
extends AbstractLogEnabled
63-
implements Archiver, Contextualizable, FinalizerEnabled
59+
implements Archiver, FinalizerEnabled
6460
{
6561

66-
private Logger logger;
62+
private final Logger logger = LoggerFactory.getLogger( getClass() );
63+
64+
protected Logger getLogger()
65+
{
66+
return logger;
67+
}
6768

6869
private File destFile;
6970

@@ -135,8 +136,12 @@ public abstract class AbstractArchiver
135136
*/
136137
private String overrideGroupName;
137138

138-
// contextualized.
139-
private ArchiverManager archiverManager;
139+
/**
140+
* Injected: Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg
141+
* instantiation/composition problem.
142+
*/
143+
@Inject
144+
private Provider<ArchiverManager> archiverManagerProvider;
140145

141146
private static class AddedResourceCollection
142147
{
@@ -186,7 +191,7 @@ public void setDuplicateBehavior( final String duplicate )
186191
if ( !Archiver.DUPLICATES_VALID_BEHAVIORS.contains( duplicate ) )
187192
{
188193
throw new IllegalArgumentException(
189-
"Invalid duplicate-file behavior: \'" + duplicate + "\'. Please specify one of: "
194+
"Invalid duplicate-file behavior: '" + duplicate + "'. Please specify one of: "
190195
+ Archiver.DUPLICATES_VALID_BEHAVIORS );
191196
}
192197

@@ -524,15 +529,15 @@ public ResourceIterator getResources()
524529
return new ResourceIterator()
525530
{
526531

527-
private final Iterator addedResourceIter = resources.iterator();
532+
private final Iterator<Object> addedResourceIter = resources.iterator();
528533

529534
private AddedResourceCollection currentResourceCollection;
530535

531536
private Iterator ioResourceIter;
532537

533538
private ArchiveEntry nextEntry;
534539

535-
private final Set<String> seenEntries = new HashSet<String>();
540+
private final Set<String> seenEntries = new HashSet<>();
536541

537542
@Override
538543
public boolean hasNext()
@@ -727,24 +732,6 @@ public void setDestFile( final File destFile )
727732
}
728733
}
729734

730-
@Override
731-
protected Logger getLogger()
732-
{
733-
if ( logger == null )
734-
{
735-
if ( super.getLogger() != null )
736-
{
737-
logger = super.getLogger();
738-
}
739-
else
740-
{
741-
logger = new ConsoleLogger( Logger.LEVEL_INFO, "console" );
742-
}
743-
}
744-
745-
return logger;
746-
}
747-
748735
protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet, Charset charset )
749736
throws ArchiverException
750737
{
@@ -753,7 +740,7 @@ protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet
753740
final PlexusIoResourceCollection resources;
754741
try
755742
{
756-
resources = archiverManager.getResourceCollection( archiveFile );
743+
resources = archiverManagerProvider.get().getResourceCollection( archiveFile );
757744
}
758745
catch ( final NoSuchArchiverException e )
759746
{
@@ -880,26 +867,6 @@ public void addArchivedFileSet( @Nonnull final File archiveFile )
880867
addArchivedFileSet( archivedFileSet( archiveFile ).includeEmptyDirs( includeEmptyDirs ) );
881868
}
882869

883-
/**
884-
* Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg
885-
* instantiation/composition problem.
886-
*/
887-
@Override
888-
public void contextualize( final Context context )
889-
throws ContextException
890-
{
891-
final PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
892-
893-
try
894-
{
895-
archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE );
896-
}
897-
catch ( final ComponentLookupException e )
898-
{
899-
throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e );
900-
}
901-
}
902-
903870
@Override
904871
public boolean isForced()
905872
{
@@ -917,7 +884,7 @@ public void addArchiveFinalizer( final ArchiveFinalizer finalizer )
917884
{
918885
if ( finalizers == null )
919886
{
920-
finalizers = new ArrayList<ArchiveFinalizer>();
887+
finalizers = new ArrayList<>();
921888
}
922889

923890
finalizers.add( finalizer );
@@ -946,7 +913,7 @@ protected boolean isUptodate()
946913
}
947914
final long destTimestamp = getFileLastModifiedTime(zipFile);
948915

949-
final Iterator it = resources.iterator();
916+
final Iterator<Object> it = resources.iterator();
950917
if ( !it.hasNext() )
951918
{
952919
getLogger().debug( "isUp2date: false (No input files.)" );
@@ -1314,14 +1281,7 @@ public void configureReproducibleBuild( FileTime lastModifiedTime )
13141281
setLastModifiedTime( normalizeLastModifiedTime ( lastModifiedTime ) );
13151282

13161283
// 2. sort filenames in each directory when scanning filesystem
1317-
setFilenameComparator( new Comparator<String>()
1318-
{
1319-
@Override
1320-
public int compare( String s1, String s2 )
1321-
{
1322-
return s1.compareTo( s2 );
1323-
}
1324-
} );
1284+
setFilenameComparator( String::compareTo );
13251285

13261286
// 3. ignore file/directory mode from filesystem, since they may vary based on local user umask
13271287
// notice: this overrides execute bit on Unix (that is already ignored on Windows)

src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,34 @@
2626
import java.util.Date;
2727
import java.util.List;
2828
import java.util.Locale;
29+
import java.util.concurrent.atomic.AtomicInteger;
30+
import java.util.concurrent.atomic.LongAdder;
2931

3032
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
3133
import org.codehaus.plexus.components.io.attributes.SymlinkUtils;
3234
import org.codehaus.plexus.components.io.filemappers.FileMapper;
3335
import org.codehaus.plexus.components.io.fileselectors.FileSelector;
3436
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
35-
import org.codehaus.plexus.logging.AbstractLogEnabled;
3637
import org.codehaus.plexus.util.FileUtils;
3738
import org.codehaus.plexus.util.IOUtil;
3839
import org.codehaus.plexus.util.StringUtils;
40+
import org.slf4j.Logger;
41+
import org.slf4j.LoggerFactory;
3942

4043
// TODO there should really be constructors which take the source file.
4144

4245
/**
4346
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
4447
*/
4548
public abstract class AbstractUnArchiver
46-
extends AbstractLogEnabled
4749
implements UnArchiver, FinalizerEnabled
4850
{
51+
private final Logger logger = LoggerFactory.getLogger( getClass() );
52+
53+
protected Logger getLogger()
54+
{
55+
return logger;
56+
}
4957

5058
private File destDirectory;
5159

@@ -384,6 +392,11 @@ else if ( isDirectory )
384392
}
385393
}
386394

395+
/**
396+
* Counter for casing message emitted, visible for testing.
397+
*/
398+
final AtomicInteger casingMessageEmitted = new AtomicInteger( 0 );
399+
387400
// Visible for testing
388401
protected boolean shouldExtractEntry( File targetDirectory, File targetFileName, String entryName, Date entryDate ) throws IOException
389402
{
@@ -423,6 +436,7 @@ protected boolean shouldExtractEntry( File targetDirectory, File targetFileName,
423436
if ( differentCasing )
424437
{
425438
getLogger().warn( casingMessage );
439+
casingMessageEmitted.incrementAndGet();
426440
}
427441
return false;
428442
}
@@ -431,6 +445,7 @@ protected boolean shouldExtractEntry( File targetDirectory, File targetFileName,
431445
if ( differentCasing )
432446
{
433447
getLogger().warn( casingMessage );
448+
casingMessageEmitted.incrementAndGet();
434449
}
435450

436451
// (2)

src/main/java/org/codehaus/plexus/archiver/ArchiveEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ArchiveEntry
4040

4141
public static final int SYMLINK = 3;
4242

43-
@Nonnull private PlexusIoResource resource;
43+
@Nonnull private final PlexusIoResource resource;
4444

4545
private final String name;
4646

src/main/java/org/codehaus/plexus/archiver/ArchiveFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface ArchiveFile
1515
* Any element returned by the enumeration is an instance
1616
* of {@link org.apache.commons.compress.archivers.ArchiveEntry}.
1717
*/
18-
public Enumeration<? extends org.apache.commons.compress.archivers.ArchiveEntry> getEntries()
18+
Enumeration<? extends org.apache.commons.compress.archivers.ArchiveEntry> getEntries()
1919
throws IOException;
2020

2121
/**

src/main/java/org/codehaus/plexus/archiver/Archiver.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@ public interface Archiver
4848
*/
4949
int DEFAULT_SYMLILNK_MODE = UnixStat.LINK_FLAG | UnixStat.DEFAULT_LINK_PERM;
5050

51-
String ROLE = Archiver.class.getName();
51+
String DUPLICATES_ADD = "add";
5252

53-
public static final String DUPLICATES_ADD = "add";
53+
String DUPLICATES_PRESERVE = "preserve";
5454

55-
public static final String DUPLICATES_PRESERVE = "preserve";
55+
String DUPLICATES_SKIP = "skip";
5656

57-
public static final String DUPLICATES_SKIP = "skip";
57+
String DUPLICATES_FAIL = "fail";
5858

59-
public static final String DUPLICATES_FAIL = "fail";
60-
61-
public static final Set<String> DUPLICATES_VALID_BEHAVIORS = new HashSet<String>()
59+
Set<String> DUPLICATES_VALID_BEHAVIORS = new HashSet<String>()
6260
{
6361

6462
private static final long serialVersionUID = 1L;

src/main/java/org/codehaus/plexus/archiver/BaseFileSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface BaseFileSet
3737

3838
/**
3939
* Returns, whether the include/exclude patterns are
40-
* case sensitive.
40+
* case-sensitive.
4141
*/
4242
boolean isCaseSensitive();
4343

0 commit comments

Comments
 (0)