public abstract class AbstractPackagingProvider extends Object implements PackagingProvider
PackagingProvider. Uses the "Template Method" GoF pattern.| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.roo.process.manager.FileManager |
fileManager |
protected static Logger |
LOGGER |
protected PathResolver |
pathResolver |
static String |
ROO_PACKAGING_PROVIDER_PROPERTY
The name of the POM property that stores the packaging provider's ID.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPackagingProvider(String id,
String name,
String pomTemplate)
Constructor
|
protected |
AbstractPackagingProvider(String id,
String name,
String pomTemplate,
String pomModuleTemplate)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(org.osgi.service.component.ComponentContext cContext) |
String |
createArtifacts(org.springframework.roo.model.JavaPackage topLevelPackage,
String nullableProjectName,
String javaVersion,
GAV parentPom,
String module,
ProjectOperations projectOperations)
Creates the initial set of artifacts (files and directories) for a module
with this type of packaging; this includes setting the POM's
/project/packaging element to the desired value. |
protected void |
createOtherArtifacts(org.springframework.roo.model.JavaPackage topLevelPackage,
String module,
ProjectOperations projectOperations)
Subclasses can override this method to create any other required files or
directories (apart from the POM, which has previously been generated by
createPom(org.springframework.roo.model.JavaPackage, java.lang.String, java.lang.String, org.springframework.roo.project.GAV, java.lang.String, org.springframework.roo.project.ProjectOperations)). |
protected String |
createPom(org.springframework.roo.model.JavaPackage topLevelPackage,
String projectName,
String javaVersion,
GAV parentPom,
String module,
ProjectOperations projectOperations)
Creates the Maven POM using the subclass' POM template as follows:
sets the parent POM to the given parent (if any)
sets the groupId to the result of
getGroupId(org.springframework.roo.model.JavaPackage), omitting this
element if it's the same as the parent's groupId (as per Maven best
practice)
sets the artifactId to the result of getArtifactId(java.lang.String, java.lang.String, org.springframework.roo.model.JavaPackage)
sets the packaging to the result of #getName()
sets the project name to the result of getProjectName(java.lang.String, java.lang.String, org.springframework.roo.model.JavaPackage)
replaces all occurrences of JAVA_PRODUCT_VERSION_PLACEHOLDER with
the given Java version
This method makes as few assumptions about the POM template as possible,
to make life easier for anyone writing a PackagingProvider. |
protected String |
getArtifactId(String nullableProjectName,
String module,
org.springframework.roo.model.JavaPackage topLevelPackage)
Returns the text to be inserted into the POM's
<artifactId> element. |
org.springframework.roo.process.manager.FileManager |
getFileManager() |
protected String |
getFullyQualifiedModuleName(String moduleName,
ProjectOperations projectOperations)
Returns the fully-qualified name of the given module, relative to the
currently focused module.
|
protected String |
getGroupId(org.springframework.roo.model.JavaPackage topLevelPackage)
Returns the groupId of the project or module being created.
|
String |
getId()
Returns the unique identifier of this
PackagingProvider, for use
in the Roo user interface. |
PathResolver |
getPathResolver() |
protected String |
getProjectName(String nullableProjectName,
String module,
org.springframework.roo.model.JavaPackage topLevelPackage)
Returns the text to be inserted into the POM's
<name>
element. |
protected void |
setGroupIdAndParent(String projectGroupId,
GAV parentPom,
Element root,
Document pom)
Sets the Maven groupIds of the parent and/or project as necessary
|
protected void |
setPackagingProviderId(Document pom)
Stores the ID of this
PackagingProvider as a POM property called
"roo.packaging.provider". |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPaths, isDefaultprotected static final Logger LOGGER
public static final String ROO_PACKAGING_PROVIDER_PROPERTY
protected org.springframework.roo.process.manager.FileManager fileManager
protected PathResolver pathResolver
protected AbstractPackagingProvider(String id, String name, String pomTemplate)
id - the unique ID of this packaging type, see
PackagingProvider.getId()name - the name of this type of packaging as used in the POM
(required)pomTemplate - the path of this packaging type's POM template,
relative to its own package, as per
Class.getResourceAsStream(String); this template
should contain a "parent" element with its own groupId,
artifactId, and version elements; this parent element will be
removed if not requiredprotected AbstractPackagingProvider(String id, String name, String pomTemplate, String pomModuleTemplate)
id - the unique ID of this packaging type, see
PackagingProvider.getId()name - the name of this type of packaging as used in the POM
(required)pomTemplate - the path of this packaging type's POM template,
relative to its own package, as per
Class.getResourceAsStream(String); this template
should contain a "parent" element with its own groupId,
artifactId, and version elements; this parent element will be
removed if not requiredpomModuleTemplate - the path of this packaging type's POM module template,
relative to its own package, as per
Class.getResourceAsStream(String); this template
should contain a "parent" element with its own groupId,
artifactId, and version elements; can be nullprotected void activate(org.osgi.service.component.ComponentContext cContext)
public String createArtifacts(org.springframework.roo.model.JavaPackage topLevelPackage, String nullableProjectName, String javaVersion, GAV parentPom, String module, ProjectOperations projectOperations)
PackagingProvider/project/packaging element to the desired value.createArtifacts in interface PackagingProvidertopLevelPackage - the top-level Java package for the new project or
module (required)javaVersion - the Java version for this project or module (required)parentPom - the Maven coordinates of the parent POM (can be
null for none)module - the name of the module being created (blank for the
root or only module)projectOperations - in case it's required (never null)protected void createOtherArtifacts(org.springframework.roo.model.JavaPackage topLevelPackage,
String module,
ProjectOperations projectOperations)
createPom(org.springframework.roo.model.JavaPackage, java.lang.String, java.lang.String, org.springframework.roo.project.GAV, java.lang.String, org.springframework.roo.project.ProjectOperations)).
This implementation sets up the Log4j configuration file for the root module.
topLevelPackage - module - the unqualified name of the module being created (empty
means the root or only module)projectOperations - can't be injected as it would create a circular
dependencyprotected String createPom(org.springframework.roo.model.JavaPackage topLevelPackage, String projectName, String javaVersion, GAV parentPom, String module, ProjectOperations projectOperations)
getGroupId(org.springframework.roo.model.JavaPackage), omitting this
element if it's the same as the parent's groupId (as per Maven best
practice)getArtifactId(java.lang.String, java.lang.String, org.springframework.roo.model.JavaPackage)#getName()getProjectName(java.lang.String, java.lang.String, org.springframework.roo.model.JavaPackage)JAVA_PRODUCT_VERSION_PLACEHOLDER with
the given Java versionPackagingProvider.topLevelPackage - the new project or module's top-level Java package
(required)projectName - the project name provided by the user (can be blank)javaVersion - the Java version to substitute into the POM (required)parentPom - the Maven coordinates of the parent POM (can be
null)module - the unqualified name of the Maven module to which the new
POM belongsprojectOperations - cannot be injected otherwise it's a circular
dependencyprotected String getArtifactId(String nullableProjectName, String module, org.springframework.roo.model.JavaPackage topLevelPackage)
<artifactId> element. This implementation simply
delegates to getProjectName(java.lang.String, java.lang.String, org.springframework.roo.model.JavaPackage). Subclasses can override this method
to use a different strategy.nullableProjectName - the project name entered by the user (can be
blank)module - the name of the module being created (blank for the root
module)topLevelPackage - the project or module's top level Java package
(required)protected final String getFullyQualifiedModuleName(String moduleName, ProjectOperations projectOperations)
moduleName - can be blank for the root or only moduleprojectOperations - protected String getGroupId(org.springframework.roo.model.JavaPackage topLevelPackage)
topLevelPackage - the new project or module's top-level Java package
(required)public final String getId()
PackagingProviderPackagingProvider, for use
in the Roo user interface.
The intent of this method is to allow third-party addons to provide
alternative behaviour for a given Maven packaging type. For example, the
core Roo WAR packaging type will have an ID of "war". If the user wants
to customise how WAR modules are generated, they can implement their own
PackagingProvider with an ID of (say) "custom-war". Then when the
user adds a new module to their project, the shell will offer them the
choice of "WAR" and "CUSTOM-WAR" for the packaging type.
getId in interface PackagingProviderprotected String getProjectName(String nullableProjectName, String module, org.springframework.roo.model.JavaPackage topLevelPackage)
<name>
element. This implementation uses the given project name if not blank,
otherwise the last element of the given Java package. Subclasses can
override this method to use a different strategy.nullableProjectName - the project name entered by the user (can be
blank)module - the name of the module being created (blank for the root
module)topLevelPackage - the project or module's top level Java package
(required)protected void setGroupIdAndParent(String projectGroupId, GAV parentPom, Element root, Document pom)
projectGroupId - the project's groupId (required)parentPom - the Maven coordinates of the parent POM (can be
null)root - the root element of the POM document (required)pom - the POM document (required)protected void setPackagingProviderId(Document pom)
PackagingProvider as a POM property called
"roo.packaging.provider". Subclasses can override this
method, but be aware that Roo needs some way of working out from a given
pom.xml file which PackagingProvider should be used.pom - the DOM document for the POM being createdpublic org.springframework.roo.process.manager.FileManager getFileManager()
public PathResolver getPathResolver()
Copyright © 2009–2017 Pivotal Software, Inc.. All rights reserved.