public class Bundle extends Object
Constructor and Description |
---|
Bundle(ProjectContext context,
Path root)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
Bundle |
clean()
Removes all files on this bundle excepts the content root directory.
|
Bundle |
clean(String path)
Removes target resource on the bundle only if it exists.
|
Bundle |
copy(Path source)
Copies files from the given directory into bundle root.
|
Bundle |
copy(Path source,
String onto)
Copies files from the given file or directory onto the path.
|
Bundle |
extract(Path source)
Copies files from the given file or directory into bundle root.
|
Bundle |
extract(Path source,
String onto)
Copies files from the given file or directory onto the path.
|
Optional<Path> |
find(String path)
Returns a file on this bundle.
|
Bundle |
find(String path,
TryConsumer<? super Path,IOException> configurator)
Returns a file on this bundle.
|
Path |
get(String path)
Returns a file on the bundle.
|
Bundle |
get(String path,
TryConsumer<? super Path,IOException> configurator)
Process a file on the bundle.
|
Path |
getDirectory()
Returns the bundle directory.
|
int |
launch(String command,
String... arguments)
Launches the command.
|
Path |
put(String path)
Creates a file.
|
Bundle |
put(String path,
TryConsumer<? super Path,IOException> configurator)
Creates a file.
|
Bundle |
withLaunch(String command,
String... arguments)
Launches the command, or raise exception if the command failed.
|
public Bundle(ProjectContext context, Path root)
context
- the current contextroot
- the bundle root directorypublic Path getDirectory()
public Bundle copy(Path source)
source
- the source directoryPaths.get(String, String...)
public Bundle copy(Path source, String onto)
source
- the source file or directoryonto
- the copy target path (relative from the bundle root)Paths.get(String, String...)
public Bundle extract(Path source)
/path/to/file.jar/META-INF
.
It extracts only under META-INF
in /path/to/file.jar
.source
- the source file or directoryPaths.get(String, String...)
public Bundle extract(Path source, String onto)
source
- the source file or directoryonto
- the copy target path (relative from the bundle root)Paths.get(String, String...)
public Bundle clean()
public Bundle clean(String path)
path
- the target pathpublic Optional<Path> find(String path)
path
- the relative path from the bundle rootempty
if it is not foundpublic Path get(String path)
path
- the relative path from the bundle rootempty
if it is not foundpublic Path put(String path)
path
- the relative path from the bundle rootpublic Bundle find(String path, TryConsumer<? super Path,IOException> configurator)
path
- the relative path from the bundle rootconfigurator
- the configurator, which will be invoked only if the file existsempty
if it is not foundpublic Bundle get(String path, TryConsumer<? super Path,IOException> configurator)
path
- the relative path from the bundle rootconfigurator
- the file configuratorpublic Bundle put(String path, TryConsumer<? super Path,IOException> configurator)
path
- the relative path from the bundle rootconfigurator
- consumes the created filepublic int launch(String command, String... arguments)
command
- the command, relative from bundle rootarguments
- the command argumentsBasicCommandLauncher
public Bundle withLaunch(String command, String... arguments)
command
- the command, relative from bundle rootarguments
- the command argumentsBasicCommandLauncher
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.