- Enhancement of the dist-tool
Creating a report about the prerequisites + JDK versions
of maven plugins as they are published at the moment.
This is the first implementation and code looks ugly
many things are hard coded at the moment.
git-svn-id: https://svn.apache.org/repos/asf/maven/sandbox/trunk@1631233 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dist-tools/dist-tool-plugin/pom.xml b/dist-tools/dist-tool-plugin/pom.xml
index ac98cdb..b00b2b5 100644
--- a/dist-tools/dist-tool-plugin/pom.xml
+++ b/dist-tools/dist-tool-plugin/pom.xml
@@ -236,6 +236,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
+ <version>2.4</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
@@ -278,6 +279,7 @@
<report>check-site</report>
<report>check-source-release</report>
<report>check-index-page</report>
+ <report>check-prerequisites-site</report>
</reports>
</reportSet>
<reportSet>
@@ -331,4 +333,4 @@
</build>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
diff --git a/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties b/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties
new file mode 100644
index 0000000..f9993f5
--- /dev/null
+++ b/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties
@@ -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 = -X site
\ No newline at end of file
diff --git a/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml b/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml
new file mode 100644
index 0000000..62d8e3a
--- /dev/null
+++ b/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more
+ contributor license agreements. See the NOTICE file ~ distributed with this
+ work for additional information ~ regarding copyright ownership. The ASF
+ licenses this file ~ to you under the Apache License, Version 2.0 (the ~
+ "License"); you may not use this file except in compliance ~ with the License.
+ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ ~ Unless required by applicable law or agreed to in writing, ~ software
+ distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the
+ License for the ~ specific language governing permissions and limitations
+ ~ under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.dist.tools.its</groupId>
+ <artifactId>check-prerequisites-site-report</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>check-prerequisites-site</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
\ No newline at end of file
diff --git a/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java
new file mode 100644
index 0000000..423bafa
--- /dev/null
+++ b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java
@@ -0,0 +1,169 @@
+package org.apache.maven.dist.tools;
+
+/*
+ * 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;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.siterenderer.Renderer;
+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.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+
+/**
+ * @author Karl Heinz Marbaise
+ */
+@Mojo( name = "check-prerequisites-site", requiresProject = false )
+public class DistPrerequisiteMojo
+ extends AbstractMavenReport
+{
+
+ /**
+ * Site renderer.
+ */
+ @Component
+ protected Renderer siteRenderer;
+
+ /**
+ * Reporting directory.
+ */
+ @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true )
+ protected File outputDirectory;
+
+ /**
+ * Maven project.
+ */
+ @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ protected MavenProject project;
+
+ @Override
+ public String getName( Locale locale )
+ {
+ return "Dist Tool> Prerequisites";
+ }
+
+ @Override
+ public String getDescription( Locale locale )
+ {
+ return "Maven version prerequisites and JDK Version";
+ }
+
+ @Override
+ protected void executeReport( Locale locale )
+ throws MavenReportException
+ {
+ if ( !outputDirectory.exists() )
+ {
+ outputDirectory.mkdirs();
+ }
+
+ GetPrerequisites prerequisites = new GetPrerequisites();
+
+ Sink sink = getSink();
+
+ sink.head();
+ sink.title();
+ sink.text( "Check Prerequisites" );
+ sink.title_();
+ sink.head_();
+ sink.body();
+
+ Map<ArtifactVersion, List<MavenJDKInformation>> groupedPrequisites = prerequisites.getGroupedPrequisites();
+
+ sink.table();
+
+ ArrayList<ArtifactVersion> sortedVersion = new ArrayList<ArtifactVersion>();
+ sortedVersion.addAll( groupedPrequisites.keySet() );
+
+ Collections.<ArtifactVersion>sort( sortedVersion );
+
+ for ( ArtifactVersion mavenVersion : sortedVersion)
+ {
+ sink.tableRow();
+ sink.tableHeaderCell();
+ sink.rawText( "Maven Version Prerequisite " + mavenVersion );
+ sink.tableHeaderCell_();
+
+ sink.tableHeaderCell();
+ sink.rawText( "Maven Version");
+ sink.tableHeaderCell_();
+
+ sink.tableHeaderCell();
+ sink.rawText( "JDK Version");
+ sink.tableHeaderCell_();
+
+ sink.tableRow_();
+
+ for ( MavenJDKInformation mavenJDKInformation : groupedPrequisites.get( mavenVersion ) )
+ {
+ sink.tableRow();
+ sink.tableCell();
+ sink.text( mavenJDKInformation.getPluginName() );
+ sink.tableCell_();
+ sink.tableCell();
+ sink.text( mavenJDKInformation.getMavenVersion().toString() );
+ sink.tableCell_();
+
+ sink.tableCell();
+ sink.text( mavenJDKInformation.getJdkVersion() );
+ sink.tableCell_();
+ sink.tableRow_();
+ }
+
+ }
+
+ sink.table_();
+ sink.body_();
+ }
+
+ @Override
+ public String getOutputName()
+ {
+ return "dist-tool-prerequisites";
+ }
+
+ @Override
+ protected Renderer getSiteRenderer()
+ {
+ return siteRenderer;
+ }
+
+ @Override
+ protected String getOutputDirectory()
+ {
+ return outputDirectory.getAbsolutePath();
+ }
+
+ @Override
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+}
diff --git a/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java
new file mode 100644
index 0000000..91c5157
--- /dev/null
+++ b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java
@@ -0,0 +1,126 @@
+package org.apache.maven.dist.tools;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+public class GetPrerequisites
+{
+ /**
+ * Currently hard code should be somehow extracted from the configuration file....
+ */
+ public String[] pluginNames = {
+ "maven-acr-plugin",
+ "maven-ant-plugin",
+ "maven-antrun-plugin",
+ "maven-assembly-plugin",
+ "maven-changelog-plugin",
+ "maven-changes-plugin",
+ "maven-checkstyle-plugin",
+ "maven-clean-plugin",
+ "maven-compiler-plugin",
+ "maven-dependency-plugin",
+ "maven-deploy-plugin",
+ "maven-doap-plugin",
+ "maven-docck-plugin",
+ "maven-ear-plugin",
+ "maven-eclipse-plugin",
+ "maven-ejb-plugin",
+ "maven-gpg-plugin",
+ "maven-help-plugin",
+ "maven-install-plugin",
+ "maven-invoker-plugin",
+ "maven-jar-plugin",
+ "maven-jarsigner-plugin",
+ "maven-javadoc-plugin",
+ "maven-linkcheck-plugin",
+ "maven-patch-plugin",
+ "maven-pdf-plugin",
+ "maven-pmd-plugin",
+ "maven-project-info-reports-plugin",
+ "maven-rar-plugin",
+ "maven-remote-resources-plugin",
+ "maven-repository-plugin",
+ "maven-scm-publish-plugin",
+ "maven-shade-plugin",
+ "maven-site-plugin",
+ "maven-source-plugin",
+ "maven-stage-plugin",
+ "maven-toolchains-plugin",
+ "maven-verifier-plugin",
+ "maven-war-plugin",
+
+ };
+
+ public String BASEURL = "http://maven.apache.org/plugins/";
+
+ public MavenJDKInformation getMavenJdkInformation( String baseURL, String pluginName )
+ throws IOException
+ {
+ Document doc = Jsoup.connect( baseURL + "/" + pluginName + "/plugin-info.html" ).get();
+
+ Elements select = doc.select( "table.bodyTable" );
+
+ Element tableInfo = select.get( 1 );
+ Elements elementsByAttribute_a = tableInfo.getElementsByAttributeValue( "class", "a" );
+ Elements elementsByAttribute_b = tableInfo.getElementsByAttributeValue( "class", "b" );
+ String mavenVersion = elementsByAttribute_a.first().text();
+ String jdkVersion = elementsByAttribute_b.first().text();
+
+ //FIXME: Sometimes it happens that the indexes are swapped (I don't know why...I have to find out why...)
+ if (mavenVersion.startsWith( "JDK" )) {
+ String tmp = jdkVersion;
+ jdkVersion = mavenVersion;
+ mavenVersion = tmp;
+ }
+
+ //Leave only version part...
+ mavenVersion = mavenVersion.replace( "Maven ", "" );
+ jdkVersion = jdkVersion.replace( "JDK ", "" );
+
+ MavenJDKInformation mjdk = new MavenJDKInformation( pluginName, mavenVersion, jdkVersion );
+ return mjdk;
+ }
+
+ public List<MavenJDKInformation> getPrequisites() {
+ List<MavenJDKInformation> result = new ArrayList<MavenJDKInformation>();
+
+ for ( int i = 0; i < pluginNames.length; i++ )
+ {
+ try
+ {
+ result.add( getMavenJdkInformation( BASEURL, pluginNames[i] ));
+ }
+ catch ( IOException e )
+ {
+ //What could happen?
+ //check it...
+ }
+ }
+ return result;
+ }
+
+
+ public Map<ArtifactVersion, List<MavenJDKInformation>> getGroupedPrequisites() {
+ Map<ArtifactVersion, List<MavenJDKInformation>> result = new HashMap<ArtifactVersion, List<MavenJDKInformation>>();
+
+ List<MavenJDKInformation> prequisites = getPrequisites();
+ for ( MavenJDKInformation mavenJDKInformation : prequisites )
+ {
+ if (!result.containsKey( mavenJDKInformation.getMavenVersion() )) {
+ result.put( mavenJDKInformation.getMavenVersion(), new ArrayList<MavenJDKInformation>());
+ }
+ result.get( mavenJDKInformation.getMavenVersion()).add( mavenJDKInformation );
+ }
+
+ return result;
+ }
+}
diff --git a/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java
new file mode 100644
index 0000000..6cdca98
--- /dev/null
+++ b/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java
@@ -0,0 +1,51 @@
+package org.apache.maven.dist.tools;
+
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+
+public class MavenJDKInformation
+{
+ private String pluginName;
+
+ private ArtifactVersion mavenVersion;
+
+ private String jdkVersion;
+
+ public MavenJDKInformation( String pluginName, String mavenVersion, String jdkVersion )
+ {
+ this.pluginName = pluginName;
+ this.mavenVersion = new DefaultArtifactVersion( mavenVersion );
+ this.jdkVersion = jdkVersion;
+ }
+
+ public ArtifactVersion getMavenVersion()
+ {
+ return mavenVersion;
+ }
+
+ public void setMavenVersion( String mavenVersion )
+ {
+ this.mavenVersion = new DefaultArtifactVersion( mavenVersion );
+ }
+
+ public String getJdkVersion()
+ {
+ return jdkVersion;
+ }
+
+ public void setJdkVersion( String jdkVersion )
+ {
+ this.jdkVersion = jdkVersion;
+ }
+
+ public String getPluginName()
+ {
+ return pluginName;
+ }
+
+ public void setPluginName( String pluginName )
+ {
+ this.pluginName = pluginName;
+ }
+
+}
diff --git a/dist-tools/dist-tool-plugin/src/site/markdown/index.md b/dist-tools/dist-tool-plugin/src/site/markdown/index.md
index e6b14d5..92e455d 100644
--- a/dist-tools/dist-tool-plugin/src/site/markdown/index.md
+++ b/dist-tools/dist-tool-plugin/src/site/markdown/index.md
@@ -22,7 +22,7 @@
The dist-tool-plugin checks that [Maven release process][6] has been fully applied across every artifact, as listed in [configuration file][4].
-Results are displayed in 3 reports:
+Results are displayed in 4 reports:
* [Dist Tool> Source Release][2] report, for checks about artifacts [source release publication][5],
@@ -30,6 +30,8 @@
* [Dist Tool> Index page][3] report, for checks about index pages.
+* [Dist Tool> Prerequisites][7] report, for checks about prerequisites.
+
Notice that this plugin is actually intended for Maven itself only: if interest is expressed to use it
in other context, it would require more configurations.
@@ -39,4 +41,5 @@
[4]: ./dist-tool.conf.html
[5]: http://maven.apache.org/developers/release/maven-project-release-procedure.html#Copy_the_source_release_to_the_Apache_Distribution_Area
[6]: http://maven.apache.org/developers/release/releasing.html
-
\ No newline at end of file
+[7]: ./dist-tool-prerequisites.html
+
diff --git a/dist-tools/dist-tool-plugin/src/site/site.xml b/dist-tools/dist-tool-plugin/src/site/site.xml
index a37ebe5..0245898 100644
--- a/dist-tools/dist-tool-plugin/src/site/site.xml
+++ b/dist-tools/dist-tool-plugin/src/site/site.xml
@@ -35,6 +35,7 @@
<item name="Dist Tool> Source Release" href="dist-tool-check-source-release.html" />
<item name="Dist Tool> Sites" href="dist-tool-check-site.html" />
<item name="Dist Tool> Index Pages" href="dist-tool-check-index-page.html" />
+ <item name="Dist Tool> Prerequisites" href="dist-tool-prerequisites.html" />
<item name="Configuration" href="dist-tool.conf.html" />
</menu>
<menu name="for dev">
@@ -42,4 +43,4 @@
</menu>
<menu ref="reports"/>
</body>
-</project>
\ No newline at end of file
+</project>
diff --git a/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java b/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java
index aaf7deb..063619c 100644
--- a/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java
+++ b/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java
@@ -16,9 +16,10 @@
* limitations under the License.
*/
-import java.util.regex.Pattern;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
-import static org.junit.Assert.*;
/**
*