Skip to Content.
Sympa Menu

notify-dpml - r1464 - in trunk/main: depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info lang/module/etc

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1464 - in trunk/main: depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info lang/module/etc
  • Date: Sun, 28 May 2006 17:17:20 +0200

Author: mcconnell
Date: 2006-05-28 17:17:18 +0200 (Sun, 28 May 2006)
New Revision: 1464

Removed:

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
Modified:
trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JarTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java

trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
trunk/main/lang/module/etc/module.xsd
Log:
Resolved build issue concerning initialization actions during clean target
and added some degree of simplification concerning listener handling (in
practice this is related to the backing out of processor abstraction at the
level of the build system implementation in favour of a process model based
on a formal people/places/things abstraction).

Modified: trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-05-27 06:27:11 UTC (rev 1463)
+++ trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-05-28 15:17:18 UTC (rev 1464)
@@ -28,9 +28,7 @@
<x:init/>
</target>

- <target name="clean" depends="init">
- <delete dir="${project.target.dir}"/>
- </target>
+ <target name="clean" depends="init"/>

<target name="prepare" depends="init"/>


Modified: trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml 2006-05-27
06:27:11 UTC (rev 1463)
+++ trunk/main/depot/tools/builder/etc/prefs/xmls/builder.xml 2006-05-28
15:17:18 UTC (rev 1464)
@@ -6,15 +6,19 @@

<builder default="install">

+ <properties/>
+
<listeners>
- <listener name="standard"
class="net.dpml.tools.impl.StandardBuildListener"/>
+ <listener name="standard"
class="net.dpml.tools.impl.StandardBuildListener" priority="0"/>
</listeners>

+ <!--
<processors>
<processor name="jar" class="net.dpml.tools.process.JarProcess"/>
<processor name="part" class="net.dpml.tools.process.PluginProcess"
depends="jar"/>
<processor name="module" class="net.dpml.tools.process.ModuleProcess"/>
</processors>
-
+ -->
+
</builder>


Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -23,6 +23,7 @@
import java.net.URL;
import java.net.URI;
import java.util.Date;
+import java.util.Arrays;

import net.dpml.lang.Plugin;
import net.dpml.lang.Part;
@@ -125,7 +126,7 @@
"Error while attempting to setup the filter [" + token +
"].";
throw new BuildException( error, e );
}
- }
+ }

project.setNewProperty( "project.nl", "\n" );
project.setNewProperty(

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -93,6 +93,16 @@
Target target = event.getTarget();
String targetName = target.getName();
Processor[] processors = m_context.getProcessors();
+ if( "clean".equals( targetName ) )
+ {
+ event.getProject().log( "executing clenup phase",
Project.MSG_VERBOSE );
+ m_standard.clean( m_context );
+ for( int i=0; i<processors.length; i++ )
+ {
+ Processor processor = processors[i];
+ processor.clean( m_context );
+ }
+ }
if( "init".equals( targetName ) )
{
event.getProject().log( "executing initialization phase",
Project.MSG_VERBOSE );

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuilder.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -198,8 +198,6 @@
}
}

- //return null;
-
// otherwise we build using either an explicit or default
template
// resolved via a uri (typically a template stored in prefs)


Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -75,7 +75,8 @@

m_phase = phase;
m_processors = processors;
- m_listeners = sortListenerDirectives( listeners );
+ //m_listeners = sortListenerDirectives( listeners );
+ m_listeners = listeners;
}

/**
@@ -147,6 +148,7 @@
return hash;
}

+ /*
private static ListenerDirective[] sortListenerDirectives(
ListenerDirective[] directives )
throws UnknownKeyException
{
@@ -207,4 +209,5 @@
}
throw new UnknownKeyException( name );
}
+ */
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -26,6 +26,7 @@
import java.net.URI;
import java.net.URL;
import java.util.Properties;
+import java.util.Arrays;

import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
@@ -184,6 +185,7 @@
throw new IllegalArgumentException( error );
}
}
+ Arrays.sort( listeners );
return new BuilderDirective( listeners, phase, processors,
properties );
}

@@ -208,10 +210,12 @@
final String spec = ElementHelper.getAttribute( element, "uri",
null );
final URI uri = createURI( spec );
final String classname = ElementHelper.getAttribute( element,
"class", null );
+ final String value = ElementHelper.getAttribute( element,
"priority", null );
+ int priority = Integer.parseInt( value );
final String deps = ElementHelper.getAttribute( element,
"depends", null );
final String[] depends = buildDependenciesArray( deps );
final Properties properties = buildProperties( element );
- return new ListenerDirective( name, uri, classname, depends,
properties );
+ return new ListenerDirective( name, priority, uri, classname,
depends, properties );
}
else
{

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -31,9 +31,10 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public final class ListenerDirective extends AbstractDirective
+public final class ListenerDirective extends AbstractDirective implements
Comparable
{
private final String m_name;
+ private final int m_priority;
private final URI m_uri;
private final String m_classname;
private final String[] m_dependencies;
@@ -41,6 +42,7 @@
/**
* Creation of a new listener directive.
* @param name the listener name
+ * @param priority the listener priority
* @param uri the listener codebase
* @param classname optional classname of the plugin instantiation target
* @param dependencies array of listener names that the listener depends
upon
@@ -49,7 +51,7 @@
* @exception IllegalStateException if both classname and urn values are
null
*/
public ListenerDirective(
- String name, URI uri, String classname,
+ String name, int priority, URI uri, String classname,
String[] dependencies, Properties properties )
throws NullPointerException, IllegalStateException
{
@@ -73,6 +75,7 @@
throw new IllegalStateException( error );
}
}
+ m_priority = priority;
m_dependencies = dependencies;
m_name = name;
m_uri = uri;
@@ -89,6 +92,15 @@
}

/**
+ * Return the listener priority.
+ * @return the priority value
+ */
+ public int getPriority()
+ {
+ return m_priority;
+ }
+
+ /**
* Return the listener codebase urn.
* @return the urn
*/
@@ -139,6 +151,33 @@
return m_dependencies;
}

+ /**
+ * Compares this <code>ListenerDirective</code> object to another object.
+ * If the object is an <code>ListenerDirective</code>, this function
behaves
+ * like <code>compareTo(Integer)</code>. Otherwise, it throws a
+ * <code>ClassCastException</code>.
+ *
+ * @param other the <code>Object</code> to be compared.
+ * @return the value <code>0</code> if the argument is a
+ * <code>ListenerDirective</code> with a priority numerically equal to
this
+ * <code>ListenerDirective</code>; a value less than <code>0</code>
+ * if the argument is a <code>ListenerDirective</code> numerically
+ * greater than this <code>ListenerDirective</code>; and a value
+ * greater than <code>0</code> if the argument is a
+ * <code>ListenerDirective</code> numerically less than this
+ * <code>ListenerDirective</code>.
+ * @exception <code>ClassCastException</code> if the argument is not an
+ * <code>ListenerDirective</code>.
+ * @see java.lang.Comparable
+ */
+ public int compareTo( Object other )
+ {
+ ListenerDirective directive = (ListenerDirective) other;
+ Integer p1 = new Integer( m_priority );
+ Integer p2 = new Integer( directive.getPriority() );
+ return p1.compareTo( p2 );
+ }
+
/**
* Compare this object with another for equality.
* @param other the other object
@@ -153,6 +192,10 @@
{
return false;
}
+ else if( m_priority != object.m_priority )
+ {
+ return false;
+ }
else if( !equals( m_uri, object.m_uri ) )
{
return false;
@@ -178,6 +221,7 @@
hash ^= super.hashValue( m_name );
hash ^= super.hashArray( m_dependencies );
hash ^= super.hashValue( m_uri );
+ hash ^= m_priority;
return hash;
}
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/model/Processor.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -27,6 +27,12 @@
public interface Processor
{
/**
+ * Handle cleanup.
+ * @param context the working context
+ */
+ void clean( Context context );
+
+ /**
* Handle initialization.
* @param context the working context
*/

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/AbstractProcessor.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -30,6 +30,14 @@
public class AbstractProcessor implements Processor
{
/**
+ * Handle cleanup.
+ * @param context the working context
+ */
+ public void clean( Context context )
+ {
+ }
+
+ /**
* Handle initialization.
* @param context the working context
*/

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/JarProcess.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -1,168 +0,0 @@
-/*
- * Copyright 2005-2006 Stephen J. McConnell
- *
- * 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.
- */
-
-package net.dpml.tools.process;
-
-import java.io.File;
-
-import net.dpml.library.Resource;
-import net.dpml.library.Type;
-import net.dpml.library.info.Scope;
-import net.dpml.library.info.JarTypeDirective;
-
-import net.dpml.tools.model.Context;
-
-import net.dpml.tools.tasks.JavacTask;
-import net.dpml.tools.tasks.JarTask;
-import net.dpml.tools.tasks.JUnitTestTask;
-import net.dpml.tools.tasks.RMICTask;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Path;
-
-/**
- * Processor supporting ujava class compilation, jar creation,
- * testcase compilation and test execution.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class JarProcess extends AbstractProcessor
-{
- /**
- * Executes the compilation of java source files
- * under the normalized target/main/classes directory.
- *
- * @param context the working context
- */
- public void build( Context context )
- {
- Project project = context.getProject();
- final JavacTask task = new JavacTask( context );
- task.setProject( project );
- task.init();
- task.execute();
-
- Resource resource = context.getResource();
- if( resource.isa( "jar" ) )
- {
- Type type = resource.getType( "jar" );
- if( type instanceof JarTypeDirective )
- {
- JarTypeDirective directive = (JarTypeDirective) type;
- String[] includes = directive.getRMICIncludes();
- String[] excludes = directive.getRMICExcludes();
- RMICTask rmicTask = new RMICTask( context );
- rmicTask.setProject( project );
- rmicTask.setIncludes( includes );
- rmicTask.setExcludes( excludes );
- rmicTask.init();
- rmicTask.execute();
- }
- }
- }
-
- /**
- * Packages java class files into a jar file published under
- * the target/deliverables/jars directory.
- *
- * @param context the working context
- */
- public void pack( Context context )
- {
- Project project = context.getProject();
- String jarSrcPath = context.getProperty(
"project.target.classes.main.dir" );
- File jarSrcDir = new File( jarSrcPath );
- if( jarSrcDir.exists() )
- {
- final JarTask task = new JarTask();
- task.setProject( project );
- task.setTaskName( "jar" );
- task.setSrc( jarSrcDir );
- final File jar = getJarFile( context );
- task.setDest( jar );
- task.init();
- task.execute();
- }
- }
-
- /**
- * Compiles and executes unit tests using a classpath incorporating the
- * jar file produced under the pack phase.
- *
- * @param context the working context
- */
- public void validate( Context context )
- {
- Project project = context.getProject();
- String srcPath = context.getProperty(
"project.target.build.test.dir" );
- File src = new File( srcPath );
- if( src.exists() )
- {
- final File jar = getJarFile( context );
- Path testCompilePath = context.getPath( Scope.TEST );
- if( jar.exists() )
- {
- testCompilePath.createPathElement().setLocation( jar );
- }
- final File dest = new File( project.getProperty(
"project.target.classes.test.dir" ) );
- try
- {
- final JavacTask task = new JavacTask( context );
- task.setProject( project );
- task.setTaskName( "javac" );
- task.setSrc( src );
- task.setDest( dest );
- task.setClasspath( testCompilePath );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
- try
- {
- testCompilePath.createPathElement().setLocation( dest );
- final JUnitTestTask task = new JUnitTestTask();
- task.setProject( project );
- task.setTaskName( "junit" );
- task.setSrc( src );
- task.setClasspath( testCompilePath );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
- }
- }
-
- private File getJarFile( Context context )
- {
- Project project = context.getProject();
- String deliverablesPath = context.getProperty(
"project.target.deliverables.dir" );
- File deliverables = new File( deliverablesPath );
- File jars = new File( deliverables, "jars" );
- String filename = context.getLayoutPath( "jar" );
- return new File( jars, filename );
- }
-
-}

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/ModuleProcess.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -1,50 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * 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.
- */
-
-package net.dpml.tools.process;
-
-import net.dpml.tools.model.Context;
-
-import net.dpml.tools.tasks.ModuleTask;
-
-import org.apache.tools.ant.Project;
-
-/**
- * Processor supporting module datatype production.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ModuleProcess extends AbstractProcessor
-{
- /**
- * Creation of a module descriptor under the directory
- * target/deliverables/modules.
- *
- * @param context the working context
- */
- public void pack( Context context )
- {
- Project project = context.getProject();
- final ModuleTask task = new ModuleTask();
- task.setProject( project );
- task.setTaskName( "module" );
- task.init();
- task.execute();
- }
-}

Deleted:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/PluginProcess.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -1,68 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * 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.
- */
-
-package net.dpml.tools.process;
-
-import net.dpml.tools.model.Context;
-
-import net.dpml.tools.tasks.PartTask;
-
-import net.dpml.util.ExceptionHelper;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-
-/**
- * Processor supporting part datatype production.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PluginProcess extends AbstractProcessor
-{
- /**
- * Creation of a part descriptor under the directory
- * target/deliverables/parts.
- *
- * @param context the working context
- */
- public void pack( Context context )
- {
- try
- {
- PartTask task = new PartTask();
- Project project = context.getProject();
- task.setProject( project );
- task.setTaskName( "part" );
- task.init();
- task.execute();
- }
- catch( BuildException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String message =
- "Unexpected failure during plugin generation.";
- final String error =
- ExceptionHelper.packException( message, e, true );
- throw new BuildException( error, e );
- }
- }
-}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/process/StandardProcess.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -18,11 +18,28 @@

package net.dpml.tools.process;

+import java.io.File;
+
+import net.dpml.library.Resource;
+import net.dpml.library.Type;
+import net.dpml.library.info.Scope;
+import net.dpml.library.info.JarTypeDirective;
+
import net.dpml.tools.model.Context;
+
import net.dpml.tools.tasks.PrepareTask;
import net.dpml.tools.tasks.InstallTask;
+import net.dpml.tools.tasks.JavacTask;
+import net.dpml.tools.tasks.JarTask;
+import net.dpml.tools.tasks.JUnitTestTask;
+import net.dpml.tools.tasks.ModuleTask;
+import net.dpml.tools.tasks.RMICTask;
+import net.dpml.tools.tasks.PartTask;

import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Delete;

/**
* Standard process dealing with context initialization, codfebase
@@ -41,7 +58,6 @@
*/
public void initialize( Context context )
{
- context.init();
}

/**
@@ -54,6 +70,7 @@
*/
public void prepare( Context context )
{
+ context.init();
context.getProject().log( "commencing preparation",
Project.MSG_VERBOSE );
Project project = context.getProject();
final PrepareTask task = new PrepareTask();
@@ -65,6 +82,178 @@
}

/**
+ * Handles build related concerns based on the target directory layout
content.
+ *
+ * @param context the working context
+ */
+ public void build( Context context )
+ {
+ // If a target/build/main or target/build/test exists then we should
be
+ // triggering content compilation. Compilation requires project
input
+ // with respect to javac source selection and subsequent rmic
+ // postprocessing (both of which can be expressed as process data
associated
+ // with the target/build/main and target/build/test directories). In
addition
+ // there may be additional processes that need to be triggered (such
as
+ // type compilation which consumes compiled classes).
+
+ if( context.getTargetBuildMainDirectory().exists() )
+ {
+ // we need to add in here the aquisition of javac task
+ // parameters based on transformation directives associated
+ // with the target/classes/main directory
+
+ Project project = context.getProject();
+ final JavacTask task = new JavacTask( context );
+ task.setProject( project );
+ task.init();
+ task.execute();
+ }
+
+ // resolve rmic selection
+
+ Resource resource = context.getResource();
+ if( resource.isa( "jar" ) )
+ {
+ Type type = resource.getType( "jar" );
+ if( type instanceof JarTypeDirective )
+ {
+ JarTypeDirective directive = (JarTypeDirective) type;
+ String[] includes = directive.getRMICIncludes();
+ String[] excludes = directive.getRMICExcludes();
+ RMICTask rmicTask = new RMICTask( context );
+ Project project = context.getProject();
+ rmicTask.setProject( project );
+ rmicTask.setIncludes( includes );
+ rmicTask.setExcludes( excludes );
+ rmicTask.init();
+ rmicTask.execute();
+ }
+ }
+
+ // conditionaly compile test classes
+
+ File source = context.getTargetBuildTestDirectory();
+ if( source.exists() )
+ {
+ // we need to add in here the aquisition of javac task
+ // parameters based on transformation directives associated
+ // with the target/classes/main directory
+
+ Project project = context.getProject();
+ final JavacTask task = new JavacTask( context );
+ task.setProject( project );
+ File destination = context.getTargetClassesTestDirectory();
+ task.setSrc( source );
+ task.setDest( destination );
+ Path path = context.getPath( Scope.TEST );
+ File main = context.getTargetClassesMainDirectory();
+ if( main.exists() )
+ {
+ path.createPathElement().setLocation( main );
+ }
+ task.setClasspath( path );
+ task.init();
+ task.execute();
+ }
+ }
+
+ /**
+ * Packaging of type-specific data.
+ * @param context the working context
+ */
+ public void pack( Context context )
+ {
+ Project project = context.getProject();
+ Resource resource = context.getResource();
+
+ // handle jar file packaging
+
+ if( resource.isa( "jar" ) )
+ {
+ File base = context.getTargetClassesMainDirectory();
+ final File jar = getJarFile( context );
+ if( base.exists() )
+ {
+ final JarTask task = new JarTask();
+ task.setProject( project );
+ task.setTaskName( "jar" );
+ task.setSrc( base );
+ task.setDest( jar );
+ task.init();
+ task.execute();
+ }
+ }
+
+ // handle part production
+
+ if( resource.isa( "part" ) )
+ {
+ try
+ {
+ PartTask task = new PartTask();
+ task.setProject( project );
+ task.setTaskName( "part" );
+ task.init();
+ task.execute();
+ }
+ catch( BuildException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected failure during part externalization.";
+ throw new BuildException( error, e );
+ }
+ }
+
+ // handle module export
+
+ if( resource.isa( "module" ) )
+ {
+ final ModuleTask task = new ModuleTask();
+ task.setProject( project );
+ task.setTaskName( "module" );
+ task.init();
+ task.execute();
+ }
+ }
+
+ /**
+ * Datatype validation.
+ * @param context the working context
+ */
+ public void validate( Context context )
+ {
+ Project project = context.getProject();
+ File src = context.getTargetBuildTestDirectory();
+ if( src.exists() )
+ {
+ Path path = context.getPath( Scope.TEST );
+ final File jar = getJarFile( context );
+ if( jar.exists() )
+ {
+ path.createPathElement().setLocation( jar );
+ }
+ else if( context.getTargetClassesMainDirectory().exists() )
+ {
+ File main = context.getTargetClassesMainDirectory();
+ path.createPathElement().setLocation( main );
+ }
+ final File dest = context.getTargetClassesTestDirectory();
+ path.createPathElement().setLocation( dest );
+ final JUnitTestTask task = new JUnitTestTask();
+ task.setProject( project );
+ task.setTaskName( "junit" );
+ task.setSrc( src );
+ task.setClasspath( path );
+ task.init();
+ task.execute();
+ }
+ }
+
+ /**
* Handles replication of content under target/deliverables to the
* common cache directory - includes validation of the presence of
declared
* artifacts during execution.
@@ -80,4 +269,30 @@
task.init();
task.execute();
}
+
+ /**
+ * Handles cleanup of generated content.
+ *
+ * @param context the working context
+ */
+ public void clean( Context context )
+ {
+ File dir = context.getTargetDirectory();
+ Project project = context.getProject();
+ final Delete task = new Delete();
+ task.setProject( project );
+ task.setTaskName( "delete" );
+ task.setDir( dir );
+ task.init();
+ task.execute();
+ }
+
+ private File getJarFile( Context context )
+ {
+ Project project = context.getProject();
+ File deliverables = context.getTargetDeliverablesDirectory();
+ File jars = new File( deliverables, "jars" );
+ String filename = context.getLayoutPath( "jar" );
+ return new File( jars, filename );
+ }
}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JarTask.java
===================================================================
--- trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JarTask.java
2006-05-27 06:27:11 UTC (rev 1463)
+++ trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JarTask.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -174,7 +174,6 @@
final Manifest.Section main = manifest.getMainSection();

String publisher = resource.getProperty(
"project.publisher.name" );
- //String publisher = getContext().getProperty( type,
"project.publisher.name", null );
if( null != publisher )
{
addAttribute( main, "Created-By", publisher );
@@ -187,7 +186,6 @@
addAttribute( main, "Class-Path", classpath );
}

- //final String mainClass = getContext().getProperty( type,
JAR_MAIN_KEY, null );
final String mainClass = resource.getProperty( JAR_MAIN_KEY );
if( null != mainClass )
{
@@ -195,29 +193,24 @@
}

addAttribute( main, "Extension-Name",
getResource().getResourcePath() );
- //String specificationVendor = getContext().getProperty( type,
"project.specification.vendor", null );
String specificationVendor = resource.getProperty(
"project.specification.vendor" );
if( null != specificationVendor )
{
addAttribute( main, "Specification-Vendor",
specificationVendor );
}

- //String version = getContext().getProperty( type,
"project.specification.version", null );
String version = resource.getProperty(
"project.specification.version" );
if( null != version )
{
addAttribute( main, "Specification-Version", version );
}

- //String implementationVendor = getContext().getProperty( type,
"project.implementation.vendor", null );
String implementationVendor = resource.getProperty(
"project.implementation.vendor" );
if( null != implementationVendor )
{
addAttribute( main, "Implementation-Vendor",
implementationVendor );
}

- //String implementationVendorID =
- // getContext().getProperty( type,
"project.implementation.vendor-id", null );
String implementationVendorID = resource.getProperty(
"project.implementation.vendor-id" );
if( null != implementationVendorID )
{

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/JavacTask.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -80,7 +80,7 @@
private static final String TARGET_VALUE = "1.4";

private final Context m_context;
-
+
private String m_classPathRef;
private Path m_classPath;
private File m_destination;

Modified:
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
===================================================================
---
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
2006-05-27 06:27:11 UTC (rev 1463)
+++
trunk/main/depot/tools/builder/src/test/net/dpml/tools/info/ListenerDirectiveTestCase.java
2006-05-28 15:17:18 UTC (rev 1464)
@@ -28,6 +28,7 @@
public final class ListenerDirectiveTestCase extends AbstractTestCase
{
static final String NAME = "test";
+ static final int PRIORITY = 0;
static final String SPEC = "local:plugin:acme/widget";
static final String CLASSNAME = "net.dpml.tools.process.JarProcess";
static final String[] DEPS = new String[0];
@@ -39,13 +40,13 @@
{
LISTENERS[0] =
new ListenerDirective(
- "jar", (URI) null, CLASSNAME, DEPS, PROPERTIES );
+ "jar", 0, (URI) null, CLASSNAME, DEPS, PROPERTIES );
LISTENERS[1] =
new ListenerDirective(
- "acme", new URI( SPEC ), null, DEPS, PROPERTIES );
+ "acme", 1, new URI( SPEC ), null, DEPS, PROPERTIES );
LISTENERS[2] =
new ListenerDirective(
- "widget", (URI) null, CLASSNAME, new String[]{"acme"},
PROPERTIES );
+ "widget", 2, (URI) null, CLASSNAME, new String[]{"acme"},
PROPERTIES );
}
catch( Exception e )
{
@@ -63,7 +64,7 @@
try
{
new ListenerDirective(
- null, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
+ null, 0, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -82,7 +83,7 @@
try
{
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, null, PROPERTIES );
+ NAME, 0, new URI( SPEC ), CLASSNAME, null, PROPERTIES );
fail( "no-NPE" );
}
catch( NullPointerException e )
@@ -99,7 +100,7 @@
{
ListenerDirective process =
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
+ NAME, 0, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
assertEquals( "name", NAME, process.getName() );
}

@@ -111,7 +112,7 @@
{
ListenerDirective process =
new ListenerDirective(
- NAME, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
+ NAME, 0, new URI( SPEC ), CLASSNAME, DEPS, PROPERTIES );
assertEquals( "uri", SPEC, process.getURISpec() );
}

@@ -125,7 +126,7 @@
String dep2 = "def";
String[] deps = new String[]{dep1, dep2};
ListenerDirective process =
- new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
+ new ListenerDirective( NAME, 0, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
assertEquals( "deps", deps, process.getDependencies() );
}

@@ -139,7 +140,7 @@
String dep2 = "def";
String[] deps = new String[]{dep1, dep2};
ListenerDirective process =
- new ListenerDirective( NAME, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
+ new ListenerDirective( NAME, 0, new URI( SPEC ), CLASSNAME, deps,
PROPERTIES );
doSerializationTest( process );
}


Modified: trunk/main/lang/module/etc/module.xsd
===================================================================
--- trunk/main/lang/module/etc/module.xsd 2006-05-27 06:27:11 UTC (rev
1463)
+++ trunk/main/lang/module/etc/module.xsd 2006-05-28 15:17:18 UTC (rev
1464)
@@ -15,6 +15,9 @@
<element name="resource" type="this:ResourceType"/>
<element name="property" type="this:PropertyType"/>
<element name="type" type="common:AbstractType"
substitutionGroup="common:type"/>
+
+ <element name="data" type="this:InstructionSetType"/>
+
<!--<element name="abstract-filter" type="this:AbstractFilter"/>
<element name="filters" type="this:FiltersType"
substitutionGroup="common:data"/>
<element name="filter" type="this:Filter"
substitutionGroup="this:abstract-filter"/>
@@ -173,7 +176,7 @@
</extension>
</complexContent>
</complexType>
-
+
<simpleType name="tag">
<restriction base="string">
<enumeration value="system"/>
@@ -182,64 +185,10 @@
<enumeration value="private"/>
</restriction>
</simpleType>
-
- <complexType name="jar">
- <complexContent>
- <extension base="common:AbstractType">
- <sequence>
- <element name="src" type="this:PatternCollectionType"
minOccurs="0" maxOccurs="1"/>
- <element name="rmic" type="this:PatternCollectionType"
minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="compress" type="boolean" default="true"/>
- <attribute name="index" type="boolean" default="true"/>
- </extension>
- </complexContent>
- </complexType>

- <!--
- <complexType name="RMICType">
- <complexContent>
- <extension base="this:PatternCollectionType"/>
- </complexContent>
- </complexType>
- -->
-
- <complexType name="PatternCollectionType">
- <choice minOccurs="0" maxOccurs="unbounded">
- <element name="include" type="this:IncludePatternType"/>
- <element name="exclude" type="this:ExcludePatternType"/>
- </choice>
- </complexType>
+ <!-- filter management -->

- <complexType name="IncludePatternType">
- <simpleContent>
- <extension base="string">
- <attribute name="name" type="string"/>
- </extension>
- </simpleContent>
- </complexType>
-
- <complexType name="ExcludePatternType">
- <simpleContent>
- <extension base="string">
- <attribute name="name" type="string"/>
- </extension>
- </simpleContent>
- </complexType>
-
- <!--
<complexType name="FiltersType">
- <complexContent>
- <extension base="common:AbstractData">
- <sequence>
- <element ref="this:abstract-filter" minOccurs="0"
maxOccurs="unbounded"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
- -->
-
- <complexType name="FiltersType">
<choice minOccurs="0" maxOccurs="unbounded">
<element name="filter" type="this:Filter"/>
<element name="feature" type="this:Feature"/>
@@ -281,5 +230,55 @@
</restriction>
</simpleType>

+ <!-- new stuff-->
+
+ <complexType name="InstructionSetType">
+ <sequence>
+ <element name="data" type="this:DataType" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DataType" abstract="true">
+ <attribute name="id" type="string" use="required"/>
+ </complexType>
+
+ <!-- existing process stuff-->
+
+ <complexType name="jar">
+ <complexContent>
+ <extension base="common:AbstractType">
+ <sequence>
+ <element name="src" type="this:PatternCollectionType"
minOccurs="0" maxOccurs="1"/>
+ <element name="rmic" type="this:PatternCollectionType"
minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="compress" type="boolean" default="true"/>
+ <attribute name="index" type="boolean" default="true"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PatternCollectionType">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="include" type="this:IncludePatternType"/>
+ <element name="exclude" type="this:ExcludePatternType"/>
+ </choice>
+ </complexType>
+
+ <complexType name="IncludePatternType">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="ExcludePatternType">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="name" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
</schema>





  • r1464 - in trunk/main: depot/tools/builder/etc/prefs/templates depot/tools/builder/etc/prefs/xmls depot/tools/builder/src/main/net/dpml/tools/impl depot/tools/builder/src/main/net/dpml/tools/info depot/tools/builder/src/main/net/dpml/tools/model depot/tools/builder/src/main/net/dpml/tools/process depot/tools/builder/src/main/net/dpml/tools/tasks depot/tools/builder/src/test/net/dpml/tools/info lang/module/etc, mcconnell at BerliOS, 05/28/2006

Archive powered by MHonArc 2.6.24.

Top of Page