Author: skygo Date: Wed May 29 08:23:27 2013 New Revision: 1487396 URL: http://svn.apache.org/r1487396 Log: Add dist tool plugins WIP
Added: maven/sandbox/trunk/dist-tools/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt (with props) maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml (with props) maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml (with props) maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java (with props) maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java (with props) maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/mavendb.csv maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh (with props) Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt Wed May 29 08:23:27 2013 @@ -0,0 +1 @@ +JSOUP is under MIT licence \ No newline at end of file Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/NOTICE.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml Wed May 29 08:23:27 2013 @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<actions> + <action> + <actionName>CUSTOM-dummytest</actionName> + <displayName>dummytest</displayName> + <goals> + <goal>org.apache.maven.dist.tools:dist-tool-plugin:check-source</goal> + </goals> + </action> + </actions> Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/nbactions.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: 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=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml Wed May 29 08:23:27 2013 @@ -0,0 +1,100 @@ +<?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> + <artifactId>dist-tool-plugin</artifactId> + <groupId>org.apache.maven.dist.tools</groupId> + <version>0.0.1-SNAPSHOT</version> + <packaging>maven-plugin</packaging> + <description>Dist tool plugin. + Not to be released.</description> + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>3.0.5</version> + <type>jar</type> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.2</version> + </dependency> + <dependency> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>1.7.2</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.2</version> + <configuration> + <!-- see http://jira.codehaus.org/browse/MNG-5346 --> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + <executions> + <execution> + <id>mojo-descriptor</id> + <goals> + <goal>descriptor</goal> + </goals> + </execution> + <!-- if you want to generate help goal --> + <execution> + <id>help-goal</id> + <goals> + <goal>helpmojo</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <properties> + <netbeans.checkstyle.format>true</netbeans.checkstyle.format> + </properties> + <reporting> + <plugins> + + <!-- jxr first --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>${jxrVersion}</version> + <configuration> + <aggregate>true</aggregate> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.10</version> + <configuration> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + <configLocation>config/maven_checks.xml</configLocation> + </configuration> + </plugin> + </plugins> + </reporting> +</project> \ No newline at end of file Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java Wed May 29 08:23:27 2013 @@ -0,0 +1,254 @@ +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.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.LinkedList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + + +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author skygo + */ +@Mojo( name = "check-source" ) +public class DistMojo extends AbstractMojo +{ + + // parameters for future usage + @Parameter( property = "repository.url", defaultValue = "http://repo1.maven.org/maven2/" ) + private String repoBaseUrl; + @Parameter( property = "database.url", defaultValue = "db/mavendb.csv" ) + private File db; + private List<Request> requestList = new LinkedList<Request>(); + // parameters for future usage + + private enum CheckType + { + + SOURCE + } + + private void checkRepos( String repourl, Request r, String version, CheckType ct ) throws IOException + { + Document doc = Jsoup.connect( repourl ).get(); + Elements links = doc.select( "a[href]" ); + List<String> source = new LinkedList<String>(); + List<String> central = new LinkedList<String>(); + switch ( ct ) + { + case SOURCE: + { + // http://maven.apache.org/developers/release/maven-project-release-procedure.html#Copy_the_source_release_to_the_Apache_Distribution_Area + // build source artifact name + source.add( r.artifactId + "-" + version + "-" + "source-release.zip" ); + source.add( r.artifactId + "-" + version + "-" + "source-release.zip.asc" ); + source.add( r.artifactId + "-" + version + "-" + "source-release.zip.md5" ); + } + break; + default: + getLog().warn( "For future extensions" ); + + } + + for ( Element e : links ) + { + central.add( e.attr( "href" ) ); + } + source.removeAll( central ); + if ( !source.isEmpty() ) + { + for ( String sourceItem : source ) + { + getLog().error( "Missing:" + sourceItem + " in " + repourl ); + } + } + } + + private void checkArtifact( Request r, CheckType ct ) + { + InputStream input = null; + try + { + URL url = new URL( repoBaseUrl + r.getGroupId().replaceAll( "\\.", "/" ) + "/" + r.getArtifactId() + "/maven-metadata.xml" ); + URLConnection conn = url.openConnection(); + input = conn.getInputStream(); + JAXBContext context = JAXBContext.newInstance( MavenMetadata.class ); + Unmarshaller unmarshaller = context.createUnmarshaller(); + MavenMetadata metadata = ( MavenMetadata ) unmarshaller.unmarshal( input ); + + getLog().info( "Checking: " + r.getGroupId() + ":" + r.getArtifactId() + " " + metadata.versioning.latest ); + getLog().warn( "all version in central " + metadata.versioning.versions ); + +// central + checkRepos( repoBaseUrl + r.getGroupId().replaceAll( "\\.", "/" ) + "/" + r.getArtifactId() + "/" + metadata.versioning.latest, r, metadata.versioning.latest, ct ); + //dist + checkRepos( r.dist, r, metadata.versioning.latest, ct ); + } + catch ( MalformedURLException ex ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, ex ); + } + catch ( IOException ex ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, ex ); + } + catch ( JAXBException ex ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, ex ); + } + finally + { + try + { + if ( input != null ) + { + input.close(); + } + } + catch ( IOException ex ) + { + Logger.getLogger( DistMojo.class + .getName() ).log( Level.SEVERE, null, ex ); + } + } + } + + public void execute() throws MojoExecutionException, MojoFailureException + { + BufferedReader reader = null; + try + { + if ( db.getName().equals( "mavendb.csv" ) ) + { + reader = new BufferedReader( + new InputStreamReader( Thread.currentThread().getContextClassLoader().getResourceAsStream( "db/mavendb.csv" ) ) ); + } + else + { + reader = new BufferedReader( new FileReader( db ) ); + } + + String text; + while ( (text = reader.readLine()) != null ) + { + String[] first = text.split( ";" ); + String[] artifactInfo = first[0].split( ":" ); + requestList.add( new Request( artifactInfo[0], artifactInfo[1], first[1] ) ); + + + } + } + catch ( FileNotFoundException e ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, e ); + } + catch ( IOException e ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, e ); + } + finally + { + try + { + if ( reader != null ) + { + reader.close(); + } + } + catch ( IOException e ) + { + Logger.getLogger( DistMojo.class.getName() ).log( Level.SEVERE, null, e ); + } + } + for ( Request r : requestList ) + { + checkArtifact( r, CheckType.SOURCE ); + } + + + } + + private static class Request + { + + private final String groupId; + private final String artifactId; + private final String dist; + + public Request( String groupId, String artifactId, String dist ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.dist = dist; + + } + + /** + * @return the groupId + */ + public String getGroupId() + { + return groupId; + } + + /** + * @return the artifactId + */ + public String getArtifactId() + { + return artifactId; + } + + /** + * @return the dist + */ + public String getDist() + { + return dist; + } + } +} Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/DistMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java Wed May 29 08:23:27 2013 @@ -0,0 +1,56 @@ +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.util.LinkedList; +import java.util.List; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author skygo + */ +@XmlRootElement( name = "metadata" ) +public class MavenMetadata +{ +// reverse eng from wagon metadata + + @XmlElement + String groupId; + @XmlElement + String artifactId; + @XmlElement + VersioningTag versioning = new VersioningTag(); + + public static class VersioningTag + { + + @XmlElement + String latest; + @XmlElement + String release; + @XmlElement + String lastUpdated; + @XmlElementWrapper( name = "versions" ) + @XmlElement( name = "version" ) + List<String> versions = new LinkedList<String>(); + } +} Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/java/org/apache/maven/dist/tools/MavenMetadata.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/mavendb.csv URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/mavendb.csv?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/mavendb.csv (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/src/main/resources/db/mavendb.csv Wed May 29 08:23:27 2013 @@ -0,0 +1,46 @@ +org.apache.maven.wagon:wagon;https://dist.apache.org/repos/dist/release/maven/wagon/ +org.apache.maven.reporting:maven-reporting-exec;https://dist.apache.org/repos/dist/release/maven/reporting/ +org.apache.maven.plugins:maven-acr-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-ant-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-antrun-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-assembly-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-changelog-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-changes-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-checkstyle-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-clean-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-compiler-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-dependency-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-deploy-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-doap-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-docck-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-ear-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-eclipse-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-ejb-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-gpg-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-help-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-idea-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-install-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-invoker-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-jar-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-jarsigner-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-javadoc-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-linkcheck-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-one-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-patch-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-pdf-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-plugins;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-pmd-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-project-info-reports-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-rar-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-reactor-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-remote-resources-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-repository-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-resources-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-scm-publish-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-shade-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-site-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-source-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-stage-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-toolchains-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-verifier-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ +org.apache.maven.plugins:maven-war-plugin;https://dist.apache.org/repos/dist/release/maven/plugins/ \ No newline at end of file Added: maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh?rev=1487396&view=auto ============================================================================== --- maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh (added) +++ maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh Wed May 29 08:23:27 2013 @@ -0,0 +1 @@ +mvn org.apache.maven.dist.tools:dist-tool-plugin:check-source \ No newline at end of file Propchange: maven/sandbox/trunk/dist-tools/dist-tool-plugin/test.sh ------------------------------------------------------------------------------ svn:eol-style = native