Author: pgier Date: Tue Feb 22 22:35:07 2011 New Revision: 1073530 URL: http://svn.apache.org/viewvc?rev=1073530&view=rev Log: [MDEPLOY-48] Add options to deploy sources and javadoc along with main jar when using deploy-file.
Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties (with props) maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh (with props) Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties Tue Feb 22 22:35:07 2011 @@ -0,0 +1,5 @@ +# Clean build of the jars +invoker.goals = clean package + +# Deploy the jars in a separate step +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:deploy-file Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml Tue Feb 22 22:35:07 2011 @@ -0,0 +1,85 @@ +<?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.deploy</groupId> + <artifactId>test</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>deploy-attached-sources</name> + <description>sample jar project with attached sources</description> + <url>http://jira.codehaus.org/browse/MDEPLOY-48</url> + + <distributionManagement> + <repository> + <id>repo1</id> + <name>Maven Central Repository</name> + <url>scp://foo.org/m2/release</url> + </repository> + <snapshotRepository> + <id>repo1</id> + <name>Maven Central Repository</name> + <url>scp://foo.org/m2/snapshot</url> + </snapshotRepository> + </distributionManagement> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.1.2</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.7</version> + <executions> + <execution> + <id>attach-javadoc</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <!-- Deployments will be written to ${basedir}/target --> + <altDeploymentRepository>mine::default::file://${basedir}/target</altDeploymentRepository> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh Tue Feb 22 22:35:07 2011 @@ -0,0 +1,7 @@ +import java.io.*; +import java.util.*; + +file = new File( basedir, "target/repo" ); +file.mkdirs(); + +return true; Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/setup.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java Tue Feb 22 22:35:07 2011 @@ -0,0 +1,38 @@ +package org.apache.maven.test; + +/* + * 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. + */ + +/** + * Hello World class + */ +public class HelloWorld +{ + + /** + * Main method + * @param args + */ + public static void main( String[] args ) + { + System.out.println( "Hello world" ); + + } + +} Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/java/org/apache/maven/test/HelloWorld.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt Tue Feb 22 22:35:07 2011 @@ -0,0 +1,2 @@ +nothing to see here + Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/src/main/resources/foo.txt ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties Tue Feb 22 22:35:07 2011 @@ -0,0 +1,8 @@ +# Properties passed to invocations of the deploy plugin +pomFile = ${basedir}/pom.xml + +file = ${basedir}/target/${project.artifactId}-${project.version}.jar +sources = ${basedir}/target/${project.artifactId}-${project.version}-sources.jar +javadoc = ${basedir}/target/${project.artifactId}-${project.version}-javadoc.jar + +url = file://${basedir}/target/repo Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/test.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh?rev=1073530&view=auto ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh (added) +++ maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh Tue Feb 22 22:35:07 2011 @@ -0,0 +1,79 @@ + +/* + * 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.*; +import java.util.*; +import java.util.jar.*; +import org.codehaus.plexus.util.*; + +boolean result = true; + +try +{ + File target = new File( basedir, "target" ); + if ( !target.exists() || !target.isDirectory() ) + { + System.err.println( "target file is missing or not a directory." ); + return false; + } + + File deployedDir = new File ( target, "repo/org/apache/maven/its/deploy/test/1.0-SNAPSHOT/" ); + if ( !deployedDir.isDirectory() ) + { + System.err.println( "deployedDir is missing or is not a directory." ); + return false; + } + + boolean sourcesExists = false; + boolean javadocsExists = false; + + String [] fileList = deployedDir.list(); + for ( int i=0; i<fileList.length; ++i ) + { + if ( fileList[i].endsWith( "-1-sources.jar" ) ) + { + sourcesExists = true; + } + if ( fileList[i].endsWith( "-1-javadoc.jar" ) ) + { + javadocsExists = true; + } + } + + if ( !sourcesExists ) + { + System.err.println( "Unable to find deployed sources jar" ); + return false; + } + + if ( !javadocsExists ) + { + System.err.println( "Unable to find deployed javadocs jar" ); + return false; + } + +} +catch( Throwable e ) +{ + e.printStackTrace(); + result = false; +} + +return result; Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/deploy-attached-sources/verify.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=1073530&r1=1073529&r2=1073530&view=diff ============================================================================== --- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java (original) +++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java Tue Feb 22 22:35:07 2011 @@ -21,6 +21,7 @@ package org.apache.maven.plugin.deploy; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; +import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; @@ -99,6 +100,22 @@ public class DeployFileMojo private File file; /** + * The bundled API docs for the artifact. + * + * @parameter expression="${javadoc}" + * @since 2.6 + */ + private File javadoc; + + /** + * The bundled sources for the artifact. + * + * @parameter expression="${sources}" + * @since 2.6 + */ + private File sources; + + /** * Server Id to map on the <id> under <server> section of settings.xml * In most cases, this parameter will be required for authentication. * @@ -238,6 +255,33 @@ public class DeployFileMojo { throw new MojoExecutionException( e.getMessage(), e ); } + + if ( sources != null ) + { + artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "sources" ); + try + { + getDeployer().deploy( sources, artifact, deploymentRepository, getLocalRepository() ); + } + catch ( ArtifactDeploymentException e ) + { + throw new MojoExecutionException( "Error deploying sources " + sources + ": " + e.getMessage(), e ); + } + } + + if ( javadoc != null ) + { + artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "javadoc" ); + try + { + getDeployer().deploy( javadoc, artifact, deploymentRepository, getLocalRepository() ); + } + catch ( ArtifactDeploymentException e ) + { + throw new MojoExecutionException( "Error deploying API docs " + javadoc + ": " + e.getMessage(), e ); + } + } + } /**