Verify project structure
Typically in a multi-project setup, you want to have different packages for the different projects. An example:
| Gradle project path | Absolute package name |
|---|---|
:certificate:domain |
com.company.project.certificate.domain |
:certificate:web-api |
com.company.project.package.certificate.webapi |
:accounting:domain |
com.company.project.package.accounting.domain |
:accounting:web-api |
com.company.project.package.accounting.webapi |
:accounting:payment-provider-adapter |
com.company.project.package.accounting.ppa |
Arciphant provides the task validatePackageStructure verify correct package structure.
The task is only available in the root project but scans all the subprojects, too.
To configure it, add a packageStructureValidation block to the arciphant configuration, for example:
arciphant {
[..]
packageStructureValidation {
basePackageName("ch.ergon.arciphant.example")
}
}
If no configuration is provided, default values are applied.
Configuration options
The packageStructureValidation task provides the following configuration options (see also PackageStructureValidationDsl) to customize the desired package structure:
| Option | Description |
|---|---|
basePackageName |
The base package name for the whole project. Example: basePackageName('com.company.project') |
disableUseLowerCase |
By default, upper case letters are converted to lower case when mapping project names to corresponding package fragments. Example: project name Use |
disableRemoveUnderscore |
By default, underscores '_' are removed when mapping project name to corresponding package fragment. Example: project name Use |
disableRemoveHyphen |
By default, hyphens '-' are removed when mapping project name to corresponding package fragment. Example: project name Use |
mapProjectNamesToPackageFragments |
Configure mappings for specific project names. See detailed description below. |
mapProjectPathsToAbsolutePackages |
Completely overrides the package name for the given Gradle project path. See detailed description below. |
excludeProjectPath |
Excludes a specific project from package validation. Example: |
excludeResourcesFolder |
By default, all folders in the Use |
excludeSrcFolders |
By default, all folders in the src-folder of each project are validated. Use Example: To exclude |
mapProjectNamesToPackageFragments
Configure mappings for specific project names. The project name can be either a leaf project (e.g., an arciphant component) or a parent project (e.g., an arciphant module). The basePackageName is still used. The configured value replaces only the package fragment related to the specified project.
Example:
arciphant {
[..]
packageStructureValidation {
basePackageName("com.company.project")
mapProjectNameToPackageFragment(
"financial-accounting" to "accounting",
"payment-provider-adapter", "ppa",
)
}
}
The above config results in the following mapping:
| Gradle project path | Absolute package name |
|---|---|
:financial-accounting:domain |
com.company.project.accounting.domain |
:financial-accounting:web-api |
com.company.project.accounting.webapi |
:financial-accounting:payment-provider-adapter |
com.company.project.accounting.ppa |
mapProjectPathsToAbsolutePackages
Completely overrides the package name for the given Gradle project path.
Other than with mapProjectNamesToPackageFragments, the basePackageName is NOT used.
Example: