Author: bentmann Date: Wed Oct 28 13:13:22 2009 New Revision: 830522 URL: http://svn.apache.org/viewvc?rev=830522&view=rev Log: [MSHADE-66] Creation of dependency reduced POM fails for project with uninstalled local parent using Maven 3
Added: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/ maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/ maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml (with props) maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties (with props) maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml (with props) Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Added: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml?rev=830522&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml (added) +++ maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml Wed Oct 28 13:13:22 2009 @@ -0,0 +1,72 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.shade.drpwlp</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + </parent> + + <groupId>org.apache.maven.its.shade.drpwlp</groupId> + <artifactId>child</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <name>MSHADE-66</name> + <description> + Test that creation of the dependency reduced POM succeeds if the POM inherits from a parent that is only + locally available. In other words, the parent can only be resolved by following the relativePath in the POM + which demands for the dependency reduced POM to reside in the original project directory. + </description> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <executions> + <execution> + <id>attach-shade</id> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <shadedArtifactAttached>false</shadedArtifactAttached> + <createDependencyReducedPom>true</createDependencyReducedPom> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/child/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties?rev=830522&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties (added) +++ maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties Wed Oct 28 13:13:22 2009 @@ -0,0 +1,2 @@ +invoker.goals = clean package +invoker.project = child Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml?rev=830522&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml (added) +++ maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml Wed Oct 28 13:13:22 2009 @@ -0,0 +1,77 @@ +<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.shade.drpwlp</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + + <name>MSHADE-66</name> + <description> + Test that creation of the dependency reduced POM succeeds if the POM inherits from a parent that is only + locally available. In other words, the parent can only be resolved by following the relativePath in the POM + which demands for the dependency reduced POM to reside in the original project directory. + </description> + + <modules> + <module>child</module> + </modules> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-install-plugin</artifactId> + <version>2.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>@project.version@</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.3.1</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/dep-reduced-pom-with-local-parent/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java?rev=830522&r1=830521&r2=830522&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Wed Oct 28 13:13:22 2009 @@ -746,7 +746,11 @@ model.setDependencies( dependencies ); - File f = new File( outputDirectory, "dependency-reduced-pom.xml" ); + /* + * NOTE: Be sure to create the POM in the original base directory to be able to resolve the relativePath + * to local parent POMs when invoking the project builder below. + */ + File f = new File( project.getBasedir(), "dependency-reduced-pom.xml" ); if ( f.exists() ) { f.delete(); @@ -754,27 +758,29 @@ Writer w = WriterFactory.newXmlWriter( f ); - PomWriter.write( w, model, true ); - - w.close(); + try + { + PomWriter.write( w, model, true ); + } + finally + { + w.close(); + } MavenProject p2 = mavenProjectBuilder.build( f, localRepository, null ); modified = updateExcludesInDeps( p2, dependencies, transitiveDeps ); } - //copy the dependecy-reduced-pom.xml to the basedir where - //we'll set the file for the project to it. We cannot set - //it to the real version in "target" as then ${basedir} gets - //messed up. We'll delete this file on exit to make - //sure it gets cleaned up. + /* + * NOTE: Although the dependency reduced POM in the project directory is temporary build output, we have to + * use that for the file of the project instead of something in target to avoid messing up the base + * directory of the project. We'll delete this file on exit to make sure it gets cleaned up but keep a copy + * for inspection in the target directory as well. + */ File f = new File( project.getBasedir(), "dependency-reduced-pom.xml" ); File f2 = new File( outputDirectory, "dependency-reduced-pom.xml" ); - if ( f.exists() ) - { - f.delete(); - } - FileUtils.copyFile( f2, f ); + FileUtils.copyFile( f, f2 ); FileUtils.forceDeleteOnExit( f ); project.setFile( f ); }