You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mf...@apache.org on 2014/06/23 22:37:29 UTC
svn commit: r1604930 - in /maven/plugins/trunk/maven-dependency-plugin/src:
it/mdep-450-project-with-ancestor/ it/mdep-450-project-without-ancestor/
main/java/org/apache/maven/plugin/dependency/ site/apt/
Author: mfriedenhagen
Date: Mon Jun 23 20:37:28 2014
New Revision: 1604930
URL: http://svn.apache.org/r1604930
Log:
Fixes MDEP-450: Add goal display-ancestors which will output the line of heritage for parent poms.
Added:
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/invoker.properties
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/pom.xml
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/verify.groovy
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/invoker.properties
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/pom.xml
maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/verify.groovy
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/invoker.properties?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/invoker.properties (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/invoker.properties Mon Jun 23 20:37:28 2014
@@ -0,0 +1 @@
+invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-ancestors
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/pom.xml?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/pom.xml (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/pom.xml Mon Jun 23 20:37:28 2014
@@ -0,0 +1,38 @@
+<?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</groupId>
+ <artifactId>apache</artifactId>
+ <version>5</version>
+ </parent>
+
+ <groupId>org.apache.maven.its.dependency</groupId>
+ <artifactId>display-ancestors-test-with-ancestor</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+ <name>display-ancestors basic test</name>
+
+</project>
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/verify.groovy?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/verify.groovy (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-ancestor/verify.groovy Mon Jun 23 20:37:28 2014
@@ -0,0 +1,7 @@
+File file = new File( basedir, "build.log" );
+assert file.exists();
+
+String buildLog = file.getText( "UTF-8" );
+assert buildLog.contains( 'Ancestor POMs: org.apache:apache:5' );
+
+return true;
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/invoker.properties?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/invoker.properties (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/invoker.properties Mon Jun 23 20:37:28 2014
@@ -0,0 +1 @@
+invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-ancestors
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/pom.xml?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/pom.xml (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/pom.xml Mon Jun 23 20:37:28 2014
@@ -0,0 +1,32 @@
+<?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>display-ancestors-test-without-ancestor</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+ <name>display-ancestors basic test without ancestors</name>
+
+</project>
Added: maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/verify.groovy?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/verify.groovy (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without-ancestor/verify.groovy Mon Jun 23 20:37:28 2014
@@ -0,0 +1,7 @@
+File file = new File( basedir, "build.log" );
+assert file.exists();
+
+String buildLog = file.getText( "UTF-8" );
+assert buildLog.contains( 'No Ancestor POMs!' );
+
+return true;
Added: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java?rev=1604930&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java Mon Jun 23 20:37:28 2014
@@ -0,0 +1,81 @@
+package org.apache.maven.plugin.dependency;
+
+/*
+ * 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 org.apache.commons.lang.StringUtils;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.project.MavenProject;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Displays all ancestor POMs of the project. This may be useful in a continuous integration system
+ * where you want to know all parent poms of the project.
+ *
+ * @author Mirko Friedenhagen
+ * @since 2.9
+ */
+@Mojo( name = "display-ancestors", threadSafe = true, requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE )
+public class DisplayAncestorsMojo
+ extends AbstractMojo {
+
+ /**
+ * POM
+ */
+ @Component
+ private MavenProject project;
+
+ @Override
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+
+ final List<String> ancestors = collectAncestors();
+
+ if ( ancestors.isEmpty() ) {
+ getLog().info( "No Ancestor POMs!" );
+ } else {
+ getLog().info( String.format( Locale.US, "Ancestor POMs: %s", StringUtils.join( ancestors, " <- " ) ) );
+ }
+
+ }
+
+ private ArrayList<String> collectAncestors()
+ {
+ final ArrayList<String> ancestors = new ArrayList<String>();
+ MavenProject currentAncestor = project.getParent();
+ while ( currentAncestor != null )
+ {
+ final String gav = String.format( Locale.US, "%s:%s:%s",
+ currentAncestor.getGroupId(), currentAncestor.getArtifactId(), currentAncestor.getVersion() );
+ ancestors.add( gav );
+ currentAncestor = currentAncestor.getParent();
+ }
+ return ancestors;
+ }
+
+}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm?rev=1604930&r1=1604929&r2=1604930&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm Mon Jun 23 20:37:28 2014
@@ -61,6 +61,10 @@ ${project.name}
optionally transitive dependencies and copies them to a specified location, stripping the version if desired.
This goal can also be run from the command line.
+ *{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays all ancestor POMs of the project.
+ This may be useful in a continuous integration system where you want to know all parent poms of the project.
+ This goal can also be run from the command line.
+
*{{{./get-mojo.html}dependency:get}} resolves a single artifact, eventually transitively, from a specified remote repository.
*{{{./go-offline-mojo.html}dependency:go-offline}} tells Maven to resolve everything this project is dependent on
Re: svn commit: r1604930 - in /maven/plugins/trunk/maven-dependency-plugin/src:
it/mdep-450-project-with-ancestor/ it/mdep-450-project-without-ancestor/
main/java/org/apache/maven/plugin/dependency/ site/apt/
Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hervé,
IMO tree is a completely different beast, to be honest having info about
the ancestors seems (now) so basic to me that I would even have this to be
a core feature. No remote lookups are used here whereas tree needs to do a
complete dependency resolution.
Regards
Mirko
--
Sent from my mobile
On Jun 24, 2014 8:15 AM, "Hervé BOUTEMY" <he...@free.fr> wrote:
> useful info
> but couldn't it be added to dependency:tree, instead of a new goal?
>
> here is actual output [1]
> parents could be added before actual dependencies, in reverse order:
> parent-of-parent
> parent
> pom
> \- dependency
>
> WDYT?
>
> Regards,
>
> Hervé
>
> [1]
> http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-dependency-plugin/src/it/tree/expected.txt
>
> Le lundi 23 juin 2014 20:37:29 mfriedenhagen@apache.org a écrit :
> > Author: mfriedenhagen
> > Date: Mon Jun 23 20:37:28 2014
> > New Revision: 1604930
> >
> > URL: http://svn.apache.org/r1604930
> > Log:
> > Fixes MDEP-450: Add goal display-ancestors which will output the line of
> > heritage for parent poms.
> >
> > Added:
> >
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/invoker.properties
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/pom.xml
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/verify.groovy
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/invoker.properties
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/pom.xml
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/verify.groovy
> >
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> > plugin/dependency/DisplayAncestorsMojo.java Modified:
> > maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/invoker.properties URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> >
> c/it/mdep-450-project-with-ancestor/invoker.properties?rev=1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/invoker.properties (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/invoker.properties Mon Jun 23 20:37:28 2014 @@ -0,0 +1 @@
> >
> +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:d
> > isplay-ancestors
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/pom.xml URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> > c/it/mdep-450-project-with-ancestor/pom.xml?rev=1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/pom.xml (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/pom.xml Mon Jun 23 20:37:28 2014 @@ -0,0 +1,38 @@
> > +<?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</groupId>
> > + <artifactId>apache</artifactId>
> > + <version>5</version>
> > + </parent>
> > +
> > + <groupId>org.apache.maven.its.dependency</groupId>
> > + <artifactId>display-ancestors-test-with-ancestor</artifactId>
> > + <version>1.0</version>
> > + <packaging>pom</packaging>
> > + <name>display-ancestors basic test</name>
> > +
> > +</project>
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/verify.groovy URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> > c/it/mdep-450-project-with-ancestor/verify.groovy?rev=1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/verify.groovy (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> > cestor/verify.groovy Mon Jun 23 20:37:28 2014 @@ -0,0 +1,7 @@
> > +File file = new File( basedir, "build.log" );
> > +assert file.exists();
> > +
> > +String buildLog = file.getText( "UTF-8" );
> > +assert buildLog.contains( 'Ancestor POMs: org.apache:apache:5' );
> > +
> > +return true;
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/invoker.properties URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> >
> c/it/mdep-450-project-without-ancestor/invoker.properties?rev=1604930&view=a
> > uto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/invoker.properties (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/invoker.properties Mon Jun 23 20:37:28 2014 @@ -0,0 +1 @@
> >
> +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:d
> > isplay-ancestors
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/pom.xml URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> > c/it/mdep-450-project-without-ancestor/pom.xml?rev=1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/pom.xml (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/pom.xml Mon Jun 23 20:37:28 2014 @@ -0,0 +1,32 @@
> > +<?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>display-ancestors-test-without-ancestor</artifactId>
> > + <version>1.0</version>
> > + <packaging>pom</packaging>
> > + <name>display-ancestors basic test without ancestors</name>
> > +
> > +</project>
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/verify.groovy URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> >
> c/it/mdep-450-project-without-ancestor/verify.groovy?rev=1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/verify.groovy (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> > -ancestor/verify.groovy Mon Jun 23 20:37:28 2014 @@ -0,0 +1,7 @@
> > +File file = new File( basedir, "build.log" );
> > +assert file.exists();
> > +
> > +String buildLog = file.getText( "UTF-8" );
> > +assert buildLog.contains( 'No Ancestor POMs!' );
> > +
> > +return true;
> >
> > Added:
> >
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> > plugin/dependency/DisplayAncestorsMojo.java URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> >
> c/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java?rev
> > =1604930&view=auto
> >
> ===========================================================================
> > === ---
> >
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> > plugin/dependency/DisplayAncestorsMojo.java (added) +++
> >
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> > plugin/dependency/DisplayAncestorsMojo.java Mon Jun 23 20:37:28 2014 @@
> -0,0
> > +1,81 @@
> > +package org.apache.maven.plugin.dependency;
> > +
> > +/*
> > + * 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 org.apache.commons.lang.StringUtils;
> > +import org.apache.maven.plugin.AbstractMojo;
> > +import org.apache.maven.plugin.MojoExecutionException;
> > +import org.apache.maven.plugin.MojoFailureException;
> > +import org.apache.maven.plugins.annotations.Component;
> > +import org.apache.maven.plugins.annotations.LifecyclePhase;
> > +import org.apache.maven.plugins.annotations.Mojo;
> > +import org.apache.maven.project.MavenProject;
> > +
> > +import java.util.ArrayList;
> > +import java.util.List;
> > +import java.util.Locale;
> > +
> > +/**
> > + * Displays all ancestor POMs of the project. This may be useful in a
> > continuous integration system + * where you want to know all parent poms
> of
> > the project.
> > + *
> > + * @author Mirko Friedenhagen
> > + * @since 2.9
> > + */
> > +@Mojo( name = "display-ancestors", threadSafe = true, requiresProject =
> > true, defaultPhase = LifecyclePhase.VALIDATE ) +public class
> > DisplayAncestorsMojo
> > + extends AbstractMojo {
> > +
> > + /**
> > + * POM
> > + */
> > + @Component
> > + private MavenProject project;
> > +
> > + @Override
> > + public void execute()
> > + throws MojoExecutionException, MojoFailureException
> > + {
> > +
> > + final List<String> ancestors = collectAncestors();
> > +
> > + if ( ancestors.isEmpty() ) {
> > + getLog().info( "No Ancestor POMs!" );
> > + } else {
> > + getLog().info( String.format( Locale.US, "Ancestor POMs:
> %s",
> > StringUtils.join( ancestors, " <- " ) ) ); + }
> > +
> > + }
> > +
> > + private ArrayList<String> collectAncestors()
> > + {
> > + final ArrayList<String> ancestors = new ArrayList<String>();
> > + MavenProject currentAncestor = project.getParent();
> > + while ( currentAncestor != null )
> > + {
> > + final String gav = String.format( Locale.US, "%s:%s:%s",
> > + currentAncestor.getGroupId(),
> > currentAncestor.getArtifactId(), currentAncestor.getVersion() ); +
> > ancestors.add( gav );
> > + currentAncestor = currentAncestor.getParent();
> > + }
> > + return ancestors;
> > + }
> > +
> > +}
> >
> > Modified:
> > maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
> URL:
> >
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> > c/site/apt/index.apt.vm?rev=1604930&r1=1604929&r2=1604930&view=diff
> >
> ===========================================================================
> > === ---
> > maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
> > (original) +++
> > maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm Mon
> > Jun 23 20:37:28 2014 @@ -61,6 +61,10 @@ ${project.name}
> > optionally transitive dependencies and copies them to a specified
> > location, stripping the version if desired. This goal can also be run
> from
> > the command line.
> >
> > + *{{{./display-ancestors-mojo.html}dependency:display-ancestors}}
> displays
> > all ancestor POMs of the project. + This may be useful in a continuous
> > integration system where you want to know all parent poms of the
> project. +
> > This goal can also be run from the command line.
> > +
> > *{{{./get-mojo.html}dependency:get}} resolves a single artifact,
> > eventually transitively, from a specified remote repository.
> >
> > *{{{./go-offline-mojo.html}dependency:go-offline}} tells Maven to
> resolve
> > everything this project is dependent on
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
Re: svn commit: r1604930 - in /maven/plugins/trunk/maven-dependency-plugin/src: it/mdep-450-project-with-ancestor/ it/mdep-450-project-without-ancestor/ main/java/org/apache/maven/plugin/dependency/ site/apt/
Posted by Hervé BOUTEMY <he...@free.fr>.
useful info
but couldn't it be added to dependency:tree, instead of a new goal?
here is actual output [1]
parents could be added before actual dependencies, in reverse order:
parent-of-parent
parent
pom
\- dependency
WDYT?
Regards,
Hervé
[1] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-dependency-plugin/src/it/tree/expected.txt
Le lundi 23 juin 2014 20:37:29 mfriedenhagen@apache.org a écrit :
> Author: mfriedenhagen
> Date: Mon Jun 23 20:37:28 2014
> New Revision: 1604930
>
> URL: http://svn.apache.org/r1604930
> Log:
> Fixes MDEP-450: Add goal display-ancestors which will output the line of
> heritage for parent poms.
>
> Added:
>
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/invoker.properties
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/pom.xml
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/verify.groovy
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/invoker.properties
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/pom.xml
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/verify.groovy
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> plugin/dependency/DisplayAncestorsMojo.java Modified:
> maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/invoker.properties URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-with-ancestor/invoker.properties?rev=1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/invoker.properties (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/invoker.properties Mon Jun 23 20:37:28 2014 @@ -0,0 +1 @@
> +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:d
> isplay-ancestors
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/pom.xml URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-with-ancestor/pom.xml?rev=1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/pom.xml (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/pom.xml Mon Jun 23 20:37:28 2014 @@ -0,0 +1,38 @@
> +<?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</groupId>
> + <artifactId>apache</artifactId>
> + <version>5</version>
> + </parent>
> +
> + <groupId>org.apache.maven.its.dependency</groupId>
> + <artifactId>display-ancestors-test-with-ancestor</artifactId>
> + <version>1.0</version>
> + <packaging>pom</packaging>
> + <name>display-ancestors basic test</name>
> +
> +</project>
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/verify.groovy URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-with-ancestor/verify.groovy?rev=1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/verify.groovy (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-with-an
> cestor/verify.groovy Mon Jun 23 20:37:28 2014 @@ -0,0 +1,7 @@
> +File file = new File( basedir, "build.log" );
> +assert file.exists();
> +
> +String buildLog = file.getText( "UTF-8" );
> +assert buildLog.contains( 'Ancestor POMs: org.apache:apache:5' );
> +
> +return true;
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/invoker.properties URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-without-ancestor/invoker.properties?rev=1604930&view=a
> uto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/invoker.properties (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/invoker.properties Mon Jun 23 20:37:28 2014 @@ -0,0 +1 @@
> +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:d
> isplay-ancestors
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/pom.xml URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-without-ancestor/pom.xml?rev=1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/pom.xml (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/pom.xml Mon Jun 23 20:37:28 2014 @@ -0,0 +1,32 @@
> +<?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>display-ancestors-test-without-ancestor</artifactId>
> + <version>1.0</version>
> + <packaging>pom</packaging>
> + <name>display-ancestors basic test without ancestors</name>
> +
> +</project>
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/verify.groovy URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/it/mdep-450-project-without-ancestor/verify.groovy?rev=1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/verify.groovy (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/it/mdep-450-project-without
> -ancestor/verify.groovy Mon Jun 23 20:37:28 2014 @@ -0,0 +1,7 @@
> +File file = new File( basedir, "build.log" );
> +assert file.exists();
> +
> +String buildLog = file.getText( "UTF-8" );
> +assert buildLog.contains( 'No Ancestor POMs!' );
> +
> +return true;
>
> Added:
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> plugin/dependency/DisplayAncestorsMojo.java URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/main/java/org/apache/maven/plugin/dependency/DisplayAncestorsMojo.java?rev
> =1604930&view=auto
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> plugin/dependency/DisplayAncestorsMojo.java (added) +++
> maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/
> plugin/dependency/DisplayAncestorsMojo.java Mon Jun 23 20:37:28 2014 @@ -0,0
> +1,81 @@
> +package org.apache.maven.plugin.dependency;
> +
> +/*
> + * 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 org.apache.commons.lang.StringUtils;
> +import org.apache.maven.plugin.AbstractMojo;
> +import org.apache.maven.plugin.MojoExecutionException;
> +import org.apache.maven.plugin.MojoFailureException;
> +import org.apache.maven.plugins.annotations.Component;
> +import org.apache.maven.plugins.annotations.LifecyclePhase;
> +import org.apache.maven.plugins.annotations.Mojo;
> +import org.apache.maven.project.MavenProject;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +import java.util.Locale;
> +
> +/**
> + * Displays all ancestor POMs of the project. This may be useful in a
> continuous integration system + * where you want to know all parent poms of
> the project.
> + *
> + * @author Mirko Friedenhagen
> + * @since 2.9
> + */
> +@Mojo( name = "display-ancestors", threadSafe = true, requiresProject =
> true, defaultPhase = LifecyclePhase.VALIDATE ) +public class
> DisplayAncestorsMojo
> + extends AbstractMojo {
> +
> + /**
> + * POM
> + */
> + @Component
> + private MavenProject project;
> +
> + @Override
> + public void execute()
> + throws MojoExecutionException, MojoFailureException
> + {
> +
> + final List<String> ancestors = collectAncestors();
> +
> + if ( ancestors.isEmpty() ) {
> + getLog().info( "No Ancestor POMs!" );
> + } else {
> + getLog().info( String.format( Locale.US, "Ancestor POMs: %s",
> StringUtils.join( ancestors, " <- " ) ) ); + }
> +
> + }
> +
> + private ArrayList<String> collectAncestors()
> + {
> + final ArrayList<String> ancestors = new ArrayList<String>();
> + MavenProject currentAncestor = project.getParent();
> + while ( currentAncestor != null )
> + {
> + final String gav = String.format( Locale.US, "%s:%s:%s",
> + currentAncestor.getGroupId(),
> currentAncestor.getArtifactId(), currentAncestor.getVersion() ); +
> ancestors.add( gav );
> + currentAncestor = currentAncestor.getParent();
> + }
> + return ancestors;
> + }
> +
> +}
>
> Modified:
> maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm URL:
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/sr
> c/site/apt/index.apt.vm?rev=1604930&r1=1604929&r2=1604930&view=diff
> ===========================================================================
> === ---
> maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm
> (original) +++
> maven/plugins/trunk/maven-dependency-plugin/src/site/apt/index.apt.vm Mon
> Jun 23 20:37:28 2014 @@ -61,6 +61,10 @@ ${project.name}
> optionally transitive dependencies and copies them to a specified
> location, stripping the version if desired. This goal can also be run from
> the command line.
>
> + *{{{./display-ancestors-mojo.html}dependency:display-ancestors}} displays
> all ancestor POMs of the project. + This may be useful in a continuous
> integration system where you want to know all parent poms of the project. +
> This goal can also be run from the command line.
> +
> *{{{./get-mojo.html}dependency:get}} resolves a single artifact,
> eventually transitively, from a specified remote repository.
>
> *{{{./go-offline-mojo.html}dependency:go-offline}} tells Maven to resolve
> everything this project is dependent on
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org