Author: fgiust Date: Sat Jan 6 10:40:34 2007 New Revision: 493531 URL: http://svn.apache.org/viewvc?view=rev&rev=493531 Log: MREPOSITORY-6 Don't check for License.txt file, but verify the licenses element in pom.xml
Modified: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/stubs/NoLicenseFileMavenProjectStub.java Modified: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java?view=diff&rev=493531&r1=493530&r2=493531 ============================================================================== --- maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java (original) +++ maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java Sat Jan 6 10:40:34 2007 @@ -17,8 +17,10 @@ */ import java.io.File; +import java.util.List; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.model.License; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -37,8 +39,6 @@ { public static final String POM = "pom.xml"; - public static final String LICENSE = "LICENSE.txt"; - /** * @parameter expression="${basedir}" */ @@ -83,6 +83,7 @@ // scm url // description // dependencies + // licenses // ---------------------------------------------------------------------- validate( project.getName(), "project.name" ); @@ -98,19 +99,17 @@ validate( project.getDescription(), "project.description" ); + if ( project.getLicenses().isEmpty() ) + { + throw new MojoExecutionException( "At least one license must be defined." ); + } + // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- File pom = new File( basedir, POM ); - File license = new File( basedir, LICENSE ); - - if ( !license.exists() ) - { - throw new MojoExecutionException( LICENSE + " file is missing. Cannot create upload bundle." ); - } - String finalName = project.getBuild().getFinalName(); String outputDirectory = project.getBuild().getDirectory(); @@ -128,8 +127,6 @@ try { jarArchiver.addFile( pom, POM ); - - jarArchiver.addFile( license, LICENSE ); jarArchiver.addFile( artifact, artifact.getName() ); Modified: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java?view=diff&rev=493531&r1=493530&r2=493531 ============================================================================== --- maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java (original) +++ maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java Sat Jan 6 10:40:34 2007 @@ -90,9 +90,6 @@ assertEquals( entry.getName(), "default-configuration.jar" ); entry = (ZipEntry) entries.nextElement(); - assertEquals( entry.getName(), "LICENSE.txt" ); - - entry = (ZipEntry) entries.nextElement(); assertEquals( entry.getName(), "pom.xml" ); entry = (ZipEntry) entries.nextElement(); @@ -150,9 +147,6 @@ assertEquals( entry.getName(), "no-javadocjar.jar" ); entry = (ZipEntry) entries.nextElement(); - assertEquals( entry.getName(), "LICENSE.txt" ); - - entry = (ZipEntry) entries.nextElement(); assertEquals( entry.getName(), "pom.xml" ); entry = (ZipEntry) entries.nextElement(); @@ -210,9 +204,6 @@ assertEquals( entry.getName(), "no-sourcesjar.jar" ); entry = (ZipEntry) entries.nextElement(); - assertEquals( entry.getName(), "LICENSE.txt" ); - - entry = (ZipEntry) entries.nextElement(); assertEquals( entry.getName(), "pom.xml" ); entry = (ZipEntry) entries.nextElement(); @@ -269,9 +260,6 @@ assertEquals( entry.getName(), "no-javadoc-sources.jar" ); entry = (ZipEntry) entries.nextElement(); - assertEquals( entry.getName(), "LICENSE.txt" ); - - entry = (ZipEntry) entries.nextElement(); assertEquals( entry.getName(), "pom.xml" ); entry = (ZipEntry) entries.nextElement(); @@ -354,7 +342,7 @@ * * @throws Exception */ - public void testNoLicenseFile() + public void testNoLicense() throws Exception { Modified: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/stubs/NoLicenseFileMavenProjectStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/stubs/NoLicenseFileMavenProjectStub.java?view=diff&rev=493531&r1=493530&r2=493531 ============================================================================== --- maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/stubs/NoLicenseFileMavenProjectStub.java (original) +++ maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/stubs/NoLicenseFileMavenProjectStub.java Sat Jan 6 10:40:34 2007 @@ -16,6 +16,9 @@ * limitations under the License. */ +import java.util.ArrayList; +import java.util.List; + import org.apache.maven.model.Build; import org.apache.maven.model.Scm; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -70,4 +73,11 @@ { this.build = build; } + + public List getLicenses() + { + return new ArrayList(); + } + + }