Author: mcconnell
Date: Sat Jul 3 05:40:01 2004
New Revision: 22498
Added:
avalon/trunk/planet/facilities/finder/impl/src/main/java/org/
avalon/trunk/planet/facilities/finder/impl/src/main/java/org/apache/
avalon/trunk/planet/facilities/finder/impl/src/main/java/org/apache/avalon/
avalon/trunk/planet/facilities/finder/impl/src/main/java/org/apache/avalon/finder/
avalon/trunk/planet/facilities/finder/impl/src/main/java/org/apache/avalon/finder/impl/
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
Modified:
avalon/trunk/build.xml
avalon/trunk/central/system/build/standard.xml
avalon/trunk/central/system/index.xml
avalon/trunk/planet/facilities/index.xml
avalon/trunk/runtime/index.xml
avalon/trunk/runtime/util/build.xml
avalon/trunk/tools/ (props changed)
avalon/trunk/tools/index.xml
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
Log:
Initial cut on a gump module generation task (after doing a "ant setup", invoke "ant gump" and take a look at the gump.xml output file.
Modified: avalon/trunk/build.xml
==============================================================================
--- avalon/trunk/build.xml (original)
+++ avalon/trunk/build.xml Sat Jul 3 05:40:01 2004
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="runtime" default="install" basedir="."
+<project name="avalon" default="install" basedir="."
xmlns:x="antlib:org.apache.avalon.tools">
<available property="magic.available" classname="org.apache.avalon.tools.model.Home"/>
@@ -43,6 +43,25 @@
#--------------------------------------------------------------------------------
</echo>
<fail message="Bootstrap resources not present."/>
+ </target>
+
+ <target name="gump">
+ <x:home/>
+ <x:gump name="Magic" description="Magic Test Module"
+ public="true" filename="gump.xml">
+ <x:url href="http://avalon.apache.org/magic"/>
+ <x:svn href="https://svn.apache.org/repos/asf/avalon/trunk"/>
+ <x:license file="central/system/license/LICENSE.TXT"/>
+ </x:gump>
+ </target>
+
+ <target name="execute">
+ <property name="gump.build-id" value="123456"/>
+ <property name="gump.target" value="runtime/composition/api"/>
+ <echo>BASDIR: ${basedir}</echo>
+ <echo>TARGET: ${gump.target}</echo>
+
+ <ant dir="." antfile="central/system/build/gump.xml" inheritrefs="false"/>
</target>
</project>
Modified: avalon/trunk/central/system/build/standard.xml
==============================================================================
--- avalon/trunk/central/system/build/standard.xml (original)
+++ avalon/trunk/central/system/build/standard.xml Sat Jul 3 05:40:01 2004
@@ -46,6 +46,8 @@
<target name="site" depends="javadoc,xdoc"/>
<target name="dist" depends="install,site"/>
+
+ <target name="gump" depends="install"/>
</project>
Modified: avalon/trunk/central/system/index.xml
==============================================================================
--- avalon/trunk/central/system/index.xml (original)
+++ avalon/trunk/central/system/index.xml Sat Jul 3 05:40:01 2004
@@ -16,6 +16,7 @@
<info>
<group>avalon</group>
<name>site</name>
+ <type>doc</type>
</info>
<dependencies>
<include key="avalon-runtime" runtime="false" build="false" test="false"/>
Modified: avalon/trunk/planet/facilities/index.xml
==============================================================================
--- avalon/trunk/planet/facilities/index.xml (original)
+++ avalon/trunk/planet/facilities/index.xml Sat Jul 3 05:40:01 2004
@@ -354,15 +354,6 @@
<resource>
<info>
<group>geronimo-spec</group>
- <name>geronimo-spec-jms</name>
- <version>DEV</version>
- <type>jar</type>
- </info>
- </resource>
-
- <resource>
- <info>
- <group>geronimo-spec</group>
<name>geronimo-spec-jta</name>
<version>DEV</version>
<type>jar</type>
Modified: avalon/trunk/runtime/index.xml
==============================================================================
--- avalon/trunk/runtime/index.xml (original)
+++ avalon/trunk/runtime/index.xml Sat Jul 3 05:40:01 2004
@@ -46,6 +46,15 @@
</info>
</resource>
+ <resource>
+ <info>
+ <group>geronimo-spec</group>
+ <name>geronimo-spec-jms</name>
+ <version>DEV</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
<!--
Avalon LogKit.
-->
@@ -57,11 +66,10 @@
<version>2.0.0</version>
</info>
<dependencies>
- <include key="avalonx-supplemental" build="false" test="false"/>
+ <include key="mailapi" runtime="false"/>
<include key="log4j" runtime="false"/>
<include key="servletapi" runtime="false"/>
- <include key="mailapi" runtime="false"/>
- <include key="jms" runtime="false"/>
+ <include key="geronimo-spec-jms" runtime="false"/>
</dependencies>
</project>
@@ -766,6 +774,7 @@
<group>avalon</group>
<name>runtime</name>
<version>3.3.1</version>
+ <type>doc</type>
<status>SNAPSHOT</status>
</info>
<dependencies>
@@ -789,7 +798,7 @@
<include key="log4j" runtime="false"/>
<include key="servletapi"/>
<include key="mailapi"/>
- <include key="jms"/>
+ <include key="geronimo-spec-jms"/>
</dependencies>
</project>
Modified: avalon/trunk/runtime/util/build.xml
==============================================================================
--- avalon/trunk/runtime/util/build.xml (original)
+++ avalon/trunk/runtime/util/build.xml Sat Jul 3 05:40:01 2004
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="test" default="install" basedir="." xmlns:x="antlib:org.apache.avalon.tools">
+<project name="avalon-util" default="install" basedir="." xmlns:x="antlib:org.apache.avalon.tools">
<property file="build.properties"/>
<import file="${project.system}/build/reactor.xml"/>
Modified: avalon/trunk/tools/index.xml
==============================================================================
--- avalon/trunk/tools/index.xml (original)
+++ avalon/trunk/tools/index.xml Sat Jul 3 05:40:01 2004
@@ -46,6 +46,7 @@
<info>
<group>avalon/tools</group>
<name>avalon-tools-magic</name>
+ <type>jar</type>
</info>
<dependencies>
<include key="ant"/>
@@ -59,6 +60,7 @@
Avalon eXternal Supplemental.
-->
+ <!--
<project basedir="supplemental">
<info>
<group>avalonx/supplemental</group>
@@ -66,6 +68,7 @@
<version>1.0</version>
</info>
</project>
+ -->
<resource>
<info>
@@ -74,15 +77,9 @@
<version>1.3.1</version>
<type>jar</type>
</info>
- </resource>
-
- <resource>
- <info>
- <group>avalonx/supplemental</group>
- <name>jms</name>
- <version>1.1</version>
- <type>jar</type>
- </info>
+ <gump>
+ <alias>javamail</alias>
+ </gump>
</resource>
</index>
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml Sat Jul 3 05:40:01 2004
@@ -22,6 +22,7 @@
<taskdef name="property" classname="org.apache.avalon.tools.tasks.PropertyTask"/>
<taskdef name="replicate" classname="org.apache.avalon.tools.tasks.ReplicateTask"/>
<taskdef name="block" classname="org.apache.avalon.tools.tasks.BlockTask"/>
+ <taskdef name="gump" classname="org.apache.avalon.tools.tasks.GumpTask"/>
<typedef name="path" classname="org.apache.avalon.tools.model.MagicPath"/>
</antlib>
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java Sat Jul 3 05:40:01 2004
@@ -31,15 +31,22 @@
{
private ResourceRef[] m_plugins;
private File m_basedir;
+ private String m_path;
public Definition(
- final Home home, final String key, final File basedir, final Info info,
- final ResourceRef[] resources, final ResourceRef[] plugins )
+ final Home home, final String key, final File basedir, final String path, final Info info,
+ final Gump gump, final ResourceRef[] resources, final ResourceRef[] plugins )
{
- super( home, key, info, resources );
+ super( home, key, info, gump, resources );
m_basedir = basedir;
m_plugins = plugins;
+ m_path = path;
+ }
+
+ public String getBasePath()
+ {
+ return m_path;
}
public File getBaseDir()
Added: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java Sat Jul 3 05:40:01 2004
@@ -0,0 +1,46 @@
+/*
+ * 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 org.apache.avalon.tools.model;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Project info.
+ *
+ * @author <a href="mailto:[email protected]">Avalon Development Team</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class Gump
+{
+ public static final Gump NULL_GUMP = new Gump( null );
+
+ private String m_alias;
+
+ public Gump( final String alias )
+ {
+ m_alias = alias;
+ }
+
+ /**
+ * Gump alias name.
+ */
+ public String getAlias()
+ {
+ return m_alias;
+ }
+}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java Sat Jul 3 05:40:01 2004
@@ -42,7 +42,7 @@
}
final String protocol = id.substring( 0, i );
final String spec = id.substring( i+1 );
- return Info.create( protocol, spec);
+ return Info.create( protocol, spec );
}
public static Info create( final String type, final String id )
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java Sat Jul 3 05:40:01 2004
@@ -31,11 +31,11 @@
private final ListenerDef[] m_listeners;
public Plugin(
- final Home home, final String key, final File basedir, final Info info,
- final ResourceRef[] resources, final ResourceRef[] plugins,
+ final Home home, final String key, final File basedir, final String path, final Info info,
+ final Gump gump, final ResourceRef[] resources, final ResourceRef[] plugins,
final TaskDef[] tasks, final ListenerDef[] listeners )
{
- super( home, key, basedir, info, resources, plugins );
+ super( home, key, basedir, path, info, gump, resources, plugins );
m_tasks = tasks;
m_listeners = listeners;
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java Sat Jul 3 05:40:01 2004
@@ -40,21 +40,28 @@
private final String m_key;
private Info m_info;
+ private Gump m_gump;
private ResourceRef[] m_resources;
private Home m_home;
public Resource( final Home home, final Info info )
{
- this( home, null, info, EMPTY_REFS );
+ this( home, null, info, Gump.NULL_GUMP, EMPTY_REFS );
}
public Resource(
- final Home home, final String key, final Info info, final ResourceRef[] resources )
+ final Home home, final String key, final Info info, Gump gump, final ResourceRef[] resources )
{
m_key = key;
m_info = info;
m_resources = resources;
m_home = home;
+ m_gump = gump;
+ }
+
+ public Gump getGump()
+ {
+ return m_gump;
}
public String getKey()
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java Sat Jul 3 05:40:01 2004
@@ -45,9 +45,12 @@
final Info info =
createInfo( ElementHelper.getChild( element, "info" ) );
+ final Gump gump =
+ createGump( ElementHelper.getChild( element, "gump" ) );
final String key = getDefinitionKey( element, info );
- final File basedir = getBasedir( anchor, element );
+ final String path = element.getAttribute( "basedir" );
+ final File basedir = getBasedir( anchor, path );
final ResourceRef[] resources =
createResourceRefs(
@@ -60,7 +63,7 @@
if( tag.equals( "project" ) )
{
return new Definition(
- home, key, basedir, info, resources, plugins );
+ home, key, basedir, path, info, gump, resources, plugins );
}
else if( tag.equals( "plugin" ) )
{
@@ -70,7 +73,7 @@
getListenerDefs(
ElementHelper.getChild( element, "listeners" ) );
return new Plugin(
- home, key, basedir, info, resources, plugins,
+ home, key, basedir, path, info, gump, resources, plugins,
tasks, listeners );
}
else
@@ -85,22 +88,27 @@
{
final Info info =
createInfo( ElementHelper.getChild( element, "info" ) );
+ final Gump gump =
+ createGump( ElementHelper.getChild( element, "gump" ) );
final String key = getDefinitionKey( element, info );
final ResourceRef[] resources =
createResourceRefs(
ElementHelper.getChild( element, "dependencies" ) );
- return new Resource( home, key, info, resources );
+ return new Resource( home, key, info, gump, resources );
}
public static Definition createDefinition( final Home home, final Element element, final File anchor )
{
final Info info =
createInfo( ElementHelper.getChild( element, "info" ) );
+ final Gump gump =
+ createGump( ElementHelper.getChild( element, "gump" ) );
final String key = getDefinitionKey( element, info );
- final File basedir = getBasedir( anchor, element );
+ final String path = element.getAttribute( "basedir" );
+ final File basedir = getBasedir( anchor, path );
final ResourceRef[] resources =
createResourceRefs(
@@ -114,7 +122,7 @@
if( tag.equals( "project" ) )
{
return new Definition(
- home, key, basedir, info, resources, plugins );
+ home, key, basedir, path, info, gump, resources, plugins );
}
else if( tag.equals( "plugin" ) )
{
@@ -123,7 +131,7 @@
final ListenerDef[] listeners =
getListenerDefs( ElementHelper.getChild( element, "listeners" ) );
return new Plugin(
- home, key, basedir, info, resources, plugins, tasks, listeners );
+ home, key, basedir, path, info, gump, resources, plugins, tasks, listeners );
}
else
{
@@ -160,9 +168,8 @@
return refs;
}
- private static File getBasedir( final File anchor, final Element element )
+ private static File getBasedir( final File anchor, final String path )
{
- final String path = element.getAttribute( "basedir" );
if( null == path )
{
final String error =
@@ -226,6 +233,14 @@
{
return new Info( group, name, version, type, false );
}
+ }
+
+ public static Gump createGump( final Element info )
+ {
+ final String alias =
+ ElementHelper.getValue(
+ ElementHelper.getChild( info, "alias" ) );
+ return new Gump( alias );
}
private static ResourceRef[] createResourceRefs( final Element element )
Added: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java Sat Jul 3 05:40:01 2004
@@ -0,0 +1,487 @@
+/*
+ * 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 org.apache.avalon.tools.tasks;
+
+import org.apache.avalon.tools.model.Definition;
+import org.apache.avalon.tools.model.ResourceRef;
+import org.apache.avalon.tools.model.Info;
+import org.apache.avalon.tools.model.Resource;
+import org.apache.avalon.tools.model.Plugin.ListenerDef;
+import org.apache.avalon.tools.model.Plugin.TaskDef;
+import org.apache.avalon.tools.model.Plugin;
+import org.apache.avalon.tools.model.Policy;
+import org.apache.avalon.tools.model.Home;
+import org.apache.avalon.tools.model.Context;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Create meta-data for a block.
+ *
+ * @author <a href="mailto:[email protected]">Avalon Development Team</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class GumpTask extends SystemTask
+{
+ public static class Href
+ {
+ private String m_href;
+
+ public void setHref( String href )
+ {
+ m_href = href;
+ }
+
+ public String getHref()
+ {
+ return m_href;
+ }
+ }
+
+ public static class FileHolder
+ {
+ private String m_file;
+
+ public void setFile( String file )
+ {
+ m_file = file;
+ }
+
+ public String getFile()
+ {
+ return m_file;
+ }
+ }
+
+ public static class License extends FileHolder
+ {
+ }
+
+ public static class Template extends FileHolder
+ {
+ private String m_target = "gump";
+
+ public void setTarget( String target )
+ {
+ m_target = target;
+ }
+
+ public String getTarget()
+ {
+ return m_target;
+ }
+ }
+
+ public static class Url extends Href
+ {
+ }
+
+ public static class Cvs extends Href
+ {
+ }
+
+ public static class Svn extends Href
+ {
+ }
+
+ private String m_name;
+ private String m_filename;
+ private String m_description;
+ private Url m_url;
+ private Cvs m_cvs;
+ private Svn m_svn;
+ private License m_license;
+ private Template m_template = new Template();
+ private boolean m_public = false;
+
+ public void setName( String name )
+ {
+ m_name = name;
+ }
+
+ public void setFilename( String filename )
+ {
+ m_filename = filename;
+ }
+
+ public void setDescription( String description )
+ {
+ m_description = description;
+ }
+
+ public void setPublic( boolean flag )
+ {
+ m_public = flag;
+ }
+
+ public Url createUrl()
+ {
+ if( null == m_url )
+ {
+ m_url = new Url();
+ return m_url;
+ }
+ else
+ {
+ throw new BuildException( "Multiple url entries not allowed." );
+ }
+ }
+
+ public Svn createSvn()
+ {
+ if( null == m_svn )
+ {
+ if( null == m_cvs )
+ {
+ m_svn = new Svn();
+ return m_svn;
+ }
+ else
+ {
+ throw new BuildException( "Cannot declare both cvs and svn." );
+ }
+ }
+ else
+ {
+ throw new BuildException( "Multiple svn entries not allowed." );
+ }
+ }
+
+ public Cvs createCvs()
+ {
+ if( null == m_cvs )
+ {
+ if( null == m_cvs )
+ {
+ m_cvs = new Cvs();
+ return m_cvs;
+ }
+ else
+ {
+ throw new BuildException( "Cannot declare both cvs and svn." );
+ }
+ }
+ else
+ {
+ throw new BuildException( "Multiple cvs entries not allowed." );
+ }
+ }
+
+ public License createLicense()
+ {
+ if( null == m_license )
+ {
+ m_license = new License();
+ return m_license;
+ }
+ else
+ {
+ throw new BuildException( "Multiple license entries not allowed." );
+ }
+ }
+
+ public Template createTemplate()
+ {
+ return m_template;
+ }
+
+
+ private File getFile()
+ {
+ if( null != m_filename )
+ {
+ final Project project = getProject();
+ return Context.getFile( project.getBaseDir(), m_filename );
+ }
+ else
+ {
+ return new File( getContext().getDeliverablesDirectory(), "gump.xml" );
+ }
+ }
+
+ public void execute()
+ {
+ try
+ {
+ final File file = getFile();
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ final OutputStream output = new FileOutputStream( file );
+ final Writer writer = new OutputStreamWriter( output );
+
+ try
+ {
+ writeHeader( writer );
+ writeModule( writer );
+ writer.flush();
+ }
+ finally
+ {
+ closeStream( output );
+ }
+ }
+ catch( Throwable e )
+ {
+ throw new BuildException( e );
+ }
+ }
+
+ private String getName()
+ {
+ if( null != m_name )
+ {
+ return m_name;
+ }
+ else
+ {
+ return getProject().getName();
+ }
+ }
+
+ protected void writeModule( final Writer writer )
+ throws IOException
+ {
+ Home home = getHome();
+ Project project = getProject();
+ String name = getName();
+
+ writer.write( "\n\n<module name=\"" + name + "\">" );
+ writer.write( "\n\n <url href=\"" + m_url.getHref() + "\"/>" );
+
+ if( null != m_description )
+ {
+ writer.write( "\n <description>" );
+ writer.write( m_description );
+ writer.write( "</description>" );
+ }
+
+ if( null != m_svn )
+ {
+ writer.write( "\n <svn href=\"" + m_svn.getHref() + "\"/>" );
+ }
+ else if( null != m_svn )
+ {
+ writer.write( "\n <cvs href=\"" + m_cvs.getHref() + "\"/>" );
+ }
+
+ Definition[] definitions = home.getDefinitions();
+ for( int i=0; i<definitions.length; i++ )
+ {
+ Definition def = definitions[i];
+ writeProject( writer, def );
+ }
+
+ writer.write( "\n\n</module>\n" );
+ }
+
+ /**
+ * Write the XML header.
+ * @param writer the writer
+ * @throws IOException if unable to write xml
+ */
+ private void writeHeader( final Writer writer )
+ throws IOException
+ {
+ writer.write( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" );
+ writer.write( "\n" );
+ writer.write( "\n<!--" );
+ writer.write( "\n#" );
+ writer.write( "\n# Copyright 2004 Apache Software Foundation " );
+ writer.write( "\n# Licensed under the Apache License, Version 2.0 (the \"License\"); " );
+ writer.write( "\n# you may not use this file except in compliance with the License. " );
+ writer.write( "\n# You may obtain a copy of the License at " );
+ writer.write( "\n# " );
+ writer.write( "\n# http://www.apache.org/licenses/LICENSE-2.0 " );
+ writer.write( "\n# " );
+ writer.write( "\n# Unless required by applicable law or agreed to in writing, software " );
+ writer.write( "\n# distributed under the License is distributed on an \"AS IS\" BASIS, " );
+ writer.write( "\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or " );
+ writer.write( "\n# implied. " );
+ writer.write( "\n# " );
+ writer.write( "\n# See the License for the specific language governing permissions and " );
+ writer.write( "\n# limitations under the License. " );
+ writer.write( "\n# " );
+ writer.write( "\n# NOTE: The content of this file is automatically generated by Magic." );
+ writer.write( "\n# http://avalon.apache.org/" );
+ writer.write( "\n#" );
+ writer.write( "\n-->" );
+ writer.write( "\n" );
+ }
+
+ /**
+ * Write the XML project definition.
+ * @param writer the writer
+ * @param definition the project definition
+ * @throws IOException if unable to write xml
+ */
+ private void writeProject( final Writer writer, Definition definition )
+ throws IOException
+ {
+ String path = definition.getBaseDir().getCanonicalPath();
+ int j = getProject().getBaseDir().toString().length();
+ String basedir = path.substring( j+1 ).replace( '\\', '/' );
+
+ writer.write(
+ "\n\n <project name=\"" + definition.getKey() + "\">" );
+
+ if( null != m_license )
+ {
+ String license = m_license.getFile();
+ writer.write(
+ "\n <license name=\"" + license + "\"/>" );
+ }
+
+ final ResourceRef[] refs =
+ definition.getResourceRefs( Policy.ANY, ResourceRef.ANY, true );
+
+ String template = m_template.getFile();
+ String target = m_template.getTarget();
+
+ writer.write(
+ "\n <ant basedir=\"" + basedir + "\"" );
+ if( null != template )
+ {
+ writer.write(
+ "\n buildfile=\"" + template + "\"" );
+ }
+ if( null != target )
+ {
+ writer.write(
+ " target=\"" + target + "\"" );
+ }
+ writer.write( ">" );
+
+ writer.write(
+ "\n <!-- for magic -->" );
+ writer.write(
+ "\n <property name=\"gump.signature\" value=\"@@DATE@@\"/>" );
+
+ boolean flag = false;
+ for( int i=0; i<refs.length; i++ )
+ {
+ Resource resource = getHome().getResource( refs[i] );
+ if( !(resource instanceof Definition) )
+ {
+ if( !flag )
+ {
+ flag = true;
+ writer.write(
+ "\n <!-- external references -->" );
+ }
+ String key = resource.getKey();
+ String alias = getKeyForResource( resource );
+ writer.write(
+ "\n <depend property=\"gump.resource." + key
+ + "\" project=\"" + alias
+ + "\"/>" );
+ }
+ }
+
+ writer.write( "\n <!-- end for -->" );
+
+ flag = false;
+ writer.write( "\n </ant>" );
+ for( int i=0; i<refs.length; i++ )
+ {
+ Resource resource = getHome().getResource( refs[i] );
+ if( resource instanceof Definition )
+ {
+ if( !flag )
+ {
+ flag = true;
+ writer.write( "\n <!-- for gump -->" );
+ }
+ String key = resource.getKey();
+ writer.write(
+ "\n <depend project=\"" + key + "\"/>" );
+ }
+ }
+
+ if( flag )
+ {
+ writer.write( "\n <!-- end for -->" );
+ }
+
+ writer.write(
+ "\n <home nested=\""
+ + basedir + "/target/deliverables\"/>" );
+
+ String name = definition.getInfo().getName();
+ String type = definition.getInfo().getType();
+ if( "jar".equals( type ) || "bar".equals( type ) )
+ {
+ writer.write(
+ "\n <jar name=\"" + type + "s/"
+ + name + "-@@DATE@@.jar\"/>" );
+ }
+ if( "plugin".equals( type ) )
+ {
+ writer.write(
+ "\n <jar name=\"jars/"
+ + name + "-@@DATE@@.jar\"/>" );
+ }
+ else if( "doc".equals( type ) )
+ {
+ writer.write(
+ "\n <!-- doc output is relative to the module root -->" );
+ }
+
+ writer.write( "\n <nag to=\"[email protected]\"" );
+ writer.write( "\n from=\"Magic Integration <[email protected]>\"/>" );
+
+ writer.write( "\n </project>" );
+ }
+
+ private String getKeyForResource( Resource resource )
+ {
+ final String alias = resource.getGump().getAlias();
+ if( null != alias )
+ {
+ return alias;
+ }
+ else
+ {
+ return resource.getKey();
+ }
+ }
+
+ private void closeStream( final OutputStream output )
+ {
+ if( null != output )
+ {
+ try
+ {
+ output.close();
+ }
+ catch( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.