directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r823525 - in /directory/studio-plugin/trunk/src: main/java/org/apache/directory/studio/maven/plugins/ site/apt/examples/
Date Fri, 09 Oct 2009 12:20:30 GMT
Author: felixk
Date: Fri Oct  9 12:20:29 2009
New Revision: 823525

URL: http://svn.apache.org/viewvc?rev=823525&view=rev
Log:
Fix for DIRSTUDIO-540 (Patch to copy source bundles along with bundles during ):

Applied patch with some small modifications, thanks to Hasan for the Patch.
Update documentation.

Modified:
    directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
    directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
    directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
    directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
    directory/studio-plugin/trunk/src/site/apt/examples/copy-eclipse-artifact.apt

Modified: directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
URL: http://svn.apache.org/viewvc/directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java?rev=823525&r1=823524&r2=823525&view=diff
==============================================================================
--- directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
(original)
+++ directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
Fri Oct  9 12:20:29 2009
@@ -374,14 +374,16 @@
      * 
      * @throws MojoExecutionException
      */
-    protected void completeArtifactItems( List<ArtifactItem> artifactItems ) throws
MojoExecutionException
+    protected void completeArtifactItems( List<ArtifactItem> artifactItems, boolean
relaxed )
+        throws MojoExecutionException
     {
-        try
+        List<String> warnings = new ArrayList<String>();
+        // Get and complete artifacts
+        for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();
)
         {
-            // Get and complete artifacts
-            for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();
)
+            ArtifactItem item = artifactItem.next();
+            try
             {
-                ArtifactItem item = artifactItem.next();
                 // make sure we have a version.
                 if ( StringUtils.isEmpty( item.getVersion() ) )
                 {
@@ -389,10 +391,30 @@
                 }
                 item.setArtifact( this.getArtifact( item ) );
             }
+            catch ( Exception e )
+            {
+                if ( relaxed )
+                {
+                    warnings.add( "Following source artifact is not available in the local
repository '"
+                        + item.getGroupId() + ":" + item.getArtifactId() + ":" + item.getType()
+ ":"
+                        + item.getClassifier() + ":" + item.getVersion() + "'" );
+                }
+                else
+                {
+                    throw new MojoExecutionException(
+                        "Following source artifact is not available in the local repository
'" + item.getGroupId()
+                            + ":" + item.getArtifactId() + ":" + item.getType() + ":" + item.getClassifier()
+ ":"
+                            + item.getVersion() + "'", e );
+                }
+            }
         }
-        catch ( Exception e )
+
+        if ( relaxed && !warnings.isEmpty() )
         {
-            throw new MojoExecutionException( "", e );
+            for ( String warn : warnings )
+            {
+                getLog().warn( warn );
+            }
         }
     }
 

Modified: directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
URL: http://svn.apache.org/viewvc/directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java?rev=823525&r1=823524&r2=823525&view=diff
==============================================================================
--- directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
(original)
+++ directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
Fri Oct  9 12:20:29 2009
@@ -24,11 +24,13 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+import org.codehaus.plexus.util.StringUtils;
 
 
 /**
@@ -48,6 +50,26 @@
 public class StudioCopyEclipseDependencyMojo extends AbstractStudioMojo
 {
 
+    private static final String SOURCE = "source";
+
+    private static final String SOURCES = "sources";
+
+    /**
+     * Whether to include the sources for the artifacts
+     * 
+     * @parameter default-value="false"
+     * @since 1.0.3
+     */
+    protected boolean includeSources;
+
+    /**
+     * Whether not to bail out if a source artifact for the dependency is not found
+     * 
+     * @parameter default-value="true"
+     * @since 1.0.3
+     */
+    protected boolean relaxed;
+
     /**
      * Collection of ArtifactItems to work on. (ArtifactItem contains groupId,
      * artifactId, version, type, classifier, location, destFile, markerFile and
@@ -81,8 +103,16 @@
 
     public void execute() throws MojoExecutionException
     {
-        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
-        completeArtifactItems( artifactItems );
+        Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
+        executeForMainArtifacts( maven2OsgiConverter );
+        if ( includeSources )
+            executeForSourceArtifacts( maven2OsgiConverter );
+    }
+
+
+    private void executeForMainArtifacts( Maven2OsgiConverter maven2OsgiConverter ) throws
MojoExecutionException
+    {
+        completeArtifactItems( artifactItems, false );
 
         if ( !destinationDirectory.exists() && !destinationDirectory.mkdirs() )
         {
@@ -108,6 +138,58 @@
     }
 
 
+    private void executeForSourceArtifacts( Maven2OsgiConverter maven2OsgiConverter ) throws
MojoExecutionException
+    {
+        List<ArtifactItem> sourceArtifactItems = getCopyArtifactList();
+        completeArtifactItems( sourceArtifactItems, relaxed );
+
+        for ( Iterator<ArtifactItem> sourceItem = sourceArtifactItems.iterator(); sourceItem.hasNext();
)
+        {
+            ArtifactItem item = sourceItem.next();
+
+            if ( item.getArtifact() != null
+                && maven2OsgiConverter.getBundleSymbolicName( item.getArtifact()
).endsWith( SOURCE ) )
+            {
+                final File destFile = new File( destinationDirectory.getAbsoluteFile() +
File.separator
+                    + maven2OsgiConverter.getBundleFileName( item.getArtifact() ) );
+                getLog().info(
+                    "Copying source artifact " + item.getArtifactId() + " to\n          
    "
+                        + destFile.getAbsolutePath() );
+                try
+                {
+                    FileUtils.copyFile( item.getArtifact().getFile(), destFile );
+                }
+                catch ( IOException ioe )
+                {
+                    throw new MojoExecutionException( "Can't copy file.", ioe );
+                }
+            }
+        }
+    }
+
+
+    private List<ArtifactItem> getCopyArtifactList()
+    {
+        List<ArtifactItem> sourceArtifactItems = new ArrayList<ArtifactItem>();
+        for ( Iterator<ArtifactItem> i = artifactItems.iterator(); i.hasNext(); )
+        {
+            ArtifactItem artifactItem = ( ArtifactItem ) i.next();
+            if ( StringUtils.isEmpty( artifactItem.getClassifier() ) || !SOURCES.equals(
artifactItem.getClassifier() ) )
+            {
+                ArtifactItem sourceItem = new ArtifactItem();
+                sourceItem.setGroupId( artifactItem.getGroupId() );
+                sourceItem.setArtifactId( artifactItem.getArtifactId() );
+                sourceItem.setType( artifactItem.getType() );
+                sourceItem.setClassifier( SOURCES );
+                sourceItem.setVersion( artifactItem.getVersion() );
+                sourceArtifactItems.add( sourceItem );
+            }
+        }
+
+        return sourceArtifactItems;
+    }
+
+
     /**
      * @param artifactItems
      *            the artifactItems to set

Modified: directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
URL: http://svn.apache.org/viewvc/directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java?rev=823525&r1=823524&r2=823525&view=diff
==============================================================================
--- directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
(original)
+++ directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
Fri Oct  9 12:20:29 2009
@@ -108,7 +108,7 @@
     {
         final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
 
-        completeArtifactItems( artifactItems );
+        completeArtifactItems( artifactItems, false );
 
         // Add file to packed file
         for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();
)

Modified: directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
URL: http://svn.apache.org/viewvc/directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java?rev=823525&r1=823524&r2=823525&view=diff
==============================================================================
--- directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
(original)
+++ directory/studio-plugin/trunk/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
Fri Oct  9 12:20:29 2009
@@ -79,7 +79,7 @@
     public void execute() throws MojoExecutionException
     {
         final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
-        completeArtifactItems( artifactItems );
+        completeArtifactItems( artifactItems, false );
         for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();
)
         {
             ArtifactItem item = artifactItem.next();

Modified: directory/studio-plugin/trunk/src/site/apt/examples/copy-eclipse-artifact.apt
URL: http://svn.apache.org/viewvc/directory/studio-plugin/trunk/src/site/apt/examples/copy-eclipse-artifact.apt?rev=823525&r1=823524&r2=823525&view=diff
==============================================================================
--- directory/studio-plugin/trunk/src/site/apt/examples/copy-eclipse-artifact.apt (original)
+++ directory/studio-plugin/trunk/src/site/apt/examples/copy-eclipse-artifact.apt Fri Oct
 9 12:20:29 2009
@@ -44,6 +44,8 @@
             </goals>
             <configuration>
               <destinationDirectory>${studio-dir}/plugins</destinationDirectory>
+              <includeSources>false</includeSources>
+              <relaxed>true</relaxed>
               <artifactItems>
                 <artifactItem>
                   <groupId>org.apache.directory.studio</groupId>



Mime
View raw message