Skip to content

Commit

Permalink
MSHADE-124: Need better plan for getting dependency-reduced-pom.xml o…
Browse files Browse the repository at this point in the history
…ut of basedir

o add integration test for new unique name generator.


git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1379508 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bimargulies committed Aug 31, 2012
1 parent 635e9a8 commit c96e2a0
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 2 deletions.
101 changes: 101 additions & 0 deletions src/it/dep-reduced-pom-unique/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>MSHADE-53</name>
<description>
Test that creation of the dependency reduced POM properly handles dependencies with classifiers.
</description>
<repositories>
<repository>
<id>shade-it</id>
<url>file:///${basedir}/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>b</artifactId>
<version>0.2</version>
<classifier>client</classifier>
</dependency>
<dependency>
<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>c</artifactId>
<version>1</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>true</createDependencyReducedPom>
<generateUniqueDependencyReducedPom>true</generateUniqueDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>write-project-properties</goal>
</goals>
<phase>package</phase>
<configuration>
<outputFile>target/project.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>b</artifactId>
<version>0.2</version>
<packaging>jar</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.shade.drp</groupId>
<artifactId>c</artifactId>
<version>1</version>
<packaging>pom</packaging>

<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>
39 changes: 39 additions & 0 deletions src/it/dep-reduced-pom-unique/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.*;
import java.util.Properties;

def drps = basedir.listFiles( { dir, file -> file ==~ "dependency-reduced-.*\\.xml" } as FilenameFilter )

File pomFile = drps[0]

def ns = new groovy.xml.Namespace("http://maven.apache.org/POM/4.0.0")
def pom = new XmlParser().parse( pomFile )

assert pom[ns.modelVersion].size() == 1
assert pom[ns.dependencies][ns.dependency].size() == 0

def props = new File( basedir, "target/project.properties" )
Properties properties = new Properties();
FileInputStream inp = new FileInputStream( props );
properties.load( inp );
inp.close();

assert properties["maven.shade.dependency-reduced-pom"] != null
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public class ShadeMojo
*
* @since 1.7.2
*/
@Parameter
@Parameter( defaultValue = "false" )
private boolean generateUniqueDependencyReducedPom;

/**
Expand Down Expand Up @@ -880,7 +880,7 @@ private void createDependencyReducedPom( Set<String> artifactsToRemove )

if ( generateUniqueDependencyReducedPom )
{
dependencyReducedPomLocation = File.createTempFile( "dependency-reduced-pom", "xml", project.getBasedir() );
dependencyReducedPomLocation = File.createTempFile( "dependency-reduced-pom-", ".xml", project.getBasedir() );
project.getProperties().setProperty( "maven.shade.dependency-reduced-pom", dependencyReducedPomLocation.getAbsolutePath() );
}
else
Expand All @@ -893,6 +893,8 @@ private void createDependencyReducedPom( Set<String> artifactsToRemove )
}

File f = dependencyReducedPomLocation;
getLog().info( "Dependency-reduced POM written at: " + f.getAbsolutePath() );

if ( f.exists() )
{
f.delete();
Expand Down

0 comments on commit c96e2a0

Please sign in to comment.