r1719 - in trunk/main: . depot/library/src/main/net/dpml/library/impl depot/library/src/main/net/dpml/library/info depot/tools/src/main/net/dpml/tools/tasks

mcconnell at BerliOS mcconnell at mail.berlios.de
Mon Aug 7 00:25:32 EDT 2006


Author: mcconnell
Date: 2006-08-07 06:25:28 +0200 (Mon, 07 Aug 2006)
New Revision: 1719

Modified:
   trunk/main/build.xml
   trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultDictionary.java
   trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
   trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InstallTask.java
Log:
checkstyle cleanup and correction to checkstyle target declaration

Modified: trunk/main/build.xml
===================================================================
--- trunk/main/build.xml	2006-08-07 03:52:23 UTC (rev 1718)
+++ trunk/main/build.xml	2006-08-07 04:25:28 UTC (rev 1719)
@@ -244,6 +244,7 @@
       <fileset dir=".">
         <include name="**/target/build/main/**/*.java"/>
         <include name="**/target/build/test/**/*.java"/>
+        <exclude name="target/**/*.*"/>
       </fileset>
     </checkstyle>
     <xslt style="${dpml.prefs}/dpml/tools/xsls/checkstyle-frames.xsl"

Modified: trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultDictionary.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultDictionary.java	2006-08-07 03:52:23 UTC (rev 1718)
+++ trunk/main/depot/library/src/main/net/dpml/library/impl/DefaultDictionary.java	2006-08-07 04:25:28 UTC (rev 1719)
@@ -120,8 +120,6 @@
     * @param key the property key
     * @param value the default value
     * @return the property value as an integer
-    * @exception NumberFormatException if underlying property value 
-    *    cannot be resolved to an integer
     */
     public int getIntegerProperty( String key, int value )
     {
@@ -142,8 +140,6 @@
     * @param key the property key
     * @param value the default value
     * @return the property value as an boolean
-    * @exception NumberFormatException if underlying property value 
-    *    cannot be resolved to an integer
     */
     public boolean getBooleanProperty( String key, boolean value )
     {

Modified: trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java
===================================================================
--- trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java	2006-08-07 03:52:23 UTC (rev 1718)
+++ trunk/main/depot/library/src/main/net/dpml/library/info/ModuleDirective.java	2006-08-07 04:25:28 UTC (rev 1719)
@@ -93,6 +93,7 @@
     * of an anonymous resource.
     *
     * @param name the module name
+    * @param version the module version
     * @param resource resource contained within the module
     */
     public ModuleDirective( String name, String version, ResourceDirective resource )

Modified: trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InstallTask.java
===================================================================
--- trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InstallTask.java	2006-08-07 03:52:23 UTC (rev 1718)
+++ trunk/main/depot/tools/src/main/net/dpml/tools/tasks/InstallTask.java	2006-08-07 04:25:28 UTC (rev 1719)
@@ -67,6 +67,7 @@
         boolean snapshot = "SNAPSHOT".equals( resourceVersion );
         boolean bootstrap = "BOOTSTRAP".equals( resourceVersion );
         boolean validation = resource.getBooleanProperty( "project.validation.enabled", false );
+        boolean validate = !snapshot && !bootstrap && validation;
         Type[] types = resource.getTypes();
         if( types.length == 0 )
         {
@@ -77,117 +78,7 @@
         for( int i=0; i < types.length; i++ )
         {
             Type type = types[i];
-            
-            //
-            // Check that the project has actually built the resource
-            // type that it declares
-            //
-
-            String id = type.getID();
-            String filename = getContext().getLayoutFilename( id );
-            File group = new File( deliverables, id + "s" );
-            File target = new File( group, filename );
-            if( !target.exists() && !id.equalsIgnoreCase( "null" ) )
-            {
-                final String error = 
-                  "Project [" 
-                  + resource 
-                  + "] declares that it produces the resource type ["
-                  + id
-                  + "] however no artifacts of that type are present in the target deliverables directory.";
-                throw new BuildException( error, getLocation() );
-            }
-            
-            if( !snapshot && !bootstrap && validation )
-            {
-                try
-                {
-                    Artifact artifact = resource.getArtifact( id );
-                    URL url = artifact.toURL();
-                    File file = (File) url.getContent( new Class[]{File.class} );
-                    if( file.exists() )
-                    {
-                        log( "validating " + target.getName() );
-                        compare( file, target, id );
-                    }
-                }
-                catch( ArtifactNotFoundException anfe )
-                {
-                    // continue as there is nothing to compare with
-                }
-                catch( IOException ioe )
-                {
-                    final String error =
-                      "IO error while attempting to cross-check resource type: " + id
-                      + "\n" + ioe.toString();
-                    throw new BuildException( error, ioe, getLocation() );
-                }
-            }
-            
-            //
-            // If the type declares an alias then construct a link 
-            // and add the link to the deliverables directory as part of 
-            // install process.
-            //
-
-            Version version = type.getVersion();
-            if( null != version )
-            {
-                try
-                {
-                    Artifact artifact = resource.getArtifact( id );
-                    String uri = artifact.toURI().toASCIIString();
-                    
-                    String link = null;
-                    if( Version.NULL_VERSION.equals( version ) )
-                    {
-                        link = resource.getName() + "." + id + ".link";
-                    }
-                    else
-                    {
-                        link = resource.getName()
-                        + "-"
-                        + version.getMajor()
-                        + "." 
-                        + version.getMinor()
-                        + "."
-                        + id + ".link";
-                    }
-                    File out = new File( group, link );
-                    boolean flag = true;
-                    if( out.exists() )
-                    {
-                        ArtifactLinkManager manager = new ArtifactLinkManager();
-                        URI enclosed = manager.getTargetURI( new URI( out.toURL().toString() ) );
-                        if( artifact.toURI().equals( enclosed ) )
-                        {
-                            flag = false;
-                        }
-                    }
-                    
-                    if( flag )
-                    {
-                        log( link.toString() );
-                        log( uri.toString() );
-                        out.createNewFile();
-                        final OutputStream output = new FileOutputStream( out );
-                        final Writer writer = new OutputStreamWriter( output );
-                        writer.write( uri );
-                        writer.close();
-                        output.close();
-                    }
-                }
-                catch( Exception e )
-                {
-                    final String error = 
-                      "Internal error while attempting to create a link for the resource type ["
-                      + id 
-                      + "] in project ["
-                      + resource
-                      + "].";
-                    throw new BuildException( error, e, getLocation() );
-                }
-            }
+            checkType( resource, type, validate );
         }
 
         if( deliverables.exists() )
@@ -223,6 +114,129 @@
         }
     }
     
+    private void checkType( Resource resource, Type type, boolean validate )
+    {
+        //
+        // Check that the project has actually built the resource
+        // type that it declares
+        //
+
+        String id = type.getID();
+        String filename = getContext().getLayoutFilename( id );
+        final File deliverables = getContext().getTargetDeliverablesDirectory();
+        File group = new File( deliverables, id + "s" );
+        File target = new File( group, filename );
+        if( !target.exists() && !id.equalsIgnoreCase( "null" ) )
+        {
+            final String error = 
+              "Project [" 
+              + resource 
+              + "] declares that it produces the resource type ["
+              + id
+              + "] however no artifacts of that type are present in the target deliverables directory.";
+            throw new BuildException( error, getLocation() );
+        }
+
+        //
+        // If the type declares an alias then construct a link 
+        // and add the link to the deliverables directory as part of 
+        // install process.
+        //
+
+        Version version = type.getVersion();
+        if( null != version )
+        {
+            try
+            {
+                Artifact artifact = resource.getArtifact( id );
+                String uri = artifact.toURI().toASCIIString();
+                String link = null;
+                if( Version.NULL_VERSION.equals( version ) )
+                {
+                    link = resource.getName() + "." + id + ".link";
+                }
+                else
+                {
+                    link = resource.getName()
+                    + "-"
+                    + version.getMajor()
+                    + "." 
+                    + version.getMinor()
+                    + "."
+                    + id + ".link";
+                }
+                File out = new File( group, link );
+                boolean flag = true;
+                if( out.exists() )
+                {
+                    ArtifactLinkManager manager = new ArtifactLinkManager();
+                    URI enclosed = manager.getTargetURI( new URI( out.toURL().toString() ) );
+                    if( artifact.toURI().equals( enclosed ) )
+                    {
+                        flag = false;
+                    }
+                }
+                
+                if( flag )
+                {
+                    final String message = 
+                      link.toString()
+                      + "\n  target: " 
+                      +  uri.toString();
+                    log( message, Project.MSG_VERBOSE );
+                    out.createNewFile();
+                    final OutputStream output = new FileOutputStream( out );
+                    final Writer writer = new OutputStreamWriter( output );
+                    writer.write( uri );
+                    writer.close();
+                    output.close();
+                }
+            }
+            catch( Exception e )
+            {
+                final String error = 
+                  "Internal error while attempting to create a link for the resource type ["
+                  + id 
+                  + "] in project ["
+                  + resource
+                  + "].";
+                throw new BuildException( error, e, getLocation() );
+            }
+        }
+
+        if( validate )
+        {
+            validateType( resource, type, target );
+        }
+    }
+    
+    private void validateType( Resource resource, Type type, File target )
+    {
+        String id = type.getID();
+        try
+        {
+            Artifact artifact = resource.getArtifact( id );
+            URL url = artifact.toURL();
+            File file = (File) url.getContent( new Class[]{File.class} );
+            if( file.exists() )
+            {
+                log( "validating " + target.getName() );
+                compare( file, target, id );
+            }
+        }
+        catch( ArtifactNotFoundException anfe )
+        {
+            // continue as there is nothing to compare with
+        }
+        catch( IOException ioe )
+        {
+            final String error =
+              "IO error while attempting to cross-check resource type: " + id
+              + "\n" + ioe.toString();
+            throw new BuildException( error, ioe, getLocation() );
+        }
+    }
+    
     private void compare( File old, File target, String id )
     {
         String oldValue = getChecksum( old );




More information about the notify-dpml mailing list