svn commit: rev 22323 - in avalon/trunk/tools/magic/src/main/org/apache/avalon/tools: model tasks

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Wed Jun 30 06:22:15 2004
New Revision: 22323

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
Log:
Update the standard layout to map closer to the maven targets directory structure by moving the test classes directory from target/test/classes to target/test-classes.  Also updated the block task to support multi-target output (e.g. generating a block into deliverables and generating an embedded block uising one statement).

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java	Wed Jun 30 06:22:15 2004
@@ -44,10 +44,11 @@
     public static final String TARGET = "target";
     public static final String BUILD = "build";
     public static final String CLASSES = "classes";
+    public static final String DELIVERABLES = "deliverables";
     public static final String TEST_CLASSES = "test-classes";
+    public static final String TEST_REPORTS = "test-reports";
     public static final String TEMP = "temp";
     public static final String TEST = "test";
-    public static final String DELIVERABLES = "deliverables";
     public static final String DOCS = "docs";
 
     private static final String USER_PROPERTIES = "user.properties";
@@ -100,6 +101,7 @@
     private File m_deliverables;
     private File m_classes;
     private File m_testClasses;
+    private File m_testReports;
     private File m_temp;
     private File m_docs;
     private File m_test;
@@ -144,6 +146,7 @@
         m_temp = setBuildPath( TEMP );
         m_test = setBuildPath( TEST );
         m_testClasses = setBuildPath( TEST_CLASSES );
+        m_testReports = setBuildPath( TEST_REPORTS );
         m_docs = setBuildPath( DOCS );
 
         project.addReference( KEY, this );
@@ -216,6 +219,11 @@
     public File getTestClassesDirectory()
     {
         return m_testClasses;
+    }
+
+    public File getTestReportsDirectory()
+    {
+        return m_testReports;
     }
 
     public File getTempDirectory()

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	Wed Jun 30 06:22:15 2004
@@ -52,6 +52,7 @@
     {
         private String m_name;
         private String m_classname;
+        private String m_profile;
 
         public Component()
         {
@@ -67,6 +68,11 @@
             m_classname = classname;
         }
 
+        public void setProfile( final String profile )
+        {
+            m_profile = profile;
+        }
+
         public String getName()
         {
             return m_name;
@@ -76,11 +82,17 @@
         {
             return m_classname;
         }
+
+        public String getProfile()
+        {
+            return m_profile;
+        }
     }
 
     private String m_target;
     private String m_container;
     private List m_components = new ArrayList();
+    private boolean m_standalone = true;
 
     public void setName( final String name )
     {
@@ -110,6 +122,16 @@
         }
     }
 
+   /**
+    * Optional attribute indicating that the block is to be generated
+    * as a standalone block.
+    */
+    public void setStandalone( final boolean flag )
+    {
+        m_standalone = flag;
+    }
+
+
     private String getName( Definition def )
     {
         if( null == m_container )
@@ -161,6 +183,21 @@
         super.setType( BLOCK );
     }
 
+    public void execute()
+    {
+        if( null != m_target )
+        {
+System.out.println( "EMBEDDED: " + getPluginFile() );
+            super.execute(); // generate the embedded block
+            m_target = null;
+        }
+        if( m_standalone )
+        {
+System.out.println( "STANDALONE: " + getPluginFile() );
+            super.execute(); // generate the standalone block
+        }
+    }
+
     protected void writePlugin( final Writer writer, final Definition def )
         throws IOException
     {
@@ -187,8 +224,18 @@
     private void writeComponent( final Writer writer, final Component component )
         throws IOException
     {
-        writer.write( 
-          "\n  <component name=\"" + component.getName() + "\" class=\""
-          + component.getClassname() + "\"/>\n" );
+        if( null == component.getProfile() )
+        {
+            writer.write( 
+              "\n  <component name=\"" + component.getName() + "\" class=\""
+              + component.getClassname() + "\"/>\n" );
+        }
+        else
+        {
+            writer.write( 
+              "\n  <component name=\"" + component.getName()  + "\" profile=\""
+              + component.getProfile() + "\"\n    class=\""
+              + component.getClassname() + "\"/>\n" );
+        }
     }
 }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java	Wed Jun 30 06:22:15 2004
@@ -49,9 +49,6 @@
     public static final String TEST_ENV_KEY = "project.test.env";
     public static final String TEST_ENV_VALUE = "env";
 
-    public static final String TEST_TMP_KEY = "project.test.temp";
-    public static final String TEST_TMP_VALUE = "temp";
-
     public static final String DEBUG_KEY = "project.test.compile.debug";
     public static final boolean DEBUG_VALUE = true;
 
@@ -82,7 +79,6 @@
             project.setNewProperty( FORK_KEY, "" + FORK_VALUE );
             project.setNewProperty( TEST_SRC_KEY, "" + TEST_SRC_VALUE );
             project.setNewProperty( TEST_ENV_KEY, "" + TEST_ENV_VALUE );
-            project.setNewProperty( TEST_TMP_KEY, "" + TEST_TMP_VALUE );
             project.setNewProperty( HALT_ON_ERROR_KEY, "" + HALT_ON_ERROR_VALUE );
             project.setNewProperty( HALT_ON_FAILURE_KEY, "" + HALT_ON_FAILURE_VALUE );
 
@@ -220,8 +216,9 @@
     {
         final Project project = getProject();
 
-        final File base = new File( m_test, "temp" );
-        copyUnitTestResource( base );
+        final File working = getContext().getTestDirectory();
+        mkDir( working );
+        copyUnitTestResource( working );
 
         final FileSet fileset = new FileSet();
         fileset.setDir( src );
@@ -237,10 +234,10 @@
         if( getForkProperty() )
         {
             junit.setFork( true );
-            junit.setDir( base );
+            junit.setDir( project.getBaseDir() );
         }
         junit.setShowOutput( true );
-        junit.setTempdir( base );
+        junit.setTempdir( working );
         junit.setReloading( true );
         junit.setFiltertrace( true );
         junit.createClasspath().add( classpath );
@@ -251,7 +248,7 @@
           getBooleanProperty( 
             HALT_ON_FAILURE_KEY, HALT_ON_FAILURE_VALUE ) );
 
-        final File reports = new File( m_test, "reports" );
+        final File reports = getContext().getTestReportsDirectory();
         mkDir( reports );
 
         final BatchTest batch = junit.createBatchTest();
@@ -272,7 +269,7 @@
 
         final Environment.Variable work = new Environment.Variable();
         work.setKey( WORK_DIR_KEY );
-        work.setValue( base.toString() );
+        work.setValue( working.toString() );
         junit.addSysproperty( work );
 
         final Environment.Variable basedir = new Environment.Variable();
@@ -285,7 +282,7 @@
         cache.setValue( getCachePath() );
         junit.addSysproperty( cache );
 
-        final File policy = new File( base, "security.policy" );
+        final File policy = new File( working, "security.policy" );
         if( policy.exists() )
         {
             final Environment.Variable security = new Environment.Variable();
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.