donaldp 02/04/14 04:16:17
Added: buildtools .cvsignore build.xml project.properties
buildtools/src/conf MANIFEST.MF
buildtools/src/java/org/apache/myrmidon/build
AntDocSubTask.java AntlibDescriptorTask.java
AntlibJarTask.java
Log:
Add in the build utilities for myrmidon.
Revision Changes Path
1.1 jakarta-ant-myrmidon/buildtools/.cvsignore
Index: .cvsignore
===================================================================
ant.properties
build
checkstyle.cache
distributions
dist
myrmidon-*
*.el
*.ipr
1.1 jakarta-ant-myrmidon/buildtools/build.xml
Index: build.xml
===================================================================
<?xml version="1.0"?>
<project name="Myrmidon BuildTools" default="main" basedir=".">
<!-- load per-project properties -->
<property file="project.properties"/>
<!--
Give user a chance to override without editing this file
(and without typing -D each time he compiles it)
-->
<property file="ant.properties"/>
<property file="../ant.properties"/>
<property file="${user.home}/.ant.properties"/>
<!-- Settings used to configure compile environment -->
<property name="build.debug" value="on"/>
<property name="build.optimize" value="off"/>
<property name="build.deprecation" value="off"/>
<property name="build.compress" value="false"/>
<!-- location of intermediate products -->
<property name="build.dir" value="build"/>
<property name="build.lib" value="${build.dir}/lib"/>
<property name="build.conf" value="${build.dir}/conf"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.reports" value="${build.dir}/reports"/>
<!-- Set the properties for source directories -->
<property name="src.dir" value="src"/>
<property name="java.dir" value="${src.dir}/java"/>
<property name="conf.dir" value="${src.dir}/conf"/>
<!-- Set the properties for distribution directories -->
<property name="dist.dir" value="dist"/>
<property name="dist.javadocs" value="${dist.dir}/docs/api"/>
<!-- property to specify name of zip/jar files -->
<property name="dist.name" value="${name}-${version}"/>
<!-- property indicating directory where all distribution archives are
placed -->
<property name="dist.base" value="distributions"/>
<!-- Classpath for product -->
<path id="project.class.path">
<pathelement path="${java.class.path}"/>
<pathelement location="${build.classes}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${checkstyle.jar}"/>
<fileset dir="../tools/xdoclet">
<include name="*.jar"/>
</fileset>
<fileset dir="../lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="main" depends="jar" description="Build the project"/>
<target name="rebuild" depends="clean,main" description="Rebuild the
project"/>
<!-- Compiles the source code -->
<target name="compile" description="Compiles the source code">
<mkdir dir="${build.classes}"/>
<!-- Compile all classes -->
<javac srcdir="${java.dir}"
destdir="${build.classes}"
debug="${build.debug}"
optimize="${build.optimize}"
deprecation="${build.deprecation}"
target="1.2">
<classpath refid="project.class.path" />
<include name="**/*.java"/>
</javac>
<!-- copy resources to same location as .class files -->
<copy todir="${build.classes}">
<fileset dir="${java.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Copies and filters the manifest and license. Used by jar and dist -->
<target name="prepare-conf">
<mkdir dir="${build.conf}"/>
<copy todir="${build.conf}" flatten="true">
<fileset dir="../" includes="LICENSE.txt"/>
<fileset dir="${conf.dir}">
<include name="MANIFEST.MF"/>
<include name="*.xml"/>
</fileset>
<filterset>
<filtersfile file="project.properties"/>
</filterset>
</copy>
</target>
<!-- Creates all the .jar file -->
<target name="jar" depends="compile, prepare-conf" description="Generates
the jar files">
<mkdir dir="${build.lib}"/>
<jar jarfile="${build.lib}/${dist.name}.jar"
basedir="${build.classes}"
compress="${build.compress}"
manifest="${build.conf}/MANIFEST.MF">
<zipfileset dir="${build.conf}" prefix="META-INF/">
<include name="LICENSE.txt"/>
<include name="*.xml"/>
</zipfileset>
</jar>
</target>
<!-- Creates all the Javadocs -->
<target name="javadocs" depends="compile" description="Generates the
javadocs">
<mkdir dir="${dist.javadocs}"/>
<javadoc packagenames="org.apache.*"
sourcepath="${java.dir}"
destdir="${dist.javadocs}">
<classpath refid="project.class.path" />
<doclet name="com.sun.tools.doclets.standard.Standard">
<param name="-author"/>
<param name="-version"/>
<param name="-doctitle" value="${Name}"/>
<param name="-windowtitle" value="${Name} API"/>
<param name="-link"
value="http://java.sun.com/j2se/1.4/docs/api/"/>
<param name="-link"
value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
<param name="-link"
value="http://jakarta.apache.org/avalon/api/"/>
<param name="-bottom"
value=""Copyright © ${year} Apache Jakarta
Project. All Rights Reserved.""/>
</doclet>
</javadoc>
</target>
<target name="checkstyle" if="do.checkstyle" description="Checkstyle">
<!-- this invocation of checkstyle requires that checkstyle be
downloaded and setup -->
<!-- thats why you are required to define do.checkstyle property to
generate the report -->
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
<classpath refid="project.class.path"/>
</taskdef>
<checkstyle
lcurlyType="nl"
lcurlyMethod="nl"
lcurlyOther="nl"
rcurly="ignore"
allowProtected="false"
allowPackage="false"
allowNoAuthor="false"
maxLineLen="100"
maxMethodLen="100"
maxConstructorLen="100"
memberPattern="^m_[a-z][a-zA-Z0-9]*$"
staticPattern="^c_[a-z][a-zA-Z0-9]*$"
constPattern="(^c_[a-z][a-zA-Z0-9]*$)|([A-Z_]*$)"
ignoreImportLen="true"
allowTabs="false"
javadocScope="protected"
ignoreWhitespace="true"
cacheFile="checkstyle.cache"
failOnViolation="false"
ignoreCastWhitespace="true">
<fileset dir="${java.dir}">
<include name="**/*.java"/>
</fileset>
<formatter type="plain"/>
<formatter type="xml" toFile="build/checkstyle-results.xml"/>
</checkstyle>
</target>
<target name="checkstyle-report"
depends="checkstyle"
if="do.checkstyle"
description="Generate Checkstyle Report">
<mkdir dir="${build.reports}/checkstyle"/>
<property name="checkstyle.pathhack" location="."/>
<style style="../tools/etc/checkstyle-frames.xsl"
in="build/checkstyle-results.xml"
out="${build.reports}/checkstyle/delete-me.html">
<param name="pathhack" expression="${checkstyle.pathhack}"/>
</style>
</target>
<!-- Creates the distribution -->
<target name="dist"
depends="prepare-conf, jar, checkstyle-report, javadocs"
description="Generates the jar files">
<mkdir dir="${dist.dir}"/>
<copy file="${build.lib}/${dist.name}.jar" todir="${dist.dir}"/>
<copy file="${build.conf}/LICENSE.txt" todir="${dist.dir}"/>
<copy file="../KEYS" todir="${dist.dir}"/>
<copy file="README.txt" todir="${dist.dir}"/>
<mkdir dir="${dist.base}"/>
<zip zipfile="${dist.base}/${dist.name}-bin.zip" compress="true">
<zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
</zip>
<!--
Not supported by released ant but when it is we should enable this
across
all of the products
<tar longfile="gnu" tarfile="${dist.base}/${dist.name}-bin.tar">
<tarfileset dir="${dist.dir}"
prefix="${dist.name}"
username="avalon"
group="avalon"/>
</tar>
<gzip zipfile="${dist.base}/${dist.name}-bin.tar.gz"
src="${dist.name}-bin.tar"/>
<bzip2 zipfile="${dist.base}/${dist.name}-bin.tar.gz"
src="${dist.name}-bin.tar"/>
<delete file="${dist.base}/${dist.name}-bin.tar"/>
<checksum fileext=".md5">
<fileset dir="${dist.base}" />
</checksum>
-->
<delete dir="${dist.dir}" />
</target>
<!-- Cleans up build and distribution directories -->
<target name="clean" description="Cleans up the project">
<delete file="checkstyle.cache"/>
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete>
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
</delete>
</target>
<target name="real-clean" depends="clean" description="Cleans up the
project, including distributions">
<delete dir="${dist.base}" />
</target>
</project>
1.1 jakarta-ant-myrmidon/buildtools/project.properties
Index: project.properties
===================================================================
name=myrmidon-buildtools
Name=Myrmidon BuildTools
dir-name=api
version=1.0
package-version=0.99
year=2000-2002
1.1 jakarta-ant-myrmidon/buildtools/src/conf/MANIFEST.MF
Index: MANIFEST.MF
===================================================================
Manifest-Version: 1.0
Created-By: Apache Ant Project
Extension-Name: myrmidion.aut
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
Implementation-Vendor: Apache Software Foundation
Implementation-Version: @version@
1.1
jakarta-ant-myrmidon/buildtools/src/java/org/apache/myrmidon/build/AntDocSubTask.java
Index: AntDocSubTask.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.myrmidon.build;
import com.sun.javadoc.ClassDoc;
import java.io.File;
import java.net.URL;
import xdoclet.TemplateSubTask;
import xdoclet.XDocletException;
/**
* Generates the XML Documentation for Ant types (including tasks and
DataTypes).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/04/14 11:16:17 $
*/
public class AntDocSubTask
extends TemplateSubTask
{
public final static String SUBTASK_NAME = "antdoc";
private static final String GENERATED_FILE_NAME = "{0}.xml";
private static final String DEFAULT_TEMPLATE_FILE =
"/org/apache/myrmidon/build/type.j";
private File m_docsDestDir;
public AntDocSubTask()
{
setDestinationFile( GENERATED_FILE_NAME );
final URL resource = getClass().getResource( DEFAULT_TEMPLATE_FILE );
setTemplateURL( resource );
final TemplateSubTask.ExtentTypes extent = new
TemplateSubTask.ExtentTypes();
extent.setValue( "hierarchy" );
setExtent( extent );
}
/**
* Specifies the directory that is the destination of generated generated
* xml documentation for types.
*/
public void setDocsDestDir( final File docsDestDir )
{
m_docsDestDir = docsDestDir;
}
public String getSubTaskName()
{
return SUBTASK_NAME;
}
/**
* Called to validate configuration parameters.
*/
public void validateOptions()
throws XDocletException
{
super.validateOptions();
if( null == m_docsDestDir )
{
throw new XDocletException( "'docsDestDir' attribute is missing
." );
}
}
protected boolean matchesGenerationRules( final ClassDoc clazz )
throws XDocletException
{
if( !super.matchesGenerationRules( clazz ) )
{
return false;
}
else if( clazz.isAbstract() )
{
return false;
}
else
{
return true;
}
}
}
1.1
jakarta-ant-myrmidon/buildtools/src/java/org/apache/myrmidon/build/AntlibDescriptorTask.java
Index: AntlibDescriptorTask.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.myrmidon.build;
import java.io.File;
import java.util.Iterator;
import java.util.Vector;
import java.net.URL;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.UpToDate;
import org.apache.tools.ant.types.FileSet;
import xdoclet.DocletTask;
import xdoclet.TemplateSubTask;
/**
* A Task that generates Myrmidon Antlib descriptors from source files,
* using the XDoclet engine and "@ant:" tags.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Darrell DeBoer</a>
*/
public class AntlibDescriptorTask
extends DocletTask
{
private static final String DESCRIPTOR_TEMPLATE =
"/org/apache/myrmidon/build/ant-descriptor.j";
private static final String ROLES_TEMPLATE =
"/org/apache/myrmidon/build/ant-roles.j";
private TemplateSubTask m_antDocs;
private String m_libName;
private String m_descriptorFileName;
private String m_rolesFileName;
/**
* Specifies the Antlib name, which is used to name the generated files.
*/
public void setLibName( final String libName )
{
m_libName = libName;
}
/**
* Specifies the name of the file for the antlib types descriptor
(optional).
*/
public void setDescriptorName( final String descriptorFileName )
{
m_descriptorFileName = descriptorFileName;
}
/**
* Specifies the name of the file for the antlib roles descriptor
(optional).
*/
public void setRolesDescriptorName( final String rolesFileName )
{
m_rolesFileName = rolesFileName;
}
public void addAntdoc( final AntDocSubTask antDocs )
{
m_antDocs = antDocs;
}
public void execute() throws BuildException
{
// Add the base directories of all the filesets to the sourcepath
final Vector filesets = getFilesets();
for( int i = 0; i < filesets.size(); i++ )
{
final FileSet fileSet = (FileSet)filesets.elementAt(i );
final File basedir = fileSet.getDir( project );
createSourcepath().setLocation( basedir );
}
// Add template subtasks.
final TemplateSubTask descriptorTemplate =
makeTemplateSubTask( DESCRIPTOR_TEMPLATE, getDescriptorFileName()
);
addTemplate( descriptorTemplate );
final TemplateSubTask rolesTemplate =
makeTemplateSubTask( ROLES_TEMPLATE, getRolesFileName() );
addTemplate( rolesTemplate );
if( null != m_antDocs )
{
addTemplate( m_antDocs );
}
if( !upToDate() )
{
log( "Generating Antlib descriptors for: " + m_libName );
super.execute();
}
}
/**
* Creates a TemplateSubTask for a given template, which is read in
* as a resource.
*/
private TemplateSubTask makeTemplateSubTask( final String
templateLocation,
final String destinationFile
)
{
final TemplateSubTask templateSubTask = new TemplateSubTask();
final URL resource = getClass().getResource( templateLocation );
templateSubTask.setTemplateURL( resource );
templateSubTask.setDestinationFile( destinationFile );
return templateSubTask;
}
/**
* Checks if the descriptor file is up-to-date.
*/
private boolean upToDate()
{
// Use the UpToDate task to check if descriptors are up-to-date.
final UpToDate uptodateTask = (UpToDate)project.createTask(
"uptodate" );
final File destFile = new File( getDestDir(), getDescriptorFileName()
);
uptodateTask.setTargetFile( destFile );
final Iterator filesets = getFilesets().iterator();
while( filesets.hasNext() )
{
final FileSet fileSet = (FileSet)filesets.next();
uptodateTask.addSrcfiles( fileSet );
}
return uptodateTask.eval();
}
/**
* Return the filename for the antlib type descriptor. If not specified,
* the default filename is returned.
*/
private String getDescriptorFileName()
{
if( m_descriptorFileName == null )
{
return m_libName + "-ant-descriptor.xml";
}
else
{
return m_descriptorFileName;
}
}
/**
* Return the filename for the antlib roles descriptor. If not specified,
* the default filename is returned.
*/
private String getRolesFileName()
{
if( m_rolesFileName == null )
{
return m_libName + "-ant-roles.xml";
}
else
{
return m_rolesFileName;
}
}
}
1.1
jakarta-ant-myrmidon/buildtools/src/java/org/apache/myrmidon/build/AntlibJarTask.java
Index: AntlibJarTask.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.myrmidon.build;
import org.apache.tools.ant.taskdefs.Jar;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.ant.BuildException;
import java.io.File;
/**
* An Ant 1.x task to assemble a Myrmidon Antlib.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/04/14 11:16:17 $
*/
public class AntlibJarTask
extends Jar
{
private File m_roleDescriptor;
private File m_typeDescriptor;
private File m_serviceDescriptor;
public void setRolesDescriptor( final File roleDescriptor )
{
m_roleDescriptor = roleDescriptor;
}
public void setDescriptor( final File typeDescriptor )
{
m_typeDescriptor = typeDescriptor;
}
public void setServicesDescriptor( final File serviceDescriptor )
{
m_serviceDescriptor = serviceDescriptor;
}
public void execute() throws BuildException
{
maybeAddFile( m_roleDescriptor, "META-INF/ant-roles.xml" );
maybeAddFile( m_typeDescriptor, "META-INF/ant-descriptor.xml" );
maybeAddFile( m_serviceDescriptor, "META-INF/ant-services.xml" );
super.execute();
}
private void maybeAddFile( final File file, final String path )
{
if( file == null )
{
return;
}
if( ! file.isFile() )
{
throw new BuildException( "File \"" + file + "\" does not exist
or is not a file." );
}
// Create a ZipFileSet for this file, and pass it up.
final ZipFileSet fs = new ZipFileSet();
fs.setDir( file.getParentFile() );
fs.setIncludes( file.getName() );
fs.setFullpath( path );
addFileset( fs );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>