Author: gboue Date: Sat Jul 1 07:32:06 2017 New Revision: 1800481 URL: http://svn.apache.org/viewvc?rev=1800481&view=rev Log: [MDEP-573] "purge-local-repository -Dinclude" does not work as described
Due to requiresProject = false, we need to loop over the projects in the reactor ourselves if the mojo was launched from the CLI. This requires several changes: - Dependency artifacts do not exist anymore so we work on dependencies and resolve them if necessary. - Dependencies on projects in the reactor are ignored (just like in the case of a single project, the project itself is not purged). - Artifacts already purged do not need to be purged again: if they were re-resolved then no need to purge and re-resolve them a second time; if they were not re-resolved then keep them deleted. - Updating to maven-artifact-transfer 0.9.2-SNAPSHOT to make added ITs work on Maven 3.0.x. Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties (with props) maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh (with props) maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml (with props) Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?rev=1800481&r1=1800480&r2=1800481&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Sat Jul 1 07:32:06 2017 @@ -222,7 +222,7 @@ under the License. <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-artifact-transfer</artifactId> - <version>0.9.1</version> + <version>0.9.2-SNAPSHOT</version> </dependency> <dependency> Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,20 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository +# [MNG-5366] Does not work in Maven >= 3.0.4 due to the resolveAlways operation not correctly forcing a new download +invoker.maven.version = !3.0.4,!3.0.5,!3.1.0,!3.1.1,!3.2.1,!3.2.2,!3.2.3 Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,47 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-bad-dep</artifactId> + <version>1.0-SNAPSHOT</version> + <description> + Tests that purge-local-repository doesn't fail when it encounters a dependency that it can't resolve + </description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>i-do-not-exist</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy Sat Jul 1 07:32:06 2017 @@ -0,0 +1,37 @@ +/* + * 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. + */ + +void checkFilePresence( String path ) +{ + File depJar = new File( localRepositoryPath, path ); + if ( !depJar.exists() ) + { + throw new Exception( "Direct dependency jar was not re-resolved: " + depJar ); + } +} + +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ); + +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); +assert buildLog.contains( 'Unable to resolve artifact: org.apache.maven.its.dependency:i-do-not-exist:jar:1.0' ); +assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); +assert buildLog.contains( 'Resolving artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-bad-dep/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,40 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-include</artifactId> + <version>1.0-SNAPSHOT</version> + <description>Tests that purge-local-repository only purges included artifacts</description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,19 @@ +# 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. + +include = org.apache.maven.its.dependency:purge-local-repository-2 +reResolve = false Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/test.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy Sat Jul 1 07:32:06 2017 @@ -0,0 +1,48 @@ +/* + * 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. + */ + +void checkFilePresence( String path ) +{ + File depJar = new File( localRepositoryPath, path ); + if ( !depJar.exists() ) + { + throw new Exception( "Dependency jar was not re-resolved: " + depJar ); + } +} + +void checkFileAbsence( String path ) +{ + File depJar = new File( localRepositoryPath, path ); + if ( depJar.exists() ) + { + throw new Exception( "Dependency jar was not purged: " + depJar ); + } +} + +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.jar" ); +checkFilePresence( "org/apache/maven/its/dependency/purge-local-repository/1.0/purge-local-repository-1.0.pom" ); + +checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.jar" ); +checkFileAbsence( "org/apache/maven/its/dependency/purge-local-repository-2/1.0/purge-local-repository-2-1.0.pom" ); + +String buildLog = new File( basedir, "build.log" ).getText( "UTF-8" ); +assert !buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository:jar:1.0' ); +assert buildLog.contains( 'Purging artifact: org.apache.maven.its.dependency:purge-local-repository-2:jar:1.0' ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-include/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,39 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module-execution</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>child1</artifactId> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purged-a</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child1/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,44 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module-execution</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>child2</artifactId> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purged-b</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>child1</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/child2/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,58 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module-execution</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + <description> + Test dependency:purge-local-repository in a multi-module build when the goal is declared in an execution in the POM + </description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <modules> + <module>child1</module> + <module>child2</module> + </modules> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <version>@project.version@</version> + <executions> + <execution> + <id>purge-local-repo</id> + <phase>validate</phase> + <goals> + <goal>purge-local-repository</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh Sat Jul 1 07:32:06 2017 @@ -0,0 +1,35 @@ +/* + * 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.File; + +void createJar( String artifactId ) +{ + File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/" + artifactId + "/1.0/" + artifactId + "-1.0.jar" ); + + purgedJar.getParentFile().mkdirs(); + purgedJar.createNewFile(); + + System.out.println( "Created dummy JAR " + purgedJar ); +} + +createJar( "purged-a" ); +createJar( "purged-b" ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/setup.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,18 @@ +# 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. + +reResolve = false Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/test.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh Sat Jul 1 07:32:06 2017 @@ -0,0 +1,37 @@ +/* + * 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.File; + +void checkFilePurged( String artifactId ) +{ + File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/" + artifactId + "/1.0/" + artifactId + "-1.0.jar" ); + + System.out.println( "Checking for absence of dummy JAR " + purgedJar ); + + if ( purgedJar.exists() ) + { + throw new Exception( "JAR was not purged: " + purgedJar ); + } +} + +checkFilePurged( "purged-a" ); +checkFilePurged( "purged-b" ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module-execution/verify.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,39 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>child1</artifactId> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purged-a</artifactId> + <version>1.0</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child1/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,44 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>child2</artifactId> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purged-b</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>child1</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/child2/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:purge-local-repository Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,39 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.dependency</groupId> + <artifactId>purge-local-repository-multi-module</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + <description>Test dependency:purge-local-repository in a multi-module build</description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + <modules> + <module>child1</module> + <module>child2</module> + </modules> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh Sat Jul 1 07:32:06 2017 @@ -0,0 +1,35 @@ +/* + * 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.File; + +void createJar( String artifactId ) +{ + File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/" + artifactId + "/1.0/" + artifactId + "-1.0.jar" ); + + purgedJar.getParentFile().mkdirs(); + purgedJar.createNewFile(); + + System.out.println( "Created dummy JAR " + purgedJar ); +} + +createJar( "purged-a" ); +createJar( "purged-b" ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/setup.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties Sat Jul 1 07:32:06 2017 @@ -0,0 +1,18 @@ +# 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. + +reResolve = false Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/test.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh Sat Jul 1 07:32:06 2017 @@ -0,0 +1,37 @@ +/* + * 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.File; + +void checkFilePurged( String artifactId ) +{ + File purgedJar = new File( localRepositoryPath, "org/apache/maven/its/dependency/" + artifactId + "/1.0/" + artifactId + "-1.0.jar" ); + + System.out.println( "Checking for absence of dummy JAR " + purgedJar ); + + if ( purgedJar.exists() ) + { + throw new Exception( "JAR was not purged: " + purgedJar ); + } +} + +checkFilePurged( "purged-a" ); +checkFilePurged( "purged-b" ); + +return true; Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/purge-local-repository-multi-module/verify.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java?rev=1800481&r1=1800480&r2=1800481&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/PurgeLocalRepositoryMojo.java Sat Jul 1 07:32:06 2017 @@ -23,26 +23,32 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.MojoExecution.Source; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.dependencies.resolve.DependencyResolver; import org.apache.maven.shared.dependencies.resolve.DependencyResolverException; +import org.apache.maven.shared.artifact.DefaultArtifactCoordinate; import org.apache.maven.shared.artifact.filter.resolve.AbstractFilter; import org.apache.maven.shared.artifact.filter.resolve.AndFilter; import org.apache.maven.shared.artifact.filter.resolve.Node; @@ -79,6 +85,12 @@ public class PurgeLocalRepositoryMojo public static final String GROUP_ID_FUZZINESS = "groupId"; /** + * The Maven projects in the reactor. + */ + @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true ) + private List<MavenProject> reactorProjects; + + /** * The current Maven project. */ @Parameter( defaultValue = "${project}", readonly = true, required = true ) @@ -88,6 +100,18 @@ public class PurgeLocalRepositoryMojo private MavenSession session; /** + * This mojo execution, used to determine if it was launched from the lifecycle or the command-line. + */ + @Parameter( defaultValue = "${mojo}", required = true, readonly = true ) + private MojoExecution mojoExecution; + + /** + * Artifact handler manager. + */ + @Component + private ArtifactHandlerManager artifactHandlerManager; + + /** * The list of dependencies in the form of groupId:artifactId which should BE deleted/purged from the local * repository. Note that using this parameter will deactivate the normal process for purging the current project * dependency tree. If this parameter is used, only the included artifacts will be purged. The manualIncludes @@ -214,31 +238,30 @@ public class PurgeLocalRepositoryMojo private Artifact projectArtifact; - private Set<Artifact> directDependencyArtifacts; + private List<Dependency> directDependencies; /** * Default constructor * - * @param directDependencyArtifacts Set of Artifact objects which represent the direct dependencies of the - * project + * @param directDependencies Set of dependencies objects which represent the direct dependencies of the project */ - public DirectDependencyFilter( Artifact projectArtifact, Set<Artifact> directDependencyArtifacts ) + public DirectDependencyFilter( Artifact projectArtifact, List<Dependency> directDependencies ) { this.projectArtifact = projectArtifact; - this.directDependencyArtifacts = directDependencyArtifacts; + this.directDependencies = directDependencies; } @Override public boolean accept( Node node, List<Node> parents ) { - if ( artifactsGAMatch( node, projectArtifact ) ) + if ( artifactsGAMatch( node, projectArtifact.getGroupId(), projectArtifact.getArtifactId() ) ) { return true; } - for ( Artifact depArtifact : directDependencyArtifacts ) + for ( Dependency dep : directDependencies ) { - if ( this.artifactsGAMatch( node, depArtifact ) ) + if ( this.artifactsGAMatch( node, dep.getGroupId(), dep.getArtifactId() ) ) { return true; } @@ -249,21 +272,21 @@ public class PurgeLocalRepositoryMojo /* * Compare the groupId:artifactId of two artifacts. */ - private boolean artifactsGAMatch( Node node, Artifact artifact2 ) + private boolean artifactsGAMatch( Node node, String groupId, String artifactId ) { if ( node.getDependency() == null ) { return false; } - if ( !node.getDependency().getGroupId().equals( artifact2.getGroupId() ) ) + if ( !node.getDependency().getGroupId().equals( groupId ) ) { - getLog().debug( "Different groupId: " + node.getDependency() + " " + artifact2 ); + getLog().debug( "Different groupId: " + node.getDependency() + " " + groupId ); return false; } - if ( !node.getDependency().getArtifactId().equals( artifact2.getArtifactId() ) ) + if ( !node.getDependency().getArtifactId().equals( artifactId ) ) { - getLog().debug( "Different artifactId: " + node.getDependency() + " " + artifact2 ); + getLog().debug( "Different artifactId: " + node.getDependency() + " " + artifactId ); return false; } return true; @@ -310,12 +333,49 @@ public class PurgeLocalRepositoryMojo return; } - Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts(); + Set<Artifact> purgedArtifacts = new HashSet<Artifact>(); + if ( shouldPurgeAllProjectsInReactor() ) + { + for ( MavenProject reactorProject : reactorProjects ) + { + purgeLocalRepository( reactorProject, purgedArtifacts ); + } + } + else + { + purgeLocalRepository( project, purgedArtifacts ); + } + } - TransformableFilter dependencyFilter = createPurgeArtifactsFilter( dependencyArtifacts ); + /** + * Determines if all projects in the reactor should be purged from their dependencies. When this goal is started on + * the command-line, it is always the case. When it is bound to a phase in the lifecycle, it is never the case. + * + * @return <code>true</code> if all projects in the reactor should be purged, <code>false</code> otherwise. + */ + private boolean shouldPurgeAllProjectsInReactor() + { + Source source = mojoExecution.getSource(); + return reactorProjects.size() > 1 && source == Source.CLI; + } + + /** + * Purges the local repository for the dependencies in the given Maven project. + * + * @param project Maven project. + * @param resolvedArtifactsToPurge The artifacts that were already purged. + * @throws MojoFailureException in case of errors during the purge. + */ + private void purgeLocalRepository( MavenProject project, Set<Artifact> purgedArtifacts ) + throws MojoFailureException + { + List<Dependency> dependencies = project.getDependencies(); + + TransformableFilter dependencyFilter = + createPurgeArtifactsFilter( project, dependencies, purgedArtifacts ); Set<Artifact> resolvedArtifactsToPurge = - getFilteredResolvedArtifacts( project, dependencyArtifacts, dependencyFilter ); + getFilteredResolvedArtifacts( project, dependencies, dependencyFilter ); if ( resolvedArtifactsToPurge.isEmpty() ) { @@ -325,6 +385,7 @@ public class PurgeLocalRepositoryMojo verbose( "Purging dependencies for project: " + project.getId() ); purgeArtifacts( resolvedArtifactsToPurge ); + purgedArtifacts.addAll( resolvedArtifactsToPurge ); if ( reResolve ) { @@ -420,11 +481,13 @@ public class PurgeLocalRepositoryMojo * Create the includes exclude filter to use when resolving and purging dependencies Also excludes any "system" * scope dependencies * - * @param dependencyArtifacts The dependency artifacts to use as a reference if we're excluding transitive - * dependencies + * @param project The Maven project. + * @param dependencies The dependencies to use as a reference if we're excluding transitive dependencies + * @param purgedArtifacts The artifacts already purged. * @return the created filter */ - private TransformableFilter createPurgeArtifactsFilter( Set<Artifact> dependencyArtifacts ) + private TransformableFilter createPurgeArtifactsFilter( MavenProject project, List<Dependency> dependencies, + Set<Artifact> purgedArtifacts ) { List<TransformableFilter> subFilters = new ArrayList<TransformableFilter>(); @@ -457,13 +520,38 @@ public class PurgeLocalRepositoryMojo if ( !actTransitively ) { - subFilters.add( new DirectDependencyFilter( project.getArtifact(), dependencyArtifacts ) ); + subFilters.add( new DirectDependencyFilter( project.getArtifact(), dependencies ) ); } + List<String> exclusions = new ArrayList<String>( reactorProjects.size() ); + // It doesn't make sense to include projects from the reactor here since they're likely not able to be resolved + for ( MavenProject reactorProject : reactorProjects ) + { + exclusions.add( toPatternExcludes( reactorProject.getArtifact() ) ); + } + // There is no need to consider a second time artifacts that were already purged (re-resolved or not) + for ( Artifact purgedArtifact : purgedArtifacts ) + { + exclusions.add( toPatternExcludes( purgedArtifact ) ); + } + subFilters.add( new PatternExclusionsFilter( exclusions ) ); + return new AndFilter( subFilters ); } /** + * Returns a string that represents a pattern for an exclude filter for the given artifact. + * + * @param artifact Artifact. + * @return String representation of a pattern for an exclude filter for the given artifact. + */ + private String toPatternExcludes( Artifact artifact ) + { + return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + + artifact.getArtifactHandler().getExtension() + ":" + artifact.getVersion(); + } + + /** * Convert comma separated list of includes to List object * * @param include @@ -482,7 +570,7 @@ public class PurgeLocalRepositoryMojo return includes; } - private Set<Artifact> getFilteredResolvedArtifacts( MavenProject project, Set<Artifact> artifacts, + private Set<Artifact> getFilteredResolvedArtifacts( MavenProject project, List<Dependency> dependencies, TransformableFilter filter ) { try @@ -502,7 +590,7 @@ public class PurgeLocalRepositoryMojo } catch ( DependencyResolverException e ) { - getLog().info( "Unable to resolve all dependencies for : " + project.getGroupId() + ":" + getLog().info( "Unable to resolve all dependencies for: " + project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion() + ". Falling back to non-transitive mode for initial artifact resolution." ); } @@ -511,24 +599,26 @@ public class PurgeLocalRepositoryMojo ArtifactFilter artifactFilter = filter.transform( new ArtifactIncludeFilterTransformer() ); - // Resolve the only poms here instead of the actual artifacts, because the files will be deleted during the - // purge anyway - for ( Artifact artifact : artifacts ) + for ( Dependency dependency : dependencies ) { - if ( artifactFilter.include( artifact ) ) + DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); + coordinate.setGroupId( dependency.getGroupId() ); + coordinate.setArtifactId( dependency.getArtifactId() ); + coordinate.setVersion( dependency.getVersion() ); + coordinate.setExtension( artifactHandlerManager.getArtifactHandler( dependency.getType() ).getExtension() ); + try { - try + Artifact artifact = + artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), coordinate ).getArtifact(); + if ( artifactFilter.include( artifact ) ) { - ArtifactResult artifactResult = - artifactResolver.resolveArtifact( session.getProjectBuildingRequest(), artifact ); - - resolvedArtifacts.add( artifactResult.getArtifact() ); - } - catch ( ArtifactResolverException e ) - { - getLog().debug( "Unable to resolve artifact: " + artifact ); + resolvedArtifacts.add( artifact ); } } + catch ( ArtifactResolverException e ) + { + getLog().debug( "Unable to resolve artifact: " + coordinate ); + } } return resolvedArtifacts; } Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java?rev=1800481&r1=1800480&r2=1800481&view=diff ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java (original) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java Sat Jul 1 07:32:06 2017 @@ -104,7 +104,7 @@ public class TestSkip public void testSkipPurgeLocalRepository() throws Exception { - doTest( "purge-local-repository" ); + doSpecialTest( "purge-local-repository" ); } public void testSkipResolve() Added: maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml?rev=1800481&view=auto ============================================================================== --- maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml (added) +++ maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml Sat Jul 1 07:32:06 2017 @@ -0,0 +1,48 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + + <groupId>com.mycompany.app</groupId> + <artifactId>my-mojo</artifactId> + <packaging>maven-plugin</packaging> + <version>1.0-SNAPSHOT</version> + + <name>my-mojo Maven Mojo</name> + <url>http://maven.apache.org</url> + + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <configuration> + <reactorProjects> + <reactorProject implementation="org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependenciesProjectStub"/> + </reactorProjects> + <project implementation="org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependenciesProjectStub"/> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision