svn commit: r169839 - in /maven/components/trunk/maven-plugins/maven-source-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugin/ src/main/java/org/apac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r169839 - in /maven/components/trunk/maven-plugins/maven-source-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugin/ src/main/java/org/apac

brettporter
Administrator
Author: brett
Date: Thu May 12 08:59:36 2005
New Revision: 169839

URL: http://svn.apache.org/viewcvs?rev=169839&view=rev
Log:
import source plugin

Added:
    maven/components/trunk/maven-plugins/maven-source-plugin/   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/resources/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/resources/sub-directory/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/resources/sub-directory/file.resource
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java   (with props)
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/resources/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/resources/sub-directory2/
    maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/resources/sub-directory2/file2.resource

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May 12 08:59:36 2005
@@ -0,0 +1,2 @@
+*.iml
+target

Added: maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml Thu May 12 08:59:36 2005
@@ -0,0 +1,25 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>maven-plugin-parent</artifactId>
+    <groupId>org.apache.maven.plugins</groupId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>maven-source-plugin</artifactId>
+  <version>2.0-alpha-1-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+  <name>Maven Source Plug-In</name>
+  <dependencies>
+    <dependency>
+      <groupId>plexus</groupId>
+      <artifactId>plexus-archiver</artifactId>
+      <version>1.0-alpha-1</version>
+    </dependency>
+    <dependency>
+      <groupId>plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java Thu May 12 08:59:36 2005
@@ -0,0 +1,81 @@
+package org.apache.maven.plugin.source;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This plugin bundles all the generated sources into a jar archive.
+ *
+ * @author <a href="mailto:[hidden email]">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ * @goal jar
+ */
+public class JarSourceMojo
+    extends AbstractMojo
+{
+    /**
+     * @parameter expression="${project.build.finalName}"
+     * @required
+     */
+    private String finalName;
+
+    /**
+     * @parameter expression="${project.compileSourceRoots}"
+     * @required
+     */
+    private List compileSourceRoots;
+
+    /**
+     * @parameter expression="${project.build.output}"
+     * @required
+     */
+    private File outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        // TODO: use a component lookup?
+        JarArchiver archiver = new JarArchiver();
+
+        SourceBundler sourceBundler = new SourceBundler();
+
+        File outputFile = new File( outputDirectory, finalName + "-sources.jar" );
+
+        File[] sourceDirectories = new File[compileSourceRoots.size()];
+        int count = 0;
+        for ( Iterator i = compileSourceRoots.iterator(); i.hasNext(); count++ )
+        {
+            sourceDirectories[count] = new File( (String) i.next() );
+        }
+
+        try
+        {
+            sourceBundler.makeSourceBundle( outputFile, sourceDirectories, archiver );
+        }
+        catch ( Exception e )
+        {
+            throw new MojoExecutionException( "Error building source JAR", e );
+        }
+    }
+}

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/JarSourceMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java Thu May 12 08:59:36 2005
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin.source;
+
+import java.io.File;
+
+import org.codehaus.plexus.archiver.Archiver;
+
+/**
+ * @author <a href="mailto:[hidden email]">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class SourceBundler
+{
+    private final static String[] DEFAULT_INCLUDES = new String[]{
+        "**/*",
+    };
+
+    private final static String[] DEFAULT_EXCLUDES = new String[]{
+        "**/CVS/**",
+        "**/.svn/**",
+    };
+
+    public void makeSourceBundle( File outputFile, File[] sourceDirectories, Archiver archiver )
+        throws Exception
+    {
+        String[] includes = DEFAULT_INCLUDES;
+
+        String[] excludes = DEFAULT_EXCLUDES;
+
+        for ( int i = 0; i < sourceDirectories.length; i++ )
+        {
+            archiver.addDirectory( sourceDirectories[ i ], includes, excludes );
+        }
+
+        archiver.setDestFile( outputFile );
+
+        archiver.createArchive();
+    }
+}

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceBundler.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml Thu May 12 08:59:36 2005
@@ -0,0 +1,4 @@
+<component-set>
+  <components>
+  </components>
+</component-set>

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java Thu May 12 08:59:36 2005
@@ -0,0 +1,40 @@
+package org.apache.maven.plugin.source;
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.archiver.Archiver;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:[hidden email]">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class SourceBundlerTest
+    extends PlexusTestCase
+{
+    public void testNormalProject()
+        throws Exception
+    {
+        SourceBundler sourceBundler = new SourceBundler();
+
+        Archiver archiver = (Archiver) lookup( Archiver.ROLE, "jar" );
+
+        File outputFile = getTestFile( "target/source-bundler-test/normal.jar" );
+
+        File sourceDirectories[] = {
+            getTestFile( "src/test/projects/normal/src/main/java" ),
+            getTestFile( "src/test/projects/normal/src/main/resources" ),
+            getTestFile( "src/test/projects/normal/src/test/java" ),
+            getTestFile( "src/test/projects/normal/src/test/resources" ),
+        };
+
+        if ( outputFile.exists() )
+        {
+            assertTrue( "Could not delete output file: " + outputFile.getAbsolutePath(), outputFile.delete() );
+        }
+
+        sourceBundler.makeSourceBundle( outputFile, sourceDirectories, archiver );
+
+        assertTrue( "Missing output file: " + outputFile.getAbsolutePath(), outputFile.isFile() );
+    }
+}

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/java/org/apache/maven/plugin/source/SourceBundlerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml Thu May 12 08:59:36 2005
@@ -0,0 +1,7 @@
+<model>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>mojo-test</groupId>
+  <artifactId>maven-sources-plugin-test-zip</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0</version>
+</model>
\ No newline at end of file

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java Thu May 12 08:59:36 2005
@@ -0,0 +1,3 @@
+public class App
+{
+}

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/java/App.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/resources/sub-directory/file.resource
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/main/resources/sub-directory/file.resource?rev=169839&view=auto
==============================================================================
    (empty)

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java?rev=169839&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java (added)
+++ maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java Thu May 12 08:59:36 2005
@@ -0,0 +1,3 @@
+public class Test
+{
+}

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/java/Test.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/resources/sub-directory2/file2.resource
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-source-plugin/src/test/projects/normal/src/test/resources/sub-directory2/file2.resource?rev=169839&view=auto
==============================================================================
    (empty)



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]