jasperkamerling commented on code in PR #233:
URL:
https://github.com/apache/maven-dependency-plugin/pull/233#discussion_r958165725
##########
src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java:
##########
@@ -373,7 +373,50 @@ public void testSubPerArtifactAndTypeRemoveVersion()
for ( Artifact artifact : artifacts )
{
String fileName = DependencyUtil.getFormattedFileName( artifact,
true );
- File folder = DependencyUtil.getFormattedOutputDirectory( false,
true, true, false, true,
+ File folder = DependencyUtil.getFormattedOutputDirectory( false,
true, true, false, true, false,
+
mojo.outputDirectory, artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
+ }
+ }
+
+ public void testSubPerArtifactRemoveType()
+ throws Exception
+ {
+ mojo.useSubDirectoryPerArtifact = true;
+ mojo.stripType = true;
+
+ mojo.execute();
+
+ Set<Artifact> artifacts = mojo.getProject().getArtifacts();
+ for ( Artifact artifact : artifacts )
+ {
+ // TODO fix test
+ String fileName = DependencyUtil.getFormattedFileName( artifact,
false );
+ File folder = DependencyUtil.getFormattedOutputDirectory( false,
false, true, false, false, true,
+ mojo.outputDirectory, artifact );
+ File file = new File( folder, fileName );
+ assertTrue( file.exists() );
Review Comment:
The tricky thing is that the file name wil contain the type and version
regardless of the settings. The setting is only meant to strip it from the
folder and not the artifact file. And then it is also made more difficult
because a subdir per type is used. I could check for "-<type>" but that feels a
bit wrong.
So maybe we can keep this as a simple mojo test and since the DependencyUtil
test should check the actual file name and paths.
Example:
`stripType=true`
```
target\unit-tests\copy-dependencies\outputDirectory\wars\a-1.0\a-1.0.war
target\unit-tests\copy-dependencies\outputDirectory\sourcess\c-1.0\c-1.0.sources
target\unit-tests\copy-dependencies\outputDirectory\jars\b-1.0\b-1.0.jar
target\unit-tests\copy-dependencies\outputDirectory\rars\e-1.0\e-1.0.rar
target\unit-tests\copy-dependencies\outputDirectory\zips\d-1.0\d-1.0.zip
```
`stripType=false`
```
target\unit-tests\copy-dependencies\outputDirectory\wars\a-1.0-war\a-1.0.war
target\unit-tests\copy-dependencies\outputDirectory\sourcess\c-1.0-sources\c-1.0.sources
target\unit-tests\copy-dependencies\outputDirectory\jars\b-1.0-jar\b-1.0.jar
target\unit-tests\copy-dependencies\outputDirectory\rars\e-1.0-rar\e-1.0.rar
target\unit-tests\copy-dependencies\outputDirectory\zips\d-1.0-zip\d-1.0.zip
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]