Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1515 - in development/main/magic/core/src/main/net/dpml/magic: . project tasks

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1515 - in development/main/magic/core/src/main/net/dpml/magic: . project tasks
  • Date: Mon, 17 Jan 2005 13:22:20 +0100

Author: mcconnell
Date: Mon Jan 17 13:22:20 2005
New Revision: 1515

Added:
development/main/magic/core/src/main/net/dpml/magic/tasks/BarTask.java
Modified:
development/main/magic/core/src/main/net/dpml/magic/plugin.xml

development/main/magic/core/src/main/net/dpml/magic/project/DeliverableHelper.java
Log:
Add the bar task to the core set of tasks and update the BarTask
impolementation to hold a repository root structure (i.e. unpack it and you
have a local host).

Modified: development/main/magic/core/src/main/net/dpml/magic/plugin.xml
==============================================================================
--- development/main/magic/core/src/main/net/dpml/magic/plugin.xml
(original)
+++ development/main/magic/core/src/main/net/dpml/magic/plugin.xml Mon
Jan 17 13:22:20 2005
@@ -5,6 +5,7 @@
<typedef name="path" classname="net.dpml.magic.project.ProjectPath"/>

<!-- taskdefs -->
+ <taskdef name="bar" classname="net.dpml.magic.tasks.BarTask"/>
<taskdef name="block" classname="net.dpml.magic.tasks.BlockTask"/>
<taskdef name="clean" classname="net.dpml.magic.tasks.CleanTask"/>
<taskdef name="export" classname="net.dpml.magic.tasks.ExportTask"/>

Modified:
development/main/magic/core/src/main/net/dpml/magic/project/DeliverableHelper.java
==============================================================================
---
development/main/magic/core/src/main/net/dpml/magic/project/DeliverableHelper.java
(original)
+++
development/main/magic/core/src/main/net/dpml/magic/project/DeliverableHelper.java
Mon Jan 17 13:22:20 2005
@@ -65,7 +65,7 @@
* Creation of an ASC signature relative to a supplied file. If a
[filename].asc
* exists it will be deleted and recreated relative to the supplied file
content.
* The ASC signature will be generated using the executable assigned to
the property
- * Home.GPG_EXE_KEY.
+ * Context.GPG_EXE_KEY.
*
* @param task the task creating the file
* @param file the file to sign

Added: development/main/magic/core/src/main/net/dpml/magic/tasks/BarTask.java
==============================================================================
--- (empty file)
+++ development/main/magic/core/src/main/net/dpml/magic/tasks/BarTask.java
Mon Jan 17 13:22:20 2005
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * 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.magic.tasks;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+import net.dpml.magic.model.Definition;
+import net.dpml.magic.project.Context;
+import net.dpml.magic.project.DeliverableHelper;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Jar;
+import org.apache.tools.ant.taskdefs.Manifest;
+import org.apache.tools.ant.taskdefs.ManifestException;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.ZipFileSet;
+
+import java.io.File;
+
+/**
+ * Create a block archive.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class BarTask extends ProjectTask
+{
+ public static final String BAR_EXT = "bar";
+
+ private List m_zipFilesets = new LinkedList();
+
+ private List m_filesets = new LinkedList();
+
+ private boolean m_classic = true;
+
+ public void addZipFileset( ZipFileSet set )
+ {
+ m_zipFilesets.add( set );
+ }
+
+ public void addFileset( FileSet set )
+ {
+ m_filesets.add( set );
+ }
+
+ private void setClassic( boolean flag )
+ {
+ m_classic = flag;
+ }
+
+ public void execute() throws BuildException
+ {
+ final String filename = getDefinition().getFilename( BAR_EXT );
+ final File deliverables = getContext().getDeliverablesDirectory() ;
+
+ if( isContent() )
+ {
+ bar( filename );
+ }
+ }
+
+ private boolean isContent()
+ {
+ if( m_classic && getContext().getDeliverablesDirectory().exists() )
+ {
+ return true;
+ }
+ else if( m_filesets.size() > 0 )
+ {
+ return true;
+ }
+ else if( m_zipFilesets.size() > 0 )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private void bar( final String filename )
+ {
+ final File deliverables = getContext().getDeliverablesDirectory();
+ final File bars= new File( deliverables, BAR_EXT + "s" );
+ final File bar = new File( bars, filename );
+ long modified = -1;
+ if( bar.exists() )
+ {
+ modified = bar.lastModified();
+ }
+
+ final Jar jar = (Jar) getProject().createTask( "jar" );
+ jar.setTaskName( getTaskName() );
+ jar.setDestFile( bar );
+ jar.setIndex( true );
+ addManifest( jar );
+ log( "creating: " + bar );
+ bars.mkdirs();
+
+ if( m_classic )
+ {
+ final String path = BAR_EXT + "s/" + filename;
+ final FileSet fileset = new FileSet();
+ fileset.setDir( deliverables );
+ fileset.createInclude().setName( "**/*" );
+ fileset.createExclude().setName( "**/" + BAR_EXT + "s" );
+ ZipFileSet deliverablesSet = new BarZipFileSet( fileset );
+ deliverablesSet.setPrefix( getDefinition().getInfo().getGroup()
);
+ jar.addZipfileset( deliverablesSet );
+ }
+
+ Iterator zipIterator = m_zipFilesets.iterator();
+ while( zipIterator.hasNext() )
+ {
+ ZipFileSet set = (ZipFileSet) zipIterator.next();
+ jar.addZipfileset( set );
+ }
+
+ Iterator filesetIterator = m_filesets.iterator();
+ while( filesetIterator.hasNext() )
+ {
+ FileSet set = (FileSet) filesetIterator.next();
+ jar.addFileset( set );
+ }
+
+ jar.init();
+ jar.execute();
+
+ if( bar.lastModified() > modified )
+ {
+ DeliverableHelper.checksum( this, bar );
+ String gpg = getIndex().getProperty( Context.GPG_EXE_KEY );
+ DeliverableHelper.asc( this, bar, gpg );
+ }
+ }
+
+ private void addManifest( final Jar jar )
+ {
+ Definition def = getDefinition();
+ try
+ {
+ final Manifest manifest = new Manifest();
+ final Manifest.Section main = manifest.getMainSection();
+ addAttribute( main, "Created-By", "The Digital Product Meta
Library" );
+ addAttribute( main, "Built-By", System.getProperty( "user.name"
) );
+
+ final Manifest.Section block = new Manifest.Section();
+ block.setName( "Block" );
+ addAttribute( block, "Block-Key", def.getKey() );
+ addAttribute( block, "Block-Group", def.getInfo().getGroup() );
+ addAttribute( block, "Block-Name", def.getInfo().getName() );
+ if( null != def.getInfo().getVersion() )
+ {
+ addAttribute(
+ block,
+ "Block-Version",
+ def.getInfo().getVersion() );
+ }
+
+ manifest.addConfiguredSection( block );
+ jar.addConfiguredManifest( manifest );
+ }
+ catch( Throwable e )
+ {
+ throw new BuildException( e );
+ }
+ }
+
+ private void addAttribute(
+ final Manifest.Section section, final String name, final String value )
+ throws ManifestException
+ {
+ final Manifest.Attribute attribute = new Manifest.Attribute( name,
value );
+ section.addConfiguredAttribute( attribute );
+ }
+
+ private static class BarZipFileSet extends ZipFileSet
+ {
+ private BarZipFileSet( FileSet set )
+ {
+ super( set );
+ }
+ }
+}



  • svn commit: r1515 - in development/main/magic/core/src/main/net/dpml/magic: . project tasks, mcconnell, 01/17/2005

Archive powered by MHonArc 2.6.24.

Top of Page