commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosu...@apache.org
Subject cvs commit: jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler AttributeIndexer.java
Date Mon, 25 Aug 2003 18:18:00 GMT
leosutic    2003/08/25 11:17:59

  Modified:    attributes/plugin plugin.jelly
               attributes/compiler/src/java/org/apache/commons/attributes/compiler
                        AttributeIndexer.java
  Log:
  Added some extra code to find the newly-generated jar file in the case
  when jar:snapshot was invoked.
  
  Revision  Changes    Path
  1.4       +1 -5      jakarta-commons-sandbox/attributes/plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/plugin/plugin.jelly,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- plugin.jelly	24 Aug 2003 17:47:59 -0000	1.3
  +++ plugin.jelly	25 Aug 2003 18:17:59 -0000	1.4
  @@ -63,10 +63,6 @@
       </goal>
   
       <postGoal name="jar:jar">
  -
  -        <ant:echo message="JvZ says: ${pom.artifactId}-${pom.currentVersion}.jar"/>
  -        <ant:echo message="JvZ also says: ${maven.final.name}.jar"/>
  -
           <!--
           For the life of me I can't figure out how to get the
           filename of the snapshot jar that jar:jar has just created.
  @@ -74,7 +70,7 @@
           The maven.final.name variable is only set locally by the jar:snapshot
           goal, and thus all I see here is the projectname-version.jar name.
           -->
  -        <ant:attribute-indexer jarFile="${maven.build.dir}/${maven.final.name}.jar">
  +        <ant:attribute-indexer baseName="${maven.build.dir}/${pom.artifactId}">
               <classpath>
                   <path refid="maven.dependency.classpath"/>
               </classpath>
  
  
  
  1.3       +33 -0     jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeIndexer.java
  
  Index: AttributeIndexer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/attributes/compiler/src/java/org/apache/commons/attributes/compiler/AttributeIndexer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttributeIndexer.java	22 Aug 2003 23:48:03 -0000	1.2
  +++ AttributeIndexer.java	25 Aug 2003 18:17:59 -0000	1.3
  @@ -105,6 +105,8 @@
       private File jarFile;
       private HashMap attributes = new HashMap ();
       private Path classPath;
  +    private File baseName;
  +    private boolean inMaven = false;
       
       private final static String INDEX_FILENAME = "META-INF/attrs.index";
       
  @@ -124,6 +126,11 @@
           this.jarFile = jarFile;
       }
       
  +    public void setBaseName (File baseName) {
  +        inMaven = true;
  +        this.baseName = baseName;        
  +    }
  +    
       public Path createClasspath () {
           this.classPath = new Path(project);
           return classPath;
  @@ -154,7 +161,33 @@
           }
       }
       
  +    protected void findJarFile () throws BuildException {
  +        File[] allFiles = baseName.getParentFile ().listFiles ();
  +        if (allFiles == null) {
  +            throw new BuildException ("Unable to find any file with base name " + baseName.getName
() 
  +                + " in " + baseName.getParentFile ().getPath ());
  +        }
  +        
  +        long newestDate = 0;
  +        for (int i = 0; i < allFiles.length; i++) {
  +            String name = allFiles[i].getName ();
  +            if (name.startsWith (baseName.getName ()) && name.endsWith (".jar")
&& 
  +                allFiles[i].lastModified () > newestDate) {
  +                jarFile = allFiles[i];
  +                newestDate = allFiles[i].lastModified ();
  +            }
  +        }
  +        
  +        if (jarFile == null) {
  +            throw new BuildException ("Unable to find any file with base name " + baseName.getName
() 
  +                + " in " + baseName.getParentFile ().getPath ());
  +        }
  +    }
  +    
       public void execute () throws BuildException {
  +        if (inMaven) {
  +            findJarFile ();
  +        }
           if (!jarFile.exists ()) {
               log ("Can't find " + jarFile.getPath ());
               return;
  
  
  

Mime
View raw message