From 35fe47e7dcc0f70b8e3cc5c1e675ca2d0da62cfc Mon Sep 17 00:00:00 2001 From: Vincent Siveton Date: Sun, 16 Oct 2005 21:51:20 +0000 Subject: [PATCH] MNG-796: Added a download report git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@322514 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugins/maven-assembly-plugin/pom.xml | 6 + .../maven/plugin/assembly/AssemblyMojo.java | 65 ++- .../maven/plugin/assembly/DownloadReport.java | 415 ++++++++++++++++++ .../resources/assembly-plugin_en.properties | 21 + .../resources/assembly-plugin_fr.properties | 21 + .../src/site/apt/howto.apt | 44 +- .../assembly-plugin-test1/LICENSE.txt | 202 +++++++++ .../projects/assembly-plugin-test1/pom.xml | 88 ++++ .../src/assemble/bin.xml | 66 +++ .../assembly-plugin-test1/src/bin/test.bat | 18 + .../assembly-plugin-test1/src/bin/test.sh | 18 + .../maven/plugin/assembly/test1/App.java | 13 + .../src/site/apt/test.apt | 12 + .../assembly-plugin-test1/src/site/site.xml | 40 ++ .../maven/plugin/assembly/test1/AppTest.java | 38 ++ 15 files changed, 1035 insertions(+), 32 deletions(-) create mode 100644 maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/DownloadReport.java create mode 100644 maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_en.properties create mode 100644 maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_fr.properties create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/LICENSE.txt create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/pom.xml create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/assemble/bin.xml create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.bat create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.sh create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/main/java/org/apache/maven/plugin/assembly/test1/App.java create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/apt/test.apt create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/site.xml create mode 100644 maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/test/java/org/apache/maven/plugin/assembly/test1/AppTest.java diff --git a/maven-plugins/maven-assembly-plugin/pom.xml b/maven-plugins/maven-assembly-plugin/pom.xml index 198da7517e..4974770ae9 100755 --- a/maven-plugins/maven-assembly-plugin/pom.xml +++ b/maven-plugins/maven-assembly-plugin/pom.xml @@ -66,5 +66,11 @@ maven-artifact 2.0 + + + org.apache.maven.reporting + maven-reporting-impl + 2.0 + \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java index 6691e7e01c..26cbe9b807 100755 --- a/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java +++ b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java @@ -37,6 +37,7 @@ import org.codehaus.plexus.archiver.tar.TarArchiver; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -147,7 +148,7 @@ public class AssemblyMojo // TODO: how, might we plug this into an installer, such as NSIS? // TODO: allow file mode specifications? - String fullName = finalName + "-" + assembly.getId(); + String fullName = getDistributionName( assembly ); for ( Iterator i = assembly.getFormats().iterator(); i.hasNext(); ) { @@ -168,17 +169,33 @@ public class AssemblyMojo } catch ( ArchiverException e ) { - throw new MojoExecutionException( "Error creating assembly", e ); + throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e ); } catch ( IOException e ) { - throw new MojoExecutionException( "Error creating assembly", e ); + throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e ); } projectHelper.attachArtifact( project, format, assembly.getId(), destFile ); } } + /** + * Get the full name of the distribution artifact + * + * @param assembly + * @return the distribution name + */ + protected String getDistributionName( Assembly assembly ) + { + if ( StringUtils.isEmpty( assembly.getId() ) ) + { + return finalName; + } + + return finalName + "-" + assembly.getId(); + } + protected File createArchive( Archiver archiver, Assembly assembly, String filename ) throws ArchiverException, IOException, MojoExecutionException, MojoFailureException { @@ -270,9 +287,10 @@ public class AssemblyMojo archiver.setDefaultFileMode( Integer.parseInt( dependencySet.getFileMode(), 8 ) ); - getLog().debug( "DependencySet[" + output + "]" + " dir perms: " + - Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " + - Integer.toString( archiver.getDefaultFileMode(), 8 ) ); + getLog().debug( + "DependencySet[" + output + "]" + " dir perms: " + + Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " + + Integer.toString( archiver.getDefaultFileMode(), 8 ) ); AndArtifactFilter filter = new AndArtifactFilter(); filter.add( new ScopeArtifactFilter( dependencySet.getScope() ) ); @@ -298,7 +316,7 @@ public class AssemblyMojo if ( dependencySet.isUnpack() ) { // TODO: something like zipfileset in plexus-archiver -// archiver.addJar( ) + // archiver.addJar( ) // TODO is the extension always 3 characters long? File tempLocation = new File( workDirectory, name.substring( 0, name.length() - 4 ) ); @@ -321,16 +339,16 @@ public class AssemblyMojo } catch ( NoSuchArchiverException e ) { - throw new MojoExecutionException( - "Unable to obtain unarchiver for file '" + artifact.getFile() + "'" ); + throw new MojoExecutionException( "Unable to obtain unarchiver for file '" + + artifact.getFile() + "'" ); } } archiver.addDirectory( tempLocation, output, null, FileUtils.getDefaultExcludes() ); } else { - archiver.addFile( artifact.getFile(), output + - evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact ) ); + archiver.addFile( artifact.getFile(), output + + evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), artifact ) ); } } } @@ -368,10 +386,12 @@ public class AssemblyMojo archiver.setDefaultFileMode( Integer.parseInt( fileSet.getFileMode(), 8 ) ); - getLog().debug( "FileSet[" + output + "]" + " dir perms: " + - Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " + - Integer.toString( archiver.getDefaultFileMode(), 8 ) + - ( fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding() ) ); + getLog() + .debug( + "FileSet[" + output + "]" + " dir perms: " + + Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " + + Integer.toString( archiver.getDefaultFileMode(), 8 ) + + ( fileSet.getLineEnding() == null ? "" : " lineEndings: " + fileSet.getLineEnding() ) ); if ( directory == null ) { @@ -420,6 +440,7 @@ public class AssemblyMojo * @param expression * @param artifact * @return expression + * @throws MojoExecutionException */ private static String evaluateFileNameMapping( String expression, Artifact artifact ) throws MojoExecutionException @@ -511,6 +532,7 @@ public class AssemblyMojo * @param format Archive format * @return archiver Archiver generated * @throws ArchiverException + * @throws NoSuchArchiverException */ private Archiver createArchiver( String format ) throws ArchiverException, NoSuchArchiverException @@ -569,9 +591,8 @@ public class AssemblyMojo out.close(); } - private void copySetReplacingLineEndings( File archiveBaseDir, File tmpDir, String[] includes, String[] excludes, - String lineEnding ) + String lineEnding ) throws ArchiverException { DirectoryScanner scanner = new DirectoryScanner(); @@ -580,16 +601,16 @@ public class AssemblyMojo scanner.setExcludes( excludes ); scanner.scan(); - String [] dirs = scanner.getIncludedDirectories(); + String[] dirs = scanner.getIncludedDirectories(); - for ( int j = 0; j < dirs.length; j ++ ) + for ( int j = 0; j < dirs.length; j++ ) { new File( tempRoot, dirs[j] ).mkdirs(); } - String [] files = scanner.getIncludedFiles(); + String[] files = scanner.getIncludedFiles(); - for ( int j = 0; j < files.length; j ++ ) + for ( int j = 0; j < files.length; j++ ) { File targetFile = new File( tmpDir, files[j] ); @@ -639,7 +660,7 @@ public class AssemblyMojo if ( !siteDirectory.exists() ) { throw new MojoExecutionException( - "site did not exist in the target directory - please run site:site before creating the assembly" ); + "site did not exist in the target directory - please run site:site before creating the assembly" ); } getLog().info( "Adding site directory to assembly : " + siteDirectory ); diff --git a/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/DownloadReport.java b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/DownloadReport.java new file mode 100644 index 0000000000..1544a473c2 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/DownloadReport.java @@ -0,0 +1,415 @@ +package org.apache.maven.plugin.assembly; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.assembly.model.Assembly; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.apache.maven.reporting.MavenReportException; +import org.codehaus.doxia.sink.Sink; +import org.codehaus.doxia.site.renderer.SiteRenderer; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.Xpp3Dom; + +/** + * Generates the Download report. + * + * @goal download + * + * @author Vincent Siveton + * @version $Id $ + */ +public class DownloadReport + extends AbstractMavenReport +{ + /** + * @parameter expression="${project.build.directory}/site" + * @required + */ + private String outputDirectory; + + /** + * @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}" + * @required + * @readonly + */ + private SiteRenderer siteRenderer; + + /** + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + + /** + * The URL of the project's download page, eg http://www.apache.org/dist/maven/binaries/. + * + * @parameter default-value="${project.distributionManagement.downloadUrl}" + * @readonly + */ + private String downloadUrl; + + /** + * The directory to download the artifact in the outputDirectory. + * + * @parameter expression="${downloadDirectory}" + * default-value="download" + * @required + */ + private String downloadDirectory; + + private List distributionFileNames = null; + + /** + * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) + */ + public String getName( Locale locale ) + { + return getBundle( locale ).getString( "report.download.name" ); + } + + /** + * @see org.apache.maven.reporting.MavenReport#getCategoryName() + */ + public String getCategoryName() + { + return CATEGORY_PROJECT_INFORMATION; + } + + /** + * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale) + */ + public String getDescription( Locale locale ) + { + return getBundle( locale ).getString( "report.download.description" ); + } + + /** + * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory() + */ + protected String getOutputDirectory() + { + return outputDirectory; + } + + /** + * @see org.apache.maven.reporting.AbstractMavenReport#getProject() + */ + protected MavenProject getProject() + { + return project; + } + + /** + * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() + */ + protected SiteRenderer getSiteRenderer() + { + return siteRenderer; + } + + /** + * Return the download directory + * + * @return the download directory + */ + protected File getDownloadDirectory() + { + File dir = new File( getOutputDirectory(), downloadDirectory ); + dir.mkdirs(); + + return dir; + } + + /** + * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) + */ + public void executeReport( Locale locale ) + throws MavenReportException + { + loadDistributionFileNames(); + + if ( StringUtils.isEmpty( downloadUrl ) ) + { + try + { + copyDistribution(); + } + catch ( IOException e ) + { + throw new MavenReportException( "An IOException has occured: " + e.getMessage() ); + } + } + + try + { + DownloadRenderer r = new DownloadRenderer( getSink(), getProject(), locale, ( StringUtils + .isEmpty( downloadUrl ) ? downloadDirectory : downloadUrl ), distributionFileNames ); + + r.render(); + } + catch ( Exception e ) + { + throw new MavenReportException( "An error has occured: " + e.getMessage() ); + } + } + + /** + * @see org.apache.maven.reporting.MavenReport#getOutputName() + */ + public String getOutputName() + { + return "download"; + } + + /** + * Read the assembly plugin configuration and load the distribution file names. + * + * @throws MavenReportException + */ + private void loadDistributionFileNames() + throws MavenReportException + { + List buildPlugins = project.getBuild().getPlugins(); + + for ( Iterator it = buildPlugins.iterator(); it.hasNext(); ) + { + Plugin expectedPlugin = (Plugin) it.next(); + + if ( "maven-assembly-plugin".equals( expectedPlugin.getArtifactId() ) ) + { + Xpp3Dom o = (Xpp3Dom) expectedPlugin.getConfiguration(); + + if ( o == null ) + { + throw new IllegalArgumentException( "The configuration of the maven-assembly-plugin is required." ); + } + + AssemblyMojo assemblyMojo = new AssemblyMojo(); + + if ( o.getChild( "finalName" ) == null ) + { + throw new IllegalArgumentException( + "The 'finalName' parameter is required for the configuration of the maven-assembly-plugin." ); + } + String finalName = o.getChild( "finalName" ).getValue(); + assemblyMojo.finalName = finalName; + + if ( ( o.getChild( "descriptor" ) == null ) && ( o.getChild( "descriptorId" ) == null ) ) + { + throw new IllegalArgumentException( "The 'descriptor' or the 'descriptorId' parameter is " + + "required for the configuration of the maven-assembly-plugin." ); + } + if ( o.getChild( "descriptor" ) != null ) + { + File descriptor = new File( o.getChild( "descriptor" ).getValue() ); + if ( !descriptor.exists() ) + { + throw new IllegalArgumentException( "The descriptor doesn't exist." ); + } + assemblyMojo.descriptor = descriptor; + } + if ( o.getChild( "descriptorId" ) != null ) + { + String descriptorId = o.getChild( "descriptorId" ).getValue(); + assemblyMojo.descriptorId = descriptorId; + } + + Assembly assembly = null; + try + { + assembly = assemblyMojo.readAssembly(); + } + catch ( MojoFailureException e ) + { + throw new MavenReportException( "A MojoFailureException has occured: " + e.getMessage() ); + } + catch ( MojoExecutionException e ) + { + throw new MavenReportException( "A MojoExecutionException has occured: " + e.getMessage() ); + } + + for ( Iterator it2 = assembly.getFormats().iterator(); it2.hasNext(); ) + { + String format = (String) it2.next(); + if ( distributionFileNames == null ) + { + distributionFileNames = new ArrayList(); + } + + if ( StringUtils.isEmpty( format ) ) + { + throw new MavenReportException( "A none-empty format is required in the assembly descriptor." ); + } + + distributionFileNames.add( assemblyMojo.getDistributionName( assembly ) + "." + format ); + } + } + } + } + + /** + * Copy distribution artifacts generated by the goal assembly:assembly. + * + * @throws IOException if a distribution artifact is not found + */ + private void copyDistribution() + throws IOException + { + if ( ( distributionFileNames == null ) || ( distributionFileNames.isEmpty() ) ) + { + return; + } + + StringBuffer sb = null; + + getLog().info( + "The property distributionManagement.downloadUrl is not set in the pom.xml. " + + "Copying distribution files in a relative directory ('" + downloadDirectory + "')." ); + + for ( Iterator it2 = distributionFileNames.iterator(); it2.hasNext(); ) + { + String distName = (String) it2.next(); + + File dist = new File( project.getBuild().getDirectory(), distName ); + if ( !dist.exists() ) + { + // Not an Exception (@see AssemblyMojo#includeSite) + if ( sb == null ) + { + sb = new StringBuffer(); + } + sb.append( dist ).append( ", " ); + continue; + } + + FileUtils.copyFileToDirectory( dist, getDownloadDirectory() ); + } + + if ( sb != null ) + { + getLog().warn( + "The " + ( distributionFileNames.size() > 1 ? "files" : "file" ) + " " + + sb.substring( 0, sb.length() - 2 ) + + " did not exist. - Please run assembly:assembly before." ); + distributionFileNames = null; + } + } + + static class DownloadRenderer + extends AbstractMavenReportRenderer + { + private MavenProject project; + + private Locale locale; + + private String downloadUrl; + + private List distributionFileNames = null; + + /** + * + * @param sink + * @param project + * @param locale + * @param downloadUrl + * @param distributionFileNames + */ + public DownloadRenderer( Sink sink, MavenProject project, Locale locale, String downloadUrl, + List distributionFileNames ) + { + super( sink ); + + this.project = project; + + this.locale = locale; + + this.downloadUrl = downloadUrl; + + this.distributionFileNames = distributionFileNames; + } + + /** + * @see org.apache.maven.reporting.MavenReportRenderer#getTitle() + */ + public String getTitle() + { + return getBundle( locale ).getString( "report.download.title" ) + + " " + + ( StringUtils.isEmpty( project.getName() ) ? project.getGroupId() + ":" + project.getArtifactId() + : project.getName() ) + " " + + ( StringUtils.isEmpty( project.getVersion() ) ? "" : project.getVersion() ); + } + + /** + * @see org.apache.maven.reporting.AbstractMavenReportRenderer#renderBody() + */ + public void renderBody() + { + startSection( getTitle() ); + + if ( ( distributionFileNames == null ) || ( distributionFileNames.isEmpty() ) ) + { + paragraph( getBundle( locale ).getString( "report.download.notavailable" ) ); + + endSection(); + + return; + } + + sink.paragraph(); + linkPatternedText( getBundle( locale ).getString( "report.download.intro" ) ); + sink.paragraph_(); + + sink.list(); + for ( Iterator it = distributionFileNames.iterator(); it.hasNext(); ) + { + String distName = (String) it.next(); + + sink.listItem(); + sink.monospaced(); + + link( downloadUrl + "/" + distName, distName.substring( distName.lastIndexOf( '.' ) ) ); + + sink.monospaced_(); + sink.listItem_(); + } + sink.list_(); + + endSection(); + } + } + + private static ResourceBundle getBundle( Locale locale ) + { + return ResourceBundle.getBundle( "assembly-plugin", locale, DownloadReport.class.getClassLoader() ); + } +} \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_en.properties b/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_en.properties new file mode 100644 index 0000000000..7df53ad938 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_en.properties @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------- +# Copyright 2001-2005 The Apache Software Foundation. +# +# Licensed 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. +# ------------------------------------------------------------------- + +report.download.name=Download +report.download.description=Download page +report.download.title=Download +report.download.notavailable=No download are available for the moment. +report.download.intro=The software is distributed in several formats for your convenience. Refer to the {Project License, ./license.html} before. diff --git a/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_fr.properties b/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_fr.properties new file mode 100644 index 0000000000..d30533bdeb --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/main/resources/assembly-plugin_fr.properties @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------- +# Copyright 2001-2005 The Apache Software Foundation. +# +# Licensed 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. +# ------------------------------------------------------------------- + +report.download.name=Téléchargement +report.download.description=Page de téléchargements +report.download.title=Téléchargement +report.download.notavailable=Aucun téléchargement n'est actuellement disponible. +report.download.intro=Le logiciel est distribué sous plusieurs formats pour votre convenance. Référez-vous à la {License du projet, /license.html} avant. \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt b/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt index 6508ec5c2d..a68b228a12 100644 --- a/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt +++ b/maven-plugins/maven-assembly-plugin/src/site/apt/howto.apt @@ -1,31 +1,31 @@ ------ - Maven 2 Assembly Plugin + Maven 2 Assembly Plugin ------ Johnny R. Ruiz III ------ - September 20, 2005 + October 16, 2005 How to Use - These is a brief example on how to use the assembly:assembly goal and assembly:unpack goal. - - To use the assembly:assembly goal, you must define the descriptor file that you are going to use or - define the descriptorId from the predefined {{{descriptor.html}descriptor ids}}. + These is a brief example on how to use the assembly:assembly goal and assembly:unpack goal. + + To use the assembly:assembly goal, you must define the descriptor file that you are going to use or + define the descriptorId from the predefined {{{descriptor.html}descriptor ids}}. -* How To use assembly:assembly using a customized descriptor file. +* How To use assembly:assembly using a customized descriptor file. ----- m2 assembly:assembly -Dmaven.assembly.descriptor=path/to/descriptor.xml ----- - + * How to use assembly:assembly using predefined descriptor ids. ---- - m2 assembly:assembly -Dmaven.assembly.descriptorId=bin + m2 assembly:assembly -Dmaven.assembly.descriptorId=bin or m2 assembly:assembly -Dmaven.assembly.descriptorId=jar-with-dependencies @@ -69,4 +69,28 @@ How to Use ----- For full documentation, click {{{index.html}here}}. - + +* How to generate Download Report + + In your project pom.xml, add the assembly plugin in section. + +------------------- + + ... + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + ... + +------------------- + + Execute the site plugin to generate the report distribution. + +------------------- + m2 site:site +------------------- \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/LICENSE.txt b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/pom.xml b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/pom.xml new file mode 100644 index 0000000000..422c263278 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/pom.xml @@ -0,0 +1,88 @@ + + + + + + 4.0.0 + org.apache.maven.plugin.assembly.test1 + assembly-plugin-test1 + jar + 1.0-SNAPSHOT + 2005 + Maven Assembly Plugin Test1 + Test download page. + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + + + + maven-assembly-plugin + + src/assemble/bin.xml + maven-${version} + + + + + + + + vsiveton + Vincent Siveton + vsiveton@apache.org + Apache Software Foundation + + Java Developer + + -5 + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-assembly-plugin + + + + + diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/assemble/bin.xml b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/assemble/bin.xml new file mode 100644 index 0000000000..cab6811db3 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/assemble/bin.xml @@ -0,0 +1,66 @@ + + + + + + bin + + tar.gz + tar.bz2 + zip + + + + + LICENSE* + + + + src/bin + bin + + *.bat + + dos + + + src/bin + bin + + *.sh + + unix + 0755 + + + src/conf + conf + + + target + lib + + *.jar + + + *-sources.jar + + + + diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.bat b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.bat new file mode 100644 index 0000000000..fe69cd025b --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.bat @@ -0,0 +1,18 @@ +@REM ---------------------------------------------------------------------------- +@REM Copyright 2001-2004 The Apache Software Foundation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM ---------------------------------------------------------------------------- +@REM + +echo test \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.sh b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.sh new file mode 100644 index 0000000000..24f2afddc5 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/bin/test.sh @@ -0,0 +1,18 @@ +# ---------------------------------------------------------------------------- +# Copyright 2001-2004 The Apache Software Foundation. +# +# Licensed 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. +# ---------------------------------------------------------------------------- +# + +echo test \ No newline at end of file diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/main/java/org/apache/maven/plugin/assembly/test1/App.java b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/main/java/org/apache/maven/plugin/assembly/test1/App.java new file mode 100644 index 0000000000..a5e73cb9d6 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/main/java/org/apache/maven/plugin/assembly/test1/App.java @@ -0,0 +1,13 @@ +package org.apache.maven.plugin.assembly.test1; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/apt/test.apt b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/apt/test.apt new file mode 100644 index 0000000000..16dfa494a0 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/apt/test.apt @@ -0,0 +1,12 @@ + ------ + Configuring Assembly Plugin + ------ + Vincent Siveton + ------ + 16 October 2005 + ------ + + +Assembly Plugin Test + + Todo diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/site.xml b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/site.xml new file mode 100644 index 0000000000..eb973efa89 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/site/site.xml @@ -0,0 +1,40 @@ + + + + + + + Maven Site + http://maven.apache.org/images/apache-maven-project.png + http://maven.apache.org/ + + + http://maven.apache.org/images/maven-small.gif + + + + + + + + + + ${reports} + + diff --git a/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/test/java/org/apache/maven/plugin/assembly/test1/AppTest.java b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/test/java/org/apache/maven/plugin/assembly/test1/AppTest.java new file mode 100644 index 0000000000..048e4acaa8 --- /dev/null +++ b/maven-plugins/maven-assembly-plugin/src/test/projects/assembly-plugin-test1/src/test/java/org/apache/maven/plugin/assembly/test1/AppTest.java @@ -0,0 +1,38 @@ +package org.apache.maven.plugin.assembly.test1; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}