Skip to content

Commit 09d8ec1

Browse files
committed
Simplified code
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1674106 13f79535-47bb-0310-9956-ffa450edef68
1 parent 5b08072 commit 09d8ec1

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDependencySetsTask.java

+21-10
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,15 @@ void addDependencySet( final DependencySet dependencySet, final Archiver archive
134134

135135
final Set<Artifact> dependencyArtifacts = resolveDependencyArtifacts( dependencySet );
136136

137-
final UnpackOptions opts = dependencySet.getUnpackOptions();
138-
if ( dependencySet.isUnpack() && opts != null && ( opts.isFiltered() || opts.getLineEnding() != null ) )
139-
{
140-
// find out if we can just ditch this empty block
141-
}
142-
else if ( dependencyArtifacts.size() > 1 )
137+
if ( !unpackTransformsContent( dependencySet ) && dependencyArtifacts.size() > 1 )
143138
{
144139
checkMultiArtifactOutputConfig( dependencySet );
145140
}
146141

147142
logger.debug( "Adding " + dependencyArtifacts.size() + " dependency artifacts." );
148143

149144
InputStreamTransformer fileSetTransformers =
150-
dependencySet.isUnpack() && dependencySet.getUnpackOptions() != null
145+
isUnpackWithOptions( dependencySet )
151146
? ReaderFormatter.getFileSetTransformers( configSource, dependencySet.getUnpackOptions().isFiltered(),
152147
dependencySet.getUnpackOptions().getLineEnding() )
153148
: null;
@@ -181,6 +176,21 @@ else if ( dependencyArtifacts.size() > 1 )
181176
}
182177
}
183178

179+
private boolean isUnpackWithOptions( DependencySet dependencySet )
180+
{
181+
return dependencySet.isUnpack() && dependencySet.getUnpackOptions() != null;
182+
}
183+
184+
private boolean unpackTransformsContent( DependencySet dependencySet )
185+
{
186+
return isUnpackWithOptions( dependencySet ) && isConentModifyingOption( dependencySet.getUnpackOptions() );
187+
}
188+
189+
private boolean isConentModifyingOption( UnpackOptions opts )
190+
{
191+
return ( opts.isFiltered() || opts.getLineEnding() != null );
192+
}
193+
184194
private void checkMultiArtifactOutputConfig( final DependencySet dependencySet )
185195
{
186196
String dir = dependencySet.getOutputDirectory();
@@ -198,8 +208,9 @@ private void checkMultiArtifactOutputConfig( final DependencySet dependencySet )
198208
if ( ( dir == null || !dir.contains( "${" ) ) && ( mapping == null || !mapping.contains( "${" ) ) )
199209
{
200210
logger.warn( "NOTE: Your assembly specifies a dependencySet that matches multiple artifacts, but "
201-
+ "specifies a concrete output format. THIS MAY RESULT IN ONE OR MORE ARTIFACTS BEING OBSCURED!\n\n"
202-
+ "Output directory: '" + dir + "'\nOutput filename mapping: '" + mapping + "'" );
211+
+ "specifies a concrete output format. THIS MAY RESULT IN ONE OR MORE ARTIFACTS BEING "
212+
+ "OBSCURED!\n\n" + "Output directory: '" + dir + "'\nOutput filename mapping: '" + mapping
213+
+ "'" );
203214
}
204215
}
205216

@@ -234,7 +245,7 @@ private void addNormalArtifact( final DependencySet dependencySet, final Artifac
234245
task.setUnpack( dependencySet.isUnpack() );
235246

236247
final UnpackOptions opts = dependencySet.getUnpackOptions();
237-
if ( dependencySet.isUnpack() && ( opts != null ) )
248+
if ( isUnpackWithOptions( dependencySet ) )
238249
{
239250
task.setIncludes( opts.getIncludes() );
240251
task.setExcludes( opts.getExcludes() );

0 commit comments

Comments
 (0)