-
Notifications
You must be signed in to change notification settings - Fork 49
Drop legacy plexus API and use only JSR330 components #220
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
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
94d29ac
Drop legacy
cstamas 604fd18
Drop empty XML
cstamas 22c4a8e
Move all container to test
cstamas d50bef1
Set proper scope
cstamas aa97010
Remove redundant method, is in superclass of alias
cstamas a49d3d1
Fix name
cstamas bef6e15
Drop plexus alltogether, is not needed anymore
cstamas 927388a
Update to released plexus-io
cstamas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,11 @@ | |
import java.util.NoSuchElementException; | ||
import java.util.Set; | ||
import javax.annotation.Nonnull; | ||
import org.codehaus.plexus.PlexusConstants; | ||
import org.codehaus.plexus.PlexusContainer; | ||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
|
||
import org.codehaus.plexus.archiver.manager.ArchiverManager; | ||
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; | ||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; | ||
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; | ||
import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes; | ||
import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier; | ||
|
@@ -49,21 +49,22 @@ | |
import org.codehaus.plexus.components.io.resources.PlexusIoResource; | ||
import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection; | ||
import org.codehaus.plexus.components.io.resources.proxy.PlexusIoProxyResourceCollection; | ||
import org.codehaus.plexus.context.Context; | ||
import org.codehaus.plexus.context.ContextException; | ||
import org.codehaus.plexus.logging.AbstractLogEnabled; | ||
import org.codehaus.plexus.logging.Logger; | ||
import org.codehaus.plexus.logging.console.ConsoleLogger; | ||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.codehaus.plexus.archiver.util.DefaultArchivedFileSet.archivedFileSet; | ||
import static org.codehaus.plexus.archiver.util.DefaultFileSet.fileSet; | ||
|
||
public abstract class AbstractArchiver | ||
extends AbstractLogEnabled | ||
implements Archiver, Contextualizable, FinalizerEnabled | ||
implements Archiver, FinalizerEnabled | ||
{ | ||
|
||
private Logger logger; | ||
private final Logger logger = LoggerFactory.getLogger( getClass() ); | ||
|
||
protected Logger getLogger() | ||
{ | ||
return logger; | ||
} | ||
|
||
private File destFile; | ||
|
||
|
@@ -135,8 +136,12 @@ public abstract class AbstractArchiver | |
*/ | ||
private String overrideGroupName; | ||
|
||
// contextualized. | ||
private ArchiverManager archiverManager; | ||
/** | ||
* Injected: Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg | ||
* instantiation/composition problem. | ||
*/ | ||
@Inject | ||
private Provider<ArchiverManager> archiverManagerProvider; | ||
|
||
private static class AddedResourceCollection | ||
{ | ||
|
@@ -186,7 +191,7 @@ public void setDuplicateBehavior( final String duplicate ) | |
if ( !Archiver.DUPLICATES_VALID_BEHAVIORS.contains( duplicate ) ) | ||
{ | ||
throw new IllegalArgumentException( | ||
"Invalid duplicate-file behavior: \'" + duplicate + "\'. Please specify one of: " | ||
"Invalid duplicate-file behavior: '" + duplicate + "'. Please specify one of: " | ||
+ Archiver.DUPLICATES_VALID_BEHAVIORS ); | ||
} | ||
|
||
|
@@ -524,15 +529,15 @@ public ResourceIterator getResources() | |
return new ResourceIterator() | ||
{ | ||
|
||
private final Iterator addedResourceIter = resources.iterator(); | ||
private final Iterator<Object> addedResourceIter = resources.iterator(); | ||
|
||
private AddedResourceCollection currentResourceCollection; | ||
|
||
private Iterator ioResourceIter; | ||
|
||
private ArchiveEntry nextEntry; | ||
|
||
private final Set<String> seenEntries = new HashSet<String>(); | ||
private final Set<String> seenEntries = new HashSet<>(); | ||
|
||
@Override | ||
public boolean hasNext() | ||
|
@@ -727,24 +732,6 @@ public void setDestFile( final File destFile ) | |
} | ||
} | ||
|
||
@Override | ||
protected Logger getLogger() | ||
{ | ||
if ( logger == null ) | ||
{ | ||
if ( super.getLogger() != null ) | ||
{ | ||
logger = super.getLogger(); | ||
} | ||
else | ||
{ | ||
logger = new ConsoleLogger( Logger.LEVEL_INFO, "console" ); | ||
} | ||
} | ||
|
||
return logger; | ||
} | ||
|
||
protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet, Charset charset ) | ||
throws ArchiverException | ||
{ | ||
|
@@ -753,7 +740,7 @@ protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet | |
final PlexusIoResourceCollection resources; | ||
try | ||
{ | ||
resources = archiverManager.getResourceCollection( archiveFile ); | ||
resources = archiverManagerProvider.get().getResourceCollection( archiveFile ); | ||
} | ||
catch ( final NoSuchArchiverException e ) | ||
{ | ||
|
@@ -880,26 +867,6 @@ public void addArchivedFileSet( @Nonnull final File archiveFile ) | |
addArchivedFileSet( archivedFileSet( archiveFile ).includeEmptyDirs( includeEmptyDirs ) ); | ||
} | ||
|
||
/** | ||
* Allows us to pull the ArchiverManager instance out of the container without causing a chicken-and-egg | ||
* instantiation/composition problem. | ||
*/ | ||
@Override | ||
public void contextualize( final Context context ) | ||
throws ContextException | ||
{ | ||
final PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); | ||
|
||
try | ||
{ | ||
archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE ); | ||
} | ||
catch ( final ComponentLookupException e ) | ||
{ | ||
throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e ); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isForced() | ||
{ | ||
|
@@ -917,7 +884,7 @@ public void addArchiveFinalizer( final ArchiveFinalizer finalizer ) | |
{ | ||
if ( finalizers == null ) | ||
{ | ||
finalizers = new ArrayList<ArchiveFinalizer>(); | ||
finalizers = new ArrayList<>(); | ||
} | ||
|
||
finalizers.add( finalizer ); | ||
|
@@ -946,7 +913,7 @@ protected boolean isUptodate() | |
} | ||
final long destTimestamp = getFileLastModifiedTime(zipFile); | ||
|
||
final Iterator it = resources.iterator(); | ||
final Iterator<Object> it = resources.iterator(); | ||
if ( !it.hasNext() ) | ||
{ | ||
getLogger().debug( "isUp2date: false (No input files.)" ); | ||
|
@@ -1314,14 +1281,7 @@ public void configureReproducibleBuild( FileTime lastModifiedTime ) | |
setLastModifiedTime( normalizeLastModifiedTime ( lastModifiedTime ) ); | ||
|
||
// 2. sort filenames in each directory when scanning filesystem | ||
setFilenameComparator( new Comparator<String>() | ||
{ | ||
@Override | ||
public int compare( String s1, String s2 ) | ||
{ | ||
return s1.compareTo( s2 ); | ||
} | ||
} ); | ||
setFilenameComparator( String::compareTo ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
// 3. ignore file/directory mode from filesystem, since they may vary based on local user umask | ||
// notice: this overrides execute bit on Unix (that is already ignored on Windows) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,26 +26,34 @@ | |
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.concurrent.atomic.LongAdder; | ||
|
||
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils; | ||
import org.codehaus.plexus.components.io.attributes.SymlinkUtils; | ||
import org.codehaus.plexus.components.io.filemappers.FileMapper; | ||
import org.codehaus.plexus.components.io.fileselectors.FileSelector; | ||
import org.codehaus.plexus.components.io.resources.PlexusIoResource; | ||
import org.codehaus.plexus.logging.AbstractLogEnabled; | ||
import org.codehaus.plexus.util.FileUtils; | ||
import org.codehaus.plexus.util.IOUtil; | ||
import org.codehaus.plexus.util.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
// TODO there should really be constructors which take the source file. | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
*/ | ||
public abstract class AbstractUnArchiver | ||
extends AbstractLogEnabled | ||
implements UnArchiver, FinalizerEnabled | ||
{ | ||
private final Logger logger = LoggerFactory.getLogger( getClass() ); | ||
|
||
protected Logger getLogger() | ||
{ | ||
return logger; | ||
} | ||
|
||
private File destDirectory; | ||
|
||
|
@@ -384,6 +392,11 @@ else if ( isDirectory ) | |
} | ||
} | ||
|
||
/** | ||
* Counter for casing message emitted, visible for testing. | ||
*/ | ||
final AtomicInteger casingMessageEmitted = new AtomicInteger( 0 ); | ||
|
||
// Visible for testing | ||
protected boolean shouldExtractEntry( File targetDirectory, File targetFileName, String entryName, Date entryDate ) throws IOException | ||
{ | ||
|
@@ -423,6 +436,7 @@ protected boolean shouldExtractEntry( File targetDirectory, File targetFileName, | |
if ( differentCasing ) | ||
{ | ||
getLogger().warn( casingMessage ); | ||
casingMessageEmitted.incrementAndGet(); | ||
} | ||
return false; | ||
} | ||
|
@@ -431,6 +445,7 @@ protected boolean shouldExtractEntry( File targetDirectory, File targetFileName, | |
if ( differentCasing ) | ||
{ | ||
getLogger().warn( casingMessage ); | ||
casingMessageEmitted.incrementAndGet(); | ||
} | ||
|
||
// (2) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.