src/java/io/bazel/rulesscala/jar/JarHelper.java
/**
   * Copies file or directory entries from the file system into the jar.
   * Directory entries will be detected and their names automatically '/'
   * suffixed.
   */
Copies file or directory entries from the file system into the jar.
Directory entries will be detected and their names automatically '/'
suffixed.
Copies file or directory entries from the file system into the jar . Directory entries will be detected and their names automatically ' / ' suffixed .
protected void copyEntry(String name, File file) throws IOException {
    if (!names.contains(name)) {
      if (!file.exists()) {
        throw new FileNotFoundException(file.getAbsolutePath() + " (No such file or directory)");
      }
      boolean isDirectory = file.isDirectory();
      if (isDirectory && !name.endsWith("/")) {
        name = name + '/';  
      }
      if (names.add(name)) {
        if (verbose) {
          System.err.println("adding " + file);
        }
        if (JarHelper.isJar(file)) {
          JarFile nameJf = new JarFile(file);
          copyJar(nameJf, names, out);
        }
        else {
          long size = isDirectory ? 0 : file.length();
          JarEntry outEntry = new JarEntry(name);
          long newtime = normalize ? normalizedTimestamp(name) : file.lastModified();
          outEntry.setTime(newtime);
          outEntry.setSize(size);
          if (size == 0L) {
            outEntry.setMethod(JarEntry.STORED);
            outEntry.setCrc(0);
            out.putNextEntry(outEntry);
          } else {
            outEntry.setMethod(storageMethod);
            if (storageMethod == JarEntry.STORED) {
              outEntry.setCrc(hashFile(file));
            }
            out.putNextEntry(outEntry);
            Files.copy(file.toPath(), out);
          }
          out.closeEntry();
        }
      }
    }
  }
protected void copyEntry ( String name , File file ) throws IOException { if ( ! names . contains ( name ) ) { if ( ! file . exists ( ) ) { throw new FileNotFoundException ( file . getAbsolutePath ( ) + " (No such file or directory)" ) ; } boolean isDirectory = file . isDirectory ( ) ; if ( isDirectory && ! name . endsWith ( "/" ) ) { name = name + '/' ; } if ( names . add ( name ) ) { if ( verbose ) { System . err . println ( "adding " + file ) ; } if ( JarHelper . isJar ( file ) ) { JarFile nameJf = new JarFile ( file ) ; copyJar ( nameJf , names , out ) ; } else { long size = isDirectory ? 0 : file . length ( ) ; JarEntry outEntry = new JarEntry ( name ) ; long newtime = normalize ? normalizedTimestamp ( name ) : file . lastModified ( ) ; outEntry . setTime ( newtime ) ; outEntry . setSize ( size ) ; if ( size == 0L ) { outEntry . setMethod ( JarEntry . STORED ) ; outEntry . setCrc ( 0 ) ; out . putNextEntry ( outEntry ) ; } else { outEntry . setMethod ( storageMethod ) ; if ( storageMethod == JarEntry . STORED ) { outEntry . setCrc ( hashFile ( file ) ) ; } out . putNextEntry ( outEntry ) ; Files . copy ( file . toPath ( ) , out ) ; } out . closeEntry ( ) ; } } } }
Copies file or directory entries from the file system into the jar.
Copies file or directory entries from the file system into the jar .
// always normalize directory names before checking set // Create a new entry