Skip to Content.
Sympa Menu

notify-dpml - r1468 - in trunk/main/depot/tools/builder: . etc/prefs/templates src/main/net/dpml/tools/impl src/main/net/dpml/tools/info src/main/net/dpml/tools/tasks

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: r1468 - in trunk/main/depot/tools/builder: . etc/prefs/templates src/main/net/dpml/tools/impl src/main/net/dpml/tools/info src/main/net/dpml/tools/tasks
  • Date: Mon, 29 May 2006 10:43:47 +0200

Author: mcconnell
Date: 2006-05-29 10:43:46 +0200 (Mon, 29 May 2006)
New Revision: 1468

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/BuildTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/CleanTask.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PackageTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/TestTask.java
Modified:
trunk/main/depot/tools/builder/build.xml
trunk/main/depot/tools/builder/etc/prefs/templates/standard.template

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/StandardProcess.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/tasks/PrepareTask.java
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
Log:
updated depot to provide support for generic build, packaging, test tasks -
and refactored build strategy to drive off the declaration of generic tasks
in the template (improving readability of build sequence).

Modified: trunk/main/depot/tools/builder/build.xml
===================================================================
--- trunk/main/depot/tools/builder/build.xml 2006-05-29 06:33:00 UTC (rev
1467)
+++ trunk/main/depot/tools/builder/build.xml 2006-05-29 08:43:46 UTC (rev
1468)
@@ -10,6 +10,7 @@
<target name="init" depends="bootstrap.init">
<filter token="PART-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-part#${dpml.xsd.version}"/>
<filter token="PROJECT-URI"
value="artifact:part:${project.group}/${project.name}#${project.version}" />
+ <filter token="PROJECT-LINK-URI"
value="link:part:${project.group}/${project.name}" />
<filter token="PROJECT-NAME" value="${project.name}" />
<filter token="PROJECT-GROUP" value="${project.group}"/>
<filter token="PROJECT-VERSION" value="${project.version}"/>
@@ -18,6 +19,8 @@
<filter token="PLUGIN-CLASS"
value="net.dpml.tools.impl.StandardBuilder"/>
<filter token="DEPOT-CHECKSTYLE-PLUGIN-URI"

value="artifact:plugin:${project.group}/dpml-depot-checkstyle#${project.version}"/>
+ <filter token="DEPOT-CHECKSTYLE-PLUGIN-LINK-URI"
+ value="link:plugin:${project.group}/dpml-depot-checkstyle"/>
</target>

<target name="setup-path" depends="bootstrap.setup-path">

Modified: trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
===================================================================
--- trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-05-29 06:33:00 UTC (rev 1467)
+++ trunk/main/depot/tools/builder/etc/prefs/templates/standard.template
2006-05-29 08:43:46 UTC (rev 1468)
@@ -20,7 +20,7 @@
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="dpml:depot" >

- <transit:plugin uri="@PROJECT-URI@">
+ <transit:plugin uri="@PROJECT-LINK-URI@">
<antlib urn="dpml:depot" resource="net/dpml/tools/tasks/antlib.xml"/>
</transit:plugin>

@@ -28,23 +28,35 @@
<x:init/>
</target>

- <target name="clean" depends="init"/>
+ <target name="clean" depends="init">
+ <x:clean/>
+ </target>

- <target name="prepare" depends="init"/>
+ <target name="prepare" depends="init">
+ <x:prepare/>
+ </target>

- <target name="build" depends="prepare"/>
+ <target name="build" depends="prepare">
+ <x:build/>
+ </target>

- <target name="package" depends="build"/>
+ <target name="package" depends="build">
+ <x:package/>
+ </target>

- <target name="test" depends="package"/>
+ <target name="test" depends="package">
+ <x:test/>
+ </target>

- <target name="install" depends="test"/>
+ <target name="install" depends="test">
+ <x:install/>
+ </target>

<target name="checkstyle" depends="prepare">
<property name="checkstyle.dir"
location="${project.target.reports.dir}/checkstyle"/>
<property name="checkstyle.data"
location="${checkstyle.dir}/checkstyle.xml"/>
<property name="project.checkstyle.data"
location="${project.target.reports.dir}/checkstyle"/>
- <x:plugin uri="@DEPOT-CHECKSTYLE-PLUGIN-URI@">
+ <x:plugin uri="@DEPOT-CHECKSTYLE-PLUGIN-LINK-URI@">
<task class="net.dpml.tools.checkstyle.CheckstyleTask"
name="checkstyle"/>
</x:plugin>
<mkdir dir="${checkstyle.dir}"/>

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-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/DefaultContext.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -163,7 +163,7 @@
}

/**
- * Initialize the contex during which runtime and test path objects are
+ * Initialize the context during which runtime and test path objects are
* established as project references.
*/
public void init()

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-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardBuildListener.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -93,10 +93,10 @@
String targetName = target.getName();
if( "clean".equals( targetName ) )
{
- event.getProject().log( "executing clenup phase",
Project.MSG_VERBOSE );
+ event.getProject().log( "executing cleanup phase",
Project.MSG_VERBOSE );
m_standard.clean( m_context );
}
- if( "init".equals( targetName ) )
+ else if( "init".equals( targetName ) )
{
event.getProject().log( "executing initialization phase",
Project.MSG_VERBOSE );
m_standard.initialize( m_context );

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardProcess.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardProcess.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/impl/StandardProcess.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -51,8 +51,7 @@
public class StandardProcess extends AbstractProcessor
{
/**
- * Handles context initialization during which path definitions
- * for runtime and test concerns are bound to the active project.
+ * Handles context initialization.
*
* @param context the working context
*/
@@ -70,15 +69,6 @@
*/
public void prepare( Context context )
{
- context.init();
- context.getProject().log( "commencing preparation",
Project.MSG_VERBOSE );
- Project project = context.getProject();
- final PrepareTask task = new PrepareTask();
- task.setProject( project );
- task.setTaskName( "prepare" );
- task.init();
- task.execute();
- context.getProject().log( "preparation complete",
Project.MSG_VERBOSE );
}

/**
@@ -88,6 +78,7 @@
*/
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
@@ -155,6 +146,7 @@
task.init();
task.execute();
}
+ */
}

/**
@@ -163,6 +155,7 @@
*/
public void pack( Context context )
{
+ /*
Project project = context.getProject();
Resource resource = context.getResource();

@@ -218,6 +211,7 @@
task.init();
task.execute();
}
+ */
}

/**
@@ -262,12 +256,6 @@
*/
public void install( Context context )
{
- Project project = context.getProject();
- final InstallTask task = new InstallTask();
- task.setProject( project );
- task.setTaskName( "install" );
- task.init();
- task.execute();
}

/**
@@ -277,14 +265,6 @@
*/
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 )

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-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirective.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -42,7 +42,6 @@
* Creation of a new library directive.
* @param listeners an array of listener directives
* @param phase the default target phase
- * @param processors an array of processor directives
* @param properties supplimentary properties
* @exception UnknownKeyException if a unknown key is referenced
*/

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-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/BuilderDirectiveHelper.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -48,8 +48,6 @@
private static final String LISTENER_ELEMENT_NAME = "listener";
private static final String PROPERTIES_ELEMENT_NAME = "properties";
private static final String PROPERTY_ELEMENT_NAME = "property";
- private static final String PROCESSORS_ELEMENT_NAME = "processors";
- private static final String PROCESSOR_ELEMENT_NAME = "processor";

private BuilderDirectiveHelper()
{

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-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/info/ListenerDirective.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -26,7 +26,7 @@

/**
* The ListenerDirective is an immutable descriptor used to define
- * a build listener that serves to construct an identified type.
+ * a build listener to be attached to an Ant project.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -44,7 +44,6 @@
* @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
* @param properties supplimentary properties
* @exception NullPointerException if name or dependencies are null
* @exception IllegalStateException if both classname and urn values are
null
@@ -76,8 +75,8 @@
}

/**
- * Return the listener resource type name.
- * @return the name of the resource type produced by the listener
+ * Return the listener name.
+ * @return the listener name
*/
public String getName()
{
@@ -94,7 +93,7 @@
}

/**
- * Return the listener codebase urn.
+ * Return the listener codebase uri.
* @return the urn
*/
public URI getURI()
@@ -103,8 +102,8 @@
}

/**
- * Return the listener codebase urn.
- * @return the urn
+ * Return the listener codebase uri as a string.
+ * @return the uri value
*/
public String getURISpec()
{
@@ -119,11 +118,9 @@
}

/**
- * Return true if the listener produces a build artifact. If false
- * the listener may contribute to a build process but does not generate a
- * specific artifact type.
+ * Get the listener classname.
*
- * @return true if the listener produces an artifact
+ * @return the classname of the listener
*/
public String getClassname()
{

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/BuildTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/BuildTask.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/BuildTask.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -0,0 +1,117 @@
+/*
+ * 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.tasks;
+
+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.Context;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Delete;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Cleanup of generated target directory.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class BuildTask extends GenericTask
+{
+ /**
+ * Compiles main and test classes resulting in the creation of the
+ * target/classes/main and target/classes/test directories.
+ */
+ public void execute()
+ {
+ // 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).
+
+ Context context = getContext();
+ 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();
+ }
+ }
+}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/CleanTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/CleanTask.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/CleanTask.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -0,0 +1,52 @@
+/*
+ * 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.tasks;
+
+import java.io.File;
+
+import net.dpml.tools.Context;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Delete;
+
+/**
+ * Cleanup of generated target directory.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class CleanTask extends GenericTask
+{
+ /**
+ * Removes generated content through deletion of the declared
+ * project target directory.
+ */
+ public void execute()
+ {
+ Context context = getContext();
+ 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();
+ }
+}

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PackageTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PackageTask.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PackageTask.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -0,0 +1,115 @@
+/*
+ * 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.tasks;
+
+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.Context;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Delete;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Cleanup of generated target directory.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PackageTask extends GenericTask
+{
+ /**
+ * Compiles main and test classes resulting in the creation of the
+ * target/classes/main and target/classes/test directories.
+ */
+ public void execute()
+ {
+ Context context = getContext();
+ 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();
+ }
+ }
+
+ 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/PrepareTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PrepareTask.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/PrepareTask.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -82,6 +82,8 @@
final Project project = getProject();
Resource resource = getResource();
Context context = getContext();
+ context.init();
+
log( "basedir: " + getResource().getBaseDir(), Project.MSG_VERBOSE );

//

Added:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/TestTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/TestTask.java
2006-05-29 06:33:00 UTC (rev 1467)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/TestTask.java
2006-05-29 08:43:46 UTC (rev 1468)
@@ -0,0 +1,85 @@
+/*
+ * 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.tasks;
+
+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.Context;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Delete;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Cleanup of generated target directory.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class TestTask extends GenericTask
+{
+ /**
+ * Compiles main and test classes resulting in the creation of the
+ * target/classes/main and target/classes/test directories.
+ */
+ public void execute()
+ {
+ Context context = getContext();
+ 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();
+ }
+ }
+
+ 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/antlib.xml
===================================================================
--- trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
2006-05-29 06:33:00 UTC (rev 1467)
+++ trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/antlib.xml
2006-05-29 08:43:46 UTC (rev 1468)
@@ -1,11 +1,15 @@
<?xml version="1.0"?>
<antlib>
+
+ <taskdef name="clean" classname="net.dpml.tools.tasks.CleanTask"/>
<taskdef name="init"
classname="net.dpml.tools.tasks.InitializationTask"/>
<taskdef name="prepare" classname="net.dpml.tools.tasks.PrepareTask"/>
+ <taskdef name="build" classname="net.dpml.tools.tasks.BuildTask"/>
+ <taskdef name="package" classname="net.dpml.tools.tasks.PackageTask"/>
+ <taskdef name="test" classname="net.dpml.tools.tasks.TestTask"/>
<taskdef name="install" classname="net.dpml.tools.tasks.InstallTask"/>
- <!--<taskdef name="javac"
classname="net.dpml.tools.tasks.JavacTask"/>-->
+
<taskdef name="jar" classname="net.dpml.tools.tasks.JarTask"/>
- <!--<taskdef name="export"
classname="net.dpml.tools.tasks.PluginExportTask"/>-->
<taskdef name="junit"
classname="net.dpml.tools.tasks.JUnitTestTask"/>
<taskdef name="property"
classname="net.dpml.tools.tasks.PropertyTask"/>
<taskdef name="filter" classname="net.dpml.tools.tasks.FilterTask"/>
@@ -15,4 +19,8 @@
<taskdef name="replicate"
classname="net.dpml.tools.tasks.ReplicateTask"/>
<taskdef name="javadoc" classname="net.dpml.tools.tasks.JavadocTask"/>
<taskdef name="docs" classname="net.dpml.tools.tasks.DocTask"/>
+
+ <!--<taskdef name="javac"
classname="net.dpml.tools.tasks.JavacTask"/>-->
+ <!--<taskdef name="export"
classname="net.dpml.tools.tasks.PluginExportTask"/>-->
+
</antlib>




  • r1468 - in trunk/main/depot/tools/builder: . etc/prefs/templates src/main/net/dpml/tools/impl src/main/net/dpml/tools/info src/main/net/dpml/tools/tasks, mcconnell at BerliOS, 05/29/2006

Archive powered by MHonArc 2.6.24.

Top of Page