maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1206503 - in /maven/plugins/trunk/maven-project-info-reports-plugin/src: it/full-pom/pom.xml main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java main/resources/project-info-report_en.properties
Date Sat, 26 Nov 2011 17:21:47 GMT
Author: simonetripodi
Date: Sat Nov 26 17:21:46 2011
New Revision: 1206503

URL: http://svn.apache.org/viewvc?rev=1206503&view=rev
Log:
[MPIR-236] Crete a new report to show how to include the module in different build systems

Added:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
  (with props)
Modified:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/it/full-pom/pom.xml
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_en.properties

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/it/full-pom/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/it/full-pom/pom.xml?rev=1206503&r1=1206502&r2=1206503&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/it/full-pom/pom.xml (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/it/full-pom/pom.xml Sat Nov
26 17:21:46 2011
@@ -195,6 +195,7 @@
               <report>scm</report>
               <report>issue-tracking</report>
               <report>mailing-list</report>
+              <report>dependency-info</report>
               <report>dependency-management</report>
               <report>dependencies</report>
               <report>cim</report>

Added: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java?rev=1206503&view=auto
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
(added)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
Sat Nov 26 17:21:46 2011
@@ -0,0 +1,165 @@
+package org.apache.maven.report.projectinfo;
+
+import java.util.Formatter;
+import java.util.Locale;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.i18n.I18N;
+
+/**
+ * Generates the Dependency code snippets to be added to build tools.
+ *
+ * @author <a href="mailto:simonetripodi@apache.org">Simone Tripodi</a>
+ * @version $Id$
+ * @since 2.4.1
+ * @goal dependency-info
+ */
+public final class DependencyInformationReport
+    extends AbstractProjectInfoReport
+{
+
+    private static final String DEPENDNECY_INFO = "dependency-info";
+
+    /**
+     * @parameter default-value="${project.groupId}"
+     * @required
+     */
+    protected String groupId;
+
+    /**
+     * @parameter default-value="${project.artifactId}"
+     * @required
+     */
+    protected String artifactId;
+
+    /**
+     * @parameter default-value="${project.version}"
+     * @required
+     */
+    protected String version;
+
+    /**
+     * @parameter default-value="${project.packaging}"
+     * @required
+     */
+    protected String packaging;
+
+    // ----------------------------------------------------------------------
+    // Public methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOutputName()
+    {
+        return DEPENDNECY_INFO;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected String getI18Nsection()
+    {
+        return DEPENDNECY_INFO;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void executeReport( Locale locale )
+        throws MavenReportException
+    {
+        new DependencyInformationRenderer( getSink(), getI18N( locale ), locale,
+                                           groupId, artifactId, version, packaging )
+            .render();
+    }
+
+    // ----------------------------------------------------------------------
+    // Private
+    // ----------------------------------------------------------------------
+
+    private static final class  DependencyInformationRenderer
+        extends AbstractProjectInfoRenderer
+    {
+
+        private final String groupId;
+
+        private final String artifactId;
+
+        private final String version;
+
+        private final String packaging;
+
+        public DependencyInformationRenderer( Sink sink, I18N i18n, Locale locale,
+                                              String groupId, String artifactId, String version,
String packaging )
+        {
+            super( sink, i18n, locale );
+            this.groupId = groupId;
+            this.artifactId = artifactId;
+            this.version = version;
+            this.packaging = packaging;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        protected String getI18Nsection()
+        {
+            return DEPENDNECY_INFO;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        protected void renderBody()
+        {
+            startSection( getTitle() );
+
+            renderDependencyInfo( "Apache Maven", new Formatter()
+                                                        .format( "<dependency>%n" )
+                                                        .format( "  <groupId>%s</groupId>%n",
groupId )
+                                                        .format( "  <artifactId>%s</artifactId>%n",
artifactId )
+                                                        .format( "  <version>%s</version>%n",
version )
+                                                        .format( "  <packaging>%s</packaging>%n",
packaging )
+                                                        .format( "</dependency>" )
);
+
+            renderDependencyInfo( "Apache Buildr", new Formatter().format( "'%s:%s:%s:%s'",
+                                                                           groupId, artifactId,
packaging, version ) );
+
+            renderDependencyInfo( "Apache Ant", new Formatter()
+                                                        .format( "<dependency org=\"%s\"
name=\"%s\" rev=\"%s\">%n",
+                                                                 groupId, artifactId, version
)
+                                                        .format( "  <artifact name=\"%s\"
type=\"%s\" />%n",
+                                                                 artifactId, packaging )
+                                                        .format( "</dependency>" )
);
+
+            renderDependencyInfo( "Groovy Grape", new Formatter()
+                                                        .format( "@Grapes(%n" )
+                                                        .format( "@Grab(group='%s', module='%s',
version='%s')%n",
+                                                                 groupId,
+                                                                 artifactId,
+                                                                 version )
+                                                        .format( ")" ) );
+
+            renderDependencyInfo( "Grails", new Formatter().format( "compile '%s:%s:%s'",
+                                                                    groupId, artifactId,
version ) );
+
+            endSection();
+        }
+
+        private void renderDependencyInfo( String name, Formatter formatter )
+        {
+            startSection( name );
+            verbatimText( formatter.toString() );
+            endSection();
+        }
+
+    }
+
+}

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependencyInformationReport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_en.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_en.properties?rev=1206503&r1=1206502&r2=1206503&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_en.properties
(original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/resources/project-info-report_en.properties
Sat Nov 26 17:21:46 2011
@@ -21,3 +21,6 @@
 # JVM's default locale (which need not be "en"). See the method javadoc about
 #   ResourceBundle.getBundle(String, Locale, ClassLoader)
 # for a full description of the lookup strategy.
+
+report.dependency-info.name = Dependency Information
+report.dependency-info.title = Dependency Information



Mime
View raw message