mcconnell    2003/12/14 03:58:26

  Modified:    merlin/kernel/cli maven.xml
               merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli
                        Main.java
  Log:
  Sync. with repository updates (specifically dealing with the handling of inital 
properties).
  
  Revision  Changes    Path
  1.2       +12 -1     avalon/merlin/kernel/cli/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/cli/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml 8 Dec 2003 15:37:12 -0000       1.1
  +++ maven.xml 14 Dec 2003 11:58:26 -0000      1.2
  @@ -1,9 +1,19 @@
   
   <project default="jar:install" xmlns:maven="jelly:maven" xmlns:j="jelly:core" 
xmlns:util="jelly:util" xmlns:ant="jelly:ant">
   
  +  <!--
     <postGoal name="java:prepare-filesystem">
       <attainGoal name="avalon:artifact"/>
     </postGoal>
  +  -->
  +
  +  <!--
  +  Add the merlin.properties file.
  +  -->
  +  <postGoal name="java:compile">
  +    <ant:copy 
file="${maven.repo.local}/${pom.groupId}/properties/merlin.properties" 
  +       toDir="${maven.build.dir}/classes" verbose="yes"/>
  +  </postGoal>
   
     <preGoal name="jar:jar">
       <j:forEach var="dep" items="${pom.dependencies}">
  @@ -24,7 +34,7 @@
     # the implementation artifact classpath, factory, etc.            #
     ###################################################################
     -->
  -
  +  <!--
     <postGoal name="java:compile">
       <ant:echo file="${maven.build.dir}/classes/merlin.implementation">
   #===================================================================#
  @@ -42,6 +52,7 @@
   #
   </ant:echo>
     </postGoal>
  +  -->
   
   
   </project>
  
  
  
  1.8       +15 -70    
avalon/merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/cli/src/java/org/apache/avalon/merlin/cli/Main.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Main.java 12 Dec 2003 14:36:55 -0000      1.7
  +++ Main.java 14 Dec 2003 11:58:26 -0000      1.8
  @@ -106,7 +106,9 @@
       private static final File USER_HOME = 
         new File( System.getProperty( "user.home" ) );
   
  -    private static final String MERLIN = "merlin.properties";
  +    private static final String MERLIN_PROPERTIES = "merlin.properties";
  +
  +    private static final String IMPLEMENTATION_KEY = "merlin.implementation";
   
       private static Options CL_OPTIONS = buildCommandLineOptions();
   
  @@ -230,8 +232,8 @@
               CommandLine line = parser.parse( CL_OPTIONS, args );
   
               File dir = getWorkingDirectory( line );
  -            Artifact artifact = getDefaultImplementation( dir, line );
               File system = getMerlinSystemRepository( line );
  +            Artifact artifact = getDefaultImplementation( dir, line );
   
               if( line.hasOption( "version" ) )
               {
  @@ -270,7 +272,6 @@
                   //
   
                   MAIN = new Main( context, artifact, line );
  -
               }
           }
           catch( Throwable e )
  @@ -321,6 +322,10 @@
           m_kernel = factory.create( criteria );
       }
   
  +    //----------------------------------------------------------
  +    // implementation
  +    //----------------------------------------------------------
  +
       private void handleCommandLine( Map criteria, CommandLine line )
       {
           setLanguage( criteria, line );
  @@ -458,73 +463,13 @@
               String spec = line.getOptionValue( "impl" );
               return Artifact.createArtifact( spec );
           }
  -
  -        //
  -        // check in ${user.dir}/merlin.properties and ${user.home}/merlin.properties
  -        // for a "merlin.implementation" property and use it if decleared
  -        //
  -
  -        final String key = "merlin.implementation";
  -        String home = getLocalProperties( USER_HOME, MERLIN ).getProperty( key );
  -        String work = getLocalProperties( base, MERLIN ).getProperty( key, home);
  -        if( null != work )
  -        {
  -            return Artifact.createArtifact( work );
  -        }
  -
  -        //
  -        // otherwise go with the defaults packaged with the jar file
  -        //
  - 
  -        Properties properties = createDefaultProperties();
  -
  -        final String group = 
  -          properties.getProperty( Artifact.GROUP_KEY );
  -        final String name = 
  -          properties.getProperty( Artifact.NAME_KEY  );
  -        final String version = 
  -          properties.getProperty( Artifact.VERSION_KEY );
  -
  -        return Artifact.createArtifact( group, name, version );
  -    }
  -
  -   /**
  -    * Load the default implementation properties.
  -    * @return the implementation properties
  -    */
  -    private static Properties createDefaultProperties()
  -    {
  -        final String path = "merlin.implementation";
  -        return loadProperties( path );
  -    }
  -
  -   /**
  -    * Load a properties file from a supplied resource name.
  -    * @path the resource path
  -    * @return the properties instance
  -    */
  -    private static Properties loadProperties( String path )
  -    {
  -        try
  -        {
  -            Properties properties = new Properties();
  -            ClassLoader classloader = Main.class.getClassLoader();
  -            InputStream input = classloader.getResourceAsStream( path );
  -            if( input == null ) 
  -            {
  -                final String error = 
  -                  "Missing resource: [" + path + "]";
  -                throw new Error( error );
  -            }
  -            properties.load( input );
  -            return properties;
  -        }
  -        catch ( Throwable e )
  +        else
           {
  -            final String error = 
  -              "Internal error. " 
  -              + "Unable to locate the resource: merlin.implementation.";
  -            throw new IllegalArgumentException( error );
  +            return DefaultBuilder.createImplementationArtifact( 
  +                Main.class.getClassLoader(), 
  +                getBaseDirectory(), 
  +                MERLIN_PROPERTIES, 
  +                IMPLEMENTATION_KEY );
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to