Skip to content

Commit 6ea8543

Browse files
bk-mzmichael-o
authored andcommitted
[MSHADE-321] Always respect 'createDependencyReducedPom' flag
This closes #22
1 parent 1d19348 commit 6ea8543

File tree

5 files changed

+147
-5
lines changed

5 files changed

+147
-5
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project>
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its.shade.drp</groupId>
26+
<artifactId>test</artifactId>
27+
<version>1.0</version>
28+
<packaging>jar</packaging>
29+
30+
<name>MSHADE-321</name>
31+
<description>
32+
Test that dependency-reduced-pom is created with respect to flag only.
33+
Shade plugin starts to create DRP even if the artifact has been renamed because of the configuration
34+
</description>
35+
36+
<repositories>
37+
<repository>
38+
<id>shade-it</id>
39+
<url>file://${basedir}/repo</url>
40+
<releases>
41+
<checksumPolicy>ignore</checksumPolicy>
42+
</releases>
43+
<snapshots>
44+
<enabled>false</enabled>
45+
</snapshots>
46+
</repository>
47+
</repositories>
48+
49+
<dependencies>
50+
<dependency>
51+
<groupId>org.apache.maven.its.shade.drp</groupId>
52+
<artifactId>a</artifactId>
53+
<version>0.1</version>
54+
</dependency>
55+
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-shade-plugin</artifactId>
63+
<version>@project.version@</version>
64+
<executions>
65+
<execution>
66+
<id>shade</id>
67+
<phase>package</phase>
68+
<goals>
69+
<goal>shade</goal>
70+
</goals>
71+
<configuration>
72+
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
73+
<finalName>shade_321</finalName>
74+
<shadedArtifactAttached>false</shadedArtifactAttached>
75+
<createDependencyReducedPom>true</createDependencyReducedPom>
76+
<dependencyReducedPomLocation>target/shade_321.xml</dependencyReducedPomLocation>
77+
</configuration>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
</project>
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project>
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its.shade.drp</groupId>
26+
<artifactId>a</artifactId>
27+
<version>0.1</version>
28+
<packaging>jar</packaging>
29+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. 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,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
File jarRenamedFile = new File(basedir, "target/shade_321.jar")
21+
assert jarRenamedFile.isFile()
22+
23+
File pomFile = new File(basedir, "target/shade_321.xml")
24+
assert pomFile.isFile()
25+
26+
def ns = new groovy.xml.Namespace("http://maven.apache.org/POM/4.0.0")
27+
def pom = new XmlParser().parse(pomFile)
28+
29+
assert pom[ns.modelVersion].size() == 1
30+
assert pom[ns.dependencies][ns.dependency].size() == 0

src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,13 @@ else if ( !renamed )
593593
projectHelper.attachArtifact( project, "java-source", "test-sources",
594594
shadedTestSources );
595595
}
596-
597-
if ( createDependencyReducedPom )
598-
{
599-
createDependencyReducedPom( artifactIds );
600-
}
601596
}
602597
}
598+
599+
if ( createDependencyReducedPom )
600+
{
601+
createDependencyReducedPom( artifactIds );
602+
}
603603
}
604604
}
605605
catch ( Exception e )

0 commit comments

Comments
 (0)