Author: khmarbaise Date: Sun Oct 12 18:07:04 2014 New Revision: 1631233 URL: http://svn.apache.org/r1631233 Log: - 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. Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/markdown/index.md maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/site.xml maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml?rev=1631233&r1=1631232&r2=1631233&view=diff ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml (original) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml Sun Oct 12 18:07:04 2014 @@ -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> Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties?rev=1631233&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/invoker.properties Sun Oct 12 18:07:04 2014 @@ -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 Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml?rev=1631233&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/it/check-prerequisites-report/pom.xml Sun Oct 12 18:07:04 2014 @@ -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 Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java?rev=1631233&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistPrerequisiteMojo.java Sun Oct 12 18:07:04 2014 @@ -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; + } + +} Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java?rev=1631233&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/GetPrerequisites.java Sun Oct 12 18:07:04 2014 @@ -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; + } +} Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java?rev=1631233&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenJDKInformation.java Sun Oct 12 18:07:04 2014 @@ -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; + } + +} Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/markdown/index.md URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/markdown/index.md?rev=1631233&r1=1631232&r2=1631233&view=diff ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/markdown/index.md (original) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/markdown/index.md Sun Oct 12 18:07:04 2014 @@ -22,7 +22,7 @@ About dist-tool-plugin 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 @@ Results are displayed in 3 reports: * [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 @@ in other context, it would require more [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 + Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/site.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/site.xml?rev=1631233&r1=1631232&r2=1631233&view=diff ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/site.xml (original) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/site/site.xml Sun Oct 12 18:07:04 2014 @@ -35,6 +35,7 @@ under the License. <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 @@ under the License. </menu> <menu ref="reports"/> </body> -</project> \ No newline at end of file +</project> Modified: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java?rev=1631233&r1=1631232&r2=1631233&view=diff ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java (original) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/test/java/org/apache/maven/dist/tools/PatternTest.java Sun Oct 12 18:07:04 2014 @@ -16,9 +16,10 @@ package org.apache.maven.dist.tools; * 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.*; /** *