Class ModuleBuilder
java.lang.Object
org.wildfly.testing.tools.modules.ModuleBuilder
A simple utility to create a module.
This will create a JAR based on the classes and generate a module.xml file.
- Author:
- James R. Perkins
-
Method Summary
Modifier and TypeMethodDescriptionAdds an asset to the module library.Adds a class to the module to be generated.addClasses(Class<?>... classes) Adds the classes to the module to be generated.addDependencies(String... dependencies) Adds the dependencies for the module.xml file.addDependencies(Collection<ModuleDependency> dependencies) Adds the dependencies for the module.xml file.addDependencies(ModuleDependency... dependencies) Adds the dependencies for the module.xml file.addDependency(String dependency) Adds a dependency for the module.xml file.addDependency(ModuleDependency dependency) Adds a dependency for the module.xml file.addManifestResource(org.jboss.shrinkwrap.api.asset.Asset asset, String target) Adds a manifest resource,META-INF, inside the module JAR.Adds all the classes in the package to the generated module.addPackage(String p) Adds all the classes in the package to the generated module.addResource(org.jboss.shrinkwrap.api.spec.JavaArchive resource) Adds another resource root library to the module.addResourcePath(String resourcePath) Adds a resource path to be added to the root resource.addResourcePaths(String... resourcePaths) Adds the resource paths to be added to the root resource.addResourcePaths(Set<String> resourcePaths) Adds the resource paths to be added to the root resource.addResources(Collection<org.jboss.shrinkwrap.api.spec.JavaArchive> resources) Adds more resource root libraries to the module.addResources(org.jboss.shrinkwrap.api.spec.JavaArchive... resources) Adds more resource root libraries to the module.addServiceProvider(Class<?> intf, Class<?>... implementations) Creates aMETA-INF/servicesfile for the interface with the implementations provied.build()Creates the module by: Creating the module directory based on the modules name Generating a JAR file for the resource Generating a module.xml filename()Returns the module name.static ModuleBuilderCreates a new module builder with an archive name of test-module.jar.static ModuleBuilderCreates a new module builder.static ModuleBuilderCreates a new module builder.static ModuleBuilderCreates a new module builder with an archive name of test-module.jar.static ModuleBuilderCreates a new module builder.
-
Method Details
-
of
Creates a new module builder with an archive name of test-module.jar.- Parameters:
moduleName- the name for the module- Returns:
- a new module builder
-
of
Creates a new module builder with an archive name of test-module.jar.- Parameters:
moduleName- the name for the modulejar- the JAR to use for the module- Returns:
- a new module builder
-
of
Creates a new module builder.- Parameters:
moduleName- the name for the modulearchiveName- the name for the archive- Returns:
- a new module builder
-
of
Creates a new module builder.- Parameters:
moduleName- the name for the modulearchiveName- the name for the archivemodulePath- the JBoss Modules path where the module should be created, ifnullthere will be an attempt to discover the path- Returns:
- a new module builder
-
of
public static ModuleBuilder of(String moduleName, org.jboss.shrinkwrap.api.spec.JavaArchive jar, Path modulePath) Creates a new module builder.- Parameters:
moduleName- the name for the modulejar- the JAR to use for the modulemodulePath- the JBoss Modules path where the module should be created, ifnullthere will be an attempt to discover the path- Returns:
- a new module builder
-
name
Returns the module name.- Returns:
- the module name
-
addAsset
Adds an asset to the module library.- Parameters:
asset- the asset to addtarget- the target path for the asset- Returns:
- this builder
-
addClass
Adds a class to the module to be generated.- Parameters:
c- the class to add- Returns:
- this builder
-
addClasses
Adds the classes to the module to be generated.- Parameters:
classes- the classes to add- Returns:
- this builder
-
addDependency
Adds a dependency for the module.xml file.- Parameters:
dependency- the dependency to add- Returns:
- this builder
-
addDependencies
Adds the dependencies for the module.xml file.- Parameters:
dependencies- the dependencies to add- Returns:
- this builder
-
addDependency
Adds a dependency for the module.xml file.- Parameters:
dependency- the dependency to add- Returns:
- this builder
-
addDependencies
Adds the dependencies for the module.xml file.- Parameters:
dependencies- the dependencies to add- Returns:
- this builder
-
addDependencies
Adds the dependencies for the module.xml file.- Parameters:
dependencies- the dependencies to add- Returns:
- this builder
-
addServiceProvider
Creates aMETA-INF/servicesfile for the interface with the implementations provied.- Parameters:
intf- the interface to crate the services file forimplementations- the implemenations- Returns:
- this builder
-
addPackage
Adds all the classes in the package to the generated module.- Parameters:
p- the package to add- Returns:
- this builder
-
addPackage
Adds all the classes in the package to the generated module.- Parameters:
p- the package to add- Returns:
- this builder
-
addManifestResource
Adds a manifest resource,META-INF, inside the module JAR.- Parameters:
asset- the resource to addtarget- the target path within the archive in which to add the resource, relative to theMETA-INFpath- Returns:
- this builder
-
addResource
Adds another resource root library to the module.- Parameters:
resource- the resource to add- Returns:
- this builder
-
addResources
Adds more resource root libraries to the module.- Parameters:
resources- the resources to add- Returns:
- this builder
-
addResources
Adds more resource root libraries to the module.- Parameters:
resources- the resources to add- Returns:
- this builder
-
addResourcePath
Adds a resource path to be added to the root resource.- Parameters:
resourcePath- the resource path to add- Returns:
- this builder
-
addResourcePaths
Adds the resource paths to be added to the root resource.- Parameters:
resourcePaths- the resource paths to add- Returns:
- this builder
-
addResourcePaths
Adds the resource paths to be added to the root resource.- Parameters:
resourcePaths- the resource paths to add- Returns:
- this builder
-
build
Creates the module by:- Creating the module directory based on the modules name
- Generating a JAR file for the resource
- Generating a module.xml file
The returned cleanup task will attempt to delete the module directory. There are some cases where the module directory may not be able to be deleted. The
IOExceptionis caught in these cases and a shutdown hook is added to delete the files when the JVM exits.- Returns:
- a task to clean up the module
-