diff --git a/WHATSNEW b/WHATSNEW index 61e85233b..3891ac06f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -40,6 +40,10 @@ Changes that could break older environments: actually crashes the JVM on our (Java1.5) systems, we don't think any build files which actually worked will be affected by the change. +* used to ignore a nested fileset when a jar was also provided + as an attribute, printing a warning message; now it signs files in the + fileset. + Fixed bugs: ----------- @@ -141,6 +145,12 @@ Other changes: * has a new nested element that can be used to protect extra-content in the target directory. Bugzilla Report 21832. + +* now supports: + -nested filesets at the same time as the jar attribute + -a destDir attribute with the appropriate dependency logic, which + can be used with the jar attribute or nested filesets + -a mapper to permit filename remapping on signing Changes from Ant 1.6.2 to current Ant 1.6 CVS version ===================================================== diff --git a/build.xml b/build.xml index 8747a9a12..74d7d6d66 100644 --- a/build.xml +++ b/build.xml @@ -334,7 +334,6 @@ - diff --git a/docs/manual/CoreTasks/signjar.html b/docs/manual/CoreTasks/signjar.html index 873dd7868..900ea96d2 100644 --- a/docs/manual/CoreTasks/signjar.html +++ b/docs/manual/CoreTasks/signjar.html @@ -24,16 +24,11 @@ Dependency rules
  • Out of date destination JARs are created/signed
  • If a destination file and a source file are the same, and lazy is true, the JAR is only signed if it does not -contain any signature.
  • +contain a signature by this alias.
  • If a destination file and a source file are the same, and lazy is false, the JAR is signed.
  • -

    -When checking signatures, the actual signatory itself is not verified. This -means that "lazy" checks do not work if a JAR is signed by multiple authors. -

    -

    Parameters

    @@ -131,13 +126,11 @@ block -
    fileset of JAR files to sign. No

    Examples

    diff --git a/src/etc/testcases/taskdefs/signjar.xml b/src/etc/testcases/taskdefs/signjar.xml
    index 65eef3b07..17f0da224 100644
    --- a/src/etc/testcases/taskdefs/signjar.xml
    +++ b/src/etc/testcases/taskdefs/signjar.xml
    @@ -1,48 +1,86 @@
     
    +
       
    +  
    +  
    +  
    +  
    +  
    +  
    +  
    +  
    +    
    +    
    +      
    +        
    +          
    +        
    +      
    +    
    +  
    +
    +  
    +    
    +  
    +  
    +  
    +    
    +  
    +  
    +  
    +    
    +    
     
    -  
    -    
    -    
    +  
    +  
    +  
    +    
    +  
    +
    +  
    +    This build is for use with Ant's test cases
    +  
    +  
    +  
    +    
    +                 
       
     
    -  
    -    
    -    
    +  
    +    
    +                 
       
     
    -  
    -    
    -    
    +  
    +    
    +                 
       
     
    -  
    -    
    -    
    +  
    +    
    +                 
       
     
    +  
       
    -  
    -    
    -    
    +  
    +    
    +                 
       
     
    -  
    -    
    -    
    -    
    +    
    +    
    -
    +    
         
           
             
    -          
    +          
                 
               
             
    @@ -50,13 +88,86 @@
         
       
     
    -  
    -    
    +  
    +    
    +      
    +    
    +    
       
     
    -  
    -    This build is for use with Ant's test cases
    +  
    +    
    +      
    +    
    +    
    +  
    +  
    +  
    +    
    +      
    +    
    +  
    +  
    +  
    +    
    +    
    +    
       
     
    +  
    +    
    +  
    +
    +  
    +    
    +    
    +  
    +  
    +  
    +    
    +      
    +    
    +    
    +  
    +  
    +  
    +    
    +      
    +      
    +    
    +  
    +  
    +  
    +    
    +      
    +      
    +    
    +    
    +  
    +
    +  
    +    
    +      
    +      
    +      
    +    
    +  
    +
    +  
    +    
    +  
    +
    +  
    +    
    +  
    +
    +  
    +    
    +  
    +  
     
     
    diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java
    index 5a20fa7ce..908a2e430 100644
    --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java
    +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java
    @@ -59,16 +59,43 @@ public class SignJar extends Task {
         protected String alias;
     
         /**
    -     * The name of keystore file.
    +     * The url or path of keystore file.
          */
         private String keystore;
     
    +    /**
    +     * password for the store
    +     */
         protected String storepass;
    +
    +    /**
    +     * type of store,-storetype param
    +     */
         protected String storetype;
    +
    +    /**
    +     * password for the key in the store
    +     */
         protected String keypass;
    +
    +    /**
    +     * name to a signature file
    +     */
         protected String sigfile;
    +
    +    /**
    +     * name of a single jar
    +     */
         protected File signedjar;
    +
    +    /**
    +     * verbose output
    +     */
         protected boolean verbose;
    +
    +    /**
    +     * flag for
    +     */
         protected boolean internalsf;
         protected boolean sectionsonly;
         private boolean preserveLastModified;
    @@ -98,11 +125,8 @@ public class SignJar extends Task {
         /**
          * mapper for todir work
          */
    -    private Mapper mapper;
    +    private FileNameMapper mapper;
     
    -    /** error string for unit test verification: {@value} */
    -    public static final String ERROR_SIGNEDJAR_AND_FILESET =
    -            "The signedjar attribute is not supported with filesets";
         /**
          * error string for unit test verification: {@value}
          */
    @@ -113,7 +137,7 @@ public class SignJar extends Task {
          */
         public static final String ERROR_TOO_MANY_MAPPERS = "Too many mappers";
         /**
    -     * error string for unit test verification: {@value}
    +     * error string for unit test verification {@value}
          */
         public static final String ERROR_SIGNEDJAR_AND_FILESETS = "You cannot specify the signed JAR when using filesets";
         /**
    @@ -296,14 +320,14 @@ public class SignJar extends Task {
          * @param newMapper
          * @since Ant 1.7
          */
    -    public void addMapper(Mapper newMapper) {
    +    public void add(FileNameMapper newMapper) {
             if (mapper != null) {
                 throw new BuildException(ERROR_TOO_MANY_MAPPERS);
             }
             mapper = newMapper;
         }
     
    -    public Mapper getMapper() {
    +    public FileNameMapper getMapper() {
             return mapper;
         }
     
    @@ -373,7 +397,7 @@ public class SignJar extends Task {
             //set up our mapping policy
             FileNameMapper destMapper;
             if (hasMapper) {
    -            destMapper = mapper.getImplementation();
    +            destMapper = mapper;
             } else {
                 //no mapper? use the identity policy
                 destMapper = new IdentityMapper();
    @@ -563,7 +587,7 @@ public class SignJar extends Task {
     
         /**
          * test for a file being signed, by looking for a signature in the META-INF
    -     * directory
    +     * directory with our alias.
          *
          * @param file the file to be checked
          * @return true if the file is signed
    diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java
    index 7921b84bb..bd716c521 100644
    --- a/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java
    +++ b/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java
    @@ -35,6 +35,7 @@ public class SignJarTest extends BuildFileTest {
         public static final String EXPANDED_MANIFEST
             = "src/etc/testcases/taskdefs/manifests/META-INF/MANIFEST.MF";
     
    +
         public SignJarTest(String name) {
             super(name);
         }
    @@ -47,6 +48,13 @@ public class SignJarTest extends BuildFileTest {
             executeTarget("clean");
         }
     
    +    /**
    +     * check for being offline
    +     * @return true iff the system property "offline" is "true"
    +     */
    +    private boolean isOffline() {
    +        return Boolean.getBoolean("offline");
    +    }
         public void testBasicSigning() {
             executeTarget("basic");
         }
    @@ -64,10 +72,78 @@ public class SignJarTest extends BuildFileTest {
         }
     
         public void testURLKeystoreHTTP() {
    -        executeTarget("urlKeystoreHTTP");
    +        if(!isOffline()) {
    +            executeTarget("urlKeystoreHTTP");
    +        }
         }
     
         public void testPreserveLastModified() {
             executeTarget("preserveLastModified");
         }
    -}
    +
    +    public void testFileset() {
    +        executeTarget("testFileset");
    +    }
    +
    +    public void testFilesetAndJar() {
    +        executeTarget("testFilesetAndJar");
    +    }
    +
    +    public void testFilesetAndSignedJar() {
    +        expectBuildExceptionContaining("testFilesetAndSignedJar",
    +                "incompatible attributes",
    +                SignJar.ERROR_SIGNEDJAR_AND_FILESETS);
    +    }
    +
    +    public void testSignedJar() {
    +        executeTarget("testSignedJar");
    +    }
    +
    +    public void testDestDir() {
    +        executeTarget("testDestDir");
    +    }
    +
    +    public void testDestDirAndSignedJar() {
    +        expectBuildExceptionContaining("testFilesetAndSignedJar",
    +                "incompatible attributes",
    +                SignJar.ERROR_SIGNEDJAR_AND_FILESETS);
    +    }
    +
    +    public void testDestDirFileset() {
    +        executeTarget("testDestDirFileset");
    +    }
    +
    +    public void testMapperFileset() {
    +        executeTarget("testMapperFileset");
    +    }
    +
    +    public void testMapperNoDest() {
    +        expectBuildExceptionContaining("testMapperNoDest",
    +                "two mappers",
    +                SignJar.ERROR_MAPPER_WITHOUT_DEST);
    +    }
    +
    +    public void testTwoMappers() {
    +        expectBuildExceptionContaining("testTwoMappers",
    +                "two mappers",
    +                SignJar.ERROR_TOO_MANY_MAPPERS);
    +    }
    +
    +    public void testNoAlias() {
    +        expectBuildExceptionContaining("testNoAlias",
    +                "no alias",
    +                SignJar.ERROR_NO_ALIAS);
    +    }
    +
    +    public void testNoFiles() {
    +        expectBuildExceptionContaining("testNoFiles",
    +                "no files",
    +                SignJar.ERROR_NO_SOURCE);
    +    }
    +
    +    public void testNoStorePass() {
    +        expectBuildExceptionContaining("testNoStorePass",
    +                "no files",
    +                SignJar.ERROR_NO_STOREPASS);
    +    }
    + }