avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 20812 - in avalon/trunk/tools/project/core/src: main/org/apache/avalon/tools/home main/org/apache/avalon/tools/tasks test test/projects/demo test/projects/gizmo test/projects/sample test/projects/widget
Date Fri, 04 Jun 2004 05:40:57 GMT
Author: mcconnell
Date: Thu Jun  3 22:40:56 2004
New Revision: 20812

Added:
   avalon/trunk/tools/project/core/src/test/projects/demo/build.properties
   avalon/trunk/tools/project/core/src/test/projects/sample/build.properties
   avalon/trunk/tools/project/core/src/test/projects/widget/build.properties
   avalon/trunk/tools/project/core/src/test/standard.xml
Modified:
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java
   avalon/trunk/tools/project/core/src/test/projects/demo/build.xml
   avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties
   avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml
   avalon/trunk/tools/project/core/src/test/projects/sample/build.xml
   avalon/trunk/tools/project/core/src/test/projects/widget/build.xml
Log:
Update examples to take advantage of ant import and task overriding.

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java	Thu
Jun  3 22:40:56 2004
@@ -242,7 +242,7 @@
         props.execute();
     }
 
-    private File getFile( File root, String path )
+    public static File getFile( File root, String path )
     {
         File file = new File( path );
         if( file.isAbsolute() ) return file;

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java	Thu Jun
 3 22:40:56 2004
@@ -69,11 +69,15 @@
     //-------------------------------------------------------------
 
     public static final String KEY = "project.home";
+    public static final String HOME_KEY = "project.home";
 
     //-------------------------------------------------------------
     // mutable state
     //-------------------------------------------------------------
 
+    private boolean m_init = false;
+    private Context m_context;
+
     private String m_id;
     private String m_key;
 
@@ -116,20 +120,59 @@
     }
 
     //-------------------------------------------------------------
-    // internal
+    // Task
     //-------------------------------------------------------------
 
+    public void init() throws BuildException 
+    {
+        if( !m_init )
+        {
+            Project project = getProject();
+            m_context = Context.getContext( project );
+            m_init = true;
+        }
+    }
+
     public void execute()
     {
+        Project project = getProject();
+
         if( null == m_file )
         {
-            final String error = 
-              "Cannot continue due to missing index attribute in task defintion [" 
-              + getTaskName() + "].";
-            throw new BuildException( error );
+            String path = project.getProperty( HOME_KEY );
+            if( null != path )
+            {
+                File index = Context.getFile( project.getBaseDir(), path );
+                if( index.exists() )
+                {
+                    if( index.isDirectory() )
+                    {
+                        m_file = new File( index, "index.xml" );
+                    }
+                    else
+                    {
+                        m_file = index;
+                    }
+                }
+                else
+                {
+                    final String error = 
+                      "Property value 'project.home' in task defintion [" 
+                      + getTaskName() 
+                      + "] references a non-existant file: "
+                      + index;
+                    throw new BuildException( error );
+                }
+            }
+            else
+            {
+                final String error = 
+                  "Cannot continue due to missing index attribute in task defintion [" 
+                  + getTaskName() + "].";
+                throw new BuildException( error );
+            }
         }
 
-        Project project = getProject();
         if( null == m_id )
         {
             project.addReference( KEY, this );
@@ -140,9 +183,10 @@
         }
 
         m_system = m_file.getParentFile();
-        Element root = ElementHelper.getRootElement( m_file );
         m_project.log( "home: " + m_system, Project.MSG_DEBUG );
 
+
+        Element root = ElementHelper.getRootElement( m_file );
         final Element repo = ElementHelper.getChild( root, "repository" );
         final Element resources = ElementHelper.getChild( root, "resources" );
         final Element projects = ElementHelper.getChild( root, "projects" );
@@ -371,15 +415,4 @@
         }
         return repository;
     }
-
-    /*
-    private static void setHomeReference( Project project )
-    {
-        if( null == HOME ) throw new IllegalStateException( "home" );
-        if( null == project.getReference( "urn:project.home" ) )
-        {
-            project.addReference( "urn:project.home", HOME );
-        }
-    }
-    */
 }

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java	Thu
Jun  3 22:40:56 2004
@@ -43,7 +43,7 @@
     public static final String XDOC_RESOURCES_VALUE = "resources";
 
     public static final String XDOC_THEME_KEY = "project.xdoc.theme";
-    public static final String XDOC_THEME_VALUE = "avalon2";
+    public static final String XDOC_THEME_VALUE = "modern";
 
     public static final String XDOC_FORMAT_KEY = "project.xdoc.output.format";
     public static final String XDOC_FORMAT_VALUE = "html";

Added: avalon/trunk/tools/project/core/src/test/projects/demo/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/test/projects/demo/build.properties	Thu Jun  3 22:40:56
2004
@@ -0,0 +1,2 @@
+project.home = ../..
+project.gpg.exe = gpg
\ No newline at end of file

Modified: avalon/trunk/tools/project/core/src/test/projects/demo/build.xml
==============================================================================
--- avalon/trunk/tools/project/core/src/test/projects/demo/build.xml	(original)
+++ avalon/trunk/tools/project/core/src/test/projects/demo/build.xml	Thu Jun  3 22:40:56 2004
@@ -1,32 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
 
-<project name="my-demo" default="install" basedir="." 
+<project name="demo" default="dist" basedir="." 
     xmlns:x="antlib:org.apache.avalon.tools">
 
-  <x:home index="../../index.xml" key="demo"/>
+  <property file="build.properties"/>
+  <import file="${project.home}/standard.xml"/>
 
-  <target name="clean">
-    <x:clean/>
-  </target>
-
-  <target name="prepare" depends="">
-    <x:prepare/>
-  </target>
-
-  <target name="build" depends="prepare">
+  <target name="build" depends="standard.build">
     <x:declare/>
-    <x:javac/>
-  </target>
-
-  <target name="package" depends="build">
-    <x:jar/>
-  </target>
-
-  <target name="test" depends="package">
-    <x:junit/>
-  </target>
-
-  <target name="install" depends="test">
-    <x:install/>
   </target>
 
 </project>

Modified: avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties
==============================================================================
--- avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties	(original)
+++ avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties	Thu Jun  3 22:40:56
2004
@@ -1,4 +1,2 @@
-#avalon.target = targetx
-
-project.index = ../../index.xml
+project.home = ../..
 project.gpg.exe = gpg

Modified: avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml
==============================================================================
--- avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml	(original)
+++ avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml	Thu Jun  3 22:40:56
2004
@@ -1,31 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
 
-<project name="gizmo" default="install" basedir="." 
-    xmlns:x="antlib:org.apache.avalon.tools">
+<project name="gizmo" default="dist" basedir=".">
 
-  <x:home index="../../index.xml"/>
+  <property file="build.properties"/>
+  <import file="${project.home}/standard.xml"/>
 
-  <target name="clean">
-    <x:clean/>
-  </target>
-
-  <target name="prepare" depends="">
-    <x:prepare/>
-  </target>
-
-  <target name="build" depends="prepare">
-    <x:javac/>
-  </target>
-
-  <target name="package" depends="build">
-    <x:jar/>
-  </target>
-
-  <target name="test" depends="package">
-    <x:junit/>
-  </target>
-
-  <target name="install" depends="test">
-    <x:install/>
-  </target>
-
-</project>
+</project>
\ No newline at end of file

Added: avalon/trunk/tools/project/core/src/test/projects/sample/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/test/projects/sample/build.properties	Thu Jun  3 22:40:56
2004
@@ -0,0 +1,2 @@
+project.home = ../..
+project.gpg.exe = gpg
\ No newline at end of file

Modified: avalon/trunk/tools/project/core/src/test/projects/sample/build.xml
==============================================================================
--- avalon/trunk/tools/project/core/src/test/projects/sample/build.xml	(original)
+++ avalon/trunk/tools/project/core/src/test/projects/sample/build.xml	Thu Jun  3 22:40:56
2004
@@ -1,35 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
 
-<project name="sample" default="install" basedir="." 
-    xmlns:x="antlib:org.apache.avalon.tools" xmlns:d="plugin:demo/demo#1.0" > 
+<project name="sample" default="dist" basedir="."
+    xmlns:x="antlib:org.apache.avalon.tools" 
+    xmlns:d="plugin:demo/demo#1.0" > 
 
-  <x:home index="../../index.xml">
+  <import file="${project.home}/standard.xml"/>
+
+  <x:home>
     <x:plugin artifact="plugin:demo/demo#1.0"/>
   </x:home>
 
-  <target name="clean">
-    <x:clean/>
-  </target>
-
-  <target name="prepare" depends="">
-    <x:prepare/>
-  </target>
-
-  <target name="build" depends="prepare">
-    <x:javac/>
+  <target name="build" depends="standard.build">
     <d:hello/>
   </target>
 
-  <target name="package" depends="build">
-    <x:jar/>
-  </target>
-
-  <target name="test" depends="package">
-    <x:junit/>
-  </target>
-
-  <target name="install" depends="test">
-    <x:install/>
-  </target>
-
 </project>
-

Added: avalon/trunk/tools/project/core/src/test/projects/widget/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/test/projects/widget/build.properties	Thu Jun  3 22:40:56
2004
@@ -0,0 +1,2 @@
+project.home = ../..
+project.gpg.exe = gpg
\ No newline at end of file

Modified: avalon/trunk/tools/project/core/src/test/projects/widget/build.xml
==============================================================================
--- avalon/trunk/tools/project/core/src/test/projects/widget/build.xml	(original)
+++ avalon/trunk/tools/project/core/src/test/projects/widget/build.xml	Thu Jun  3 22:40:56
2004
@@ -1,32 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
 
-<project name="widget" default="install" basedir="." 
-    xmlns:x="antlib:org.apache.avalon.tools">
+<project name="widget" default="install" basedir=".">
 
-  <x:home index="../../index.xml"/>
-
-  <target name="clean">
-    <x:clean/>
-  </target>
-
-  <target name="prepare" depends="">
-    <x:prepare/>
-  </target>
-
-  <target name="build" depends="prepare">
-    <x:javac/>
-  </target>
-
-  <target name="package" depends="build">
-    <x:jar/>
-  </target>
-
-  <target name="test" depends="package">
-    <x:junit/>
-  </target>
-
-  <target name="install" depends="test">
-    <x:install/>
-  </target>
+  <property file="build.properties"/>
+  <import file="${project.home}/standard.xml"/>
 
 </project>
 

Added: avalon/trunk/tools/project/core/src/test/standard.xml
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/test/standard.xml	Thu Jun  3 22:40:56 2004
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<project name="standard" xmlns:x="antlib:org.apache.avalon.tools">
+
+  <x:home/>
+
+  <target name="clean">
+    <x:clean/>
+  </target>
+
+  <target name="prepare" depends="">
+    <x:prepare/>
+  </target>
+
+  <target name="build" depends="prepare">
+    <x:javac/>
+  </target>
+
+  <target name="package" depends="build">
+    <x:jar/>
+  </target>
+
+  <target name="test" depends="package">
+    <x:junit/>
+  </target>
+
+  <target name="site" depends="prepare">
+    <x:xdoc theme="modern"/>
+  </target>
+
+  <target name="install" depends="test">
+    <x:install/>
+  </target>
+
+  <target name="dist" depends="install,site"/>
+
+</project>
+

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message