-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5946 from pkriens/issue/5918-include-directory-as…
…-jar Added an option to add a directory as a jar/zip file
- Loading branch information
Showing
4 changed files
with
87 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
biz.aQute.bndlib/src/aQute/bnd/osgi/DirectoryResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package aQute.bnd.osgi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* Resource for a directory. This class implementation assumes the file does not | ||
* change underneath this object. | ||
*/ | ||
public class DirectoryResource extends WriteResource { | ||
private final File dir; | ||
|
||
public DirectoryResource(File dir) throws IOException { | ||
this.dir = dir; | ||
assert dir.isDirectory(); | ||
} | ||
|
||
public DirectoryResource(Path path) throws IOException { | ||
this(path.toFile()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return dir.toString(); | ||
} | ||
|
||
@Override | ||
public void write(OutputStream out) throws Exception { | ||
try (Jar jar = new Jar(dir)) { | ||
jar.write(out); | ||
} | ||
} | ||
|
||
@Override | ||
public long lastModified() { | ||
return dir.lastModified(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters