@Mojo(name="scan-many",
configurator="oakpal",
requiresDependencyResolution=TEST,
defaultPhase=INTEGRATION_TEST)
public class ScanManyArtifactsMojo
extends org.apache.maven.plugin.AbstractMojo
checks
. This goal supports the use of ProgressCheck
s that must
evaluate the side effects of installing packages in combination, such as for detection of workspace filter overlap.
More simply, this goal can be used in a sidecar project to scan multiple artifacts produced by previous builds using
a common library of checklists.Modifier and Type | Field and Description |
---|---|
protected String |
blobStorePath
Specify a different blob store path.
|
protected List<String> |
checklists
Specify a list of checklist ids
[module/]name to enforce. |
protected List<net.adamcin.oakpal.core.CheckSpec> |
checks
Specify a list of Checks to locate and load as
ProgressCheck s. |
protected List<String> |
cndNames
Specify a list of Compact NodeType Definition (CND) resource names (to discover in the test-scope classpath)
to import before any packages are installed during the scan.
|
protected boolean |
deferBuildFailure
If violations are reported, defer the build failure until a subsequent verify goal.
|
protected boolean |
enablePreInstallHooks
If this is set to true, InstallHooks in pre-install packages will be enabled.
|
protected org.apache.maven.plugin.MojoExecution |
execution |
protected net.adamcin.oakpal.api.Severity |
failOnSeverity
Specify the minimum violation severity level that will trigger plugin execution failure.
|
protected List<net.adamcin.oakpal.core.ForcedRoot> |
forcedRoots
Specify a list of paths with associated primaryType and mixinTypes values to create in the repository before
installing any packages for the scan.
|
protected net.adamcin.oakpal.core.InstallHookPolicy |
installHookPolicy
Specify a policy for InstallHooks in scanned packages.
|
protected List<net.adamcin.oakpal.core.JcrNs> |
jcrNamespaces
Specify a list of additional JCR namespaces to register before installing any packages for the scan.
|
protected List<String> |
jcrPrivileges
Specify a list of additional JCR privileges to register before installing any packages for the scan.
|
protected List<DependencyFilter> |
preInstallArtifacts
Specify a list of content-package artifacts to download and pre-install before the scanned packages.
|
protected List<File> |
preInstallFiles
Specify a list of content package files by path to pre-install, which have already been built or downloaded in a
previous phase.
|
protected org.apache.maven.project.MavenProject |
project |
protected String |
repoInit
Specify an inline repoinit script.
|
protected List<File> |
repoInitFiles
Specify a list of file paths to repoinit scripts.
|
protected List<String> |
runModes
Specify a list of Sling run modes to simulate for installation of embedded filevault packages and
RepositoryInitializer factory configs that provide repoinit scripts.
|
protected org.apache.maven.execution.MavenSession |
session |
protected org.apache.maven.settings.Settings |
settings |
protected boolean |
silenceAllSubpackages
Set to true to suppress progress check events generated by subpackage installation (and the resulting violations)
during the scan.
|
protected boolean |
skipITs
Conventional switch to skip integration-test phase goals.
|
protected boolean |
skipTests
Conventional switch to skip test and integration-test phase goals.
|
protected boolean |
slingNodeTypes
Enable automatic discovery and installation of CND files referenced in
Sling-Nodetypes Manifest headers
in the plugin dependencies or the project's test -scope dependencies. |
protected boolean |
storeBlobs
Set to true to disable the blob store configured by
blobStorePath . |
protected File |
summaryFile
The summary file to read integration test results from.
|
Constructor and Description |
---|
ScanManyArtifactsMojo() |
Modifier and Type | Method and Description |
---|---|
default @NotNull org.apache.jackrabbit.vault.fs.spi.NodeTypeSet |
aggregateCnds(@NotNull PlanBuilderParams params,
@NotNull org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping planMapping,
net.adamcin.oakpal.api.Fun.ThrowingFunction<List<String>,Map<String,URL>> cndResolver,
net.adamcin.oakpal.api.Fun.ThrowingSupplier<List<URL>> slingCndFinder)
Find and resolve CND resources on the classpath, read them, and aggregate the node type definitions for writing
to the
jcrNodetypes property of a plan. |
default net.adamcin.oakpal.core.OakpalPlan |
buildPlan()
Construct an Oakpal Plan purely from the relevant mojo parameters.
|
void |
execute() |
protected void |
executeGuardedIntegrationTest() |
List<String> |
getChecklists() |
List<net.adamcin.oakpal.core.CheckSpec> |
getChecks() |
List<String> |
getCndNames() |
protected ClassLoader |
getContainerClassLoader() |
org.apache.maven.plugin.MojoExecution |
getExecution()
Get the current mojo execution.
|
List<net.adamcin.oakpal.core.ForcedRoot> |
getForcedRoots() |
net.adamcin.oakpal.core.InstallHookPolicy |
getInstallHookPolicy() |
List<net.adamcin.oakpal.core.JcrNs> |
getJcrNamespaces() |
List<String> |
getJcrPrivileges() |
default @NotNull URL |
getPlanBaseUrl()
Returns a URL that serves as the plan base URL for resource resolution.
|
@NotNull PlanBuilderParams |
getPlanBuilderParams() |
default @Nullable String |
getPlanName()
Override to specify a plan name to use as the default in an opear.
|
List<DependencyFilter> |
getPreInstallArtifacts() |
List<File> |
getPreInstallFiles() |
default @NotNull List<File> |
getPreInstallFiles(@NotNull PlanBuilderParams params)
Return a list of package files to include as pre-install packages in the plan.
|
Optional<org.apache.maven.project.MavenProject> |
getProject()
Get the maven project if available.
|
List<File> |
getRepoInitFiles() |
List<String> |
getRepoInits() |
org.apache.maven.repository.RepositorySystem |
getRepositorySystem() |
List<String> |
getRunModes() |
org.apache.maven.execution.MavenSession |
getSession()
Get the current maven session.
|
org.apache.maven.settings.Settings |
getSettings()
Get the maven settings.
|
boolean |
isEnablePreInstallHooks() |
protected boolean |
isIndividuallySkipped() |
boolean |
isSlingNodeTypes() |
boolean |
isTestScopeContainer()
There are basically two use cases for the oakpal-maven-plugin:
1) Adhoc testing of a content-package project artifact, in which case all oakpal classpath resources will be
found in
test scope, or
2) Creation and testing of an oakpal module with checklists, and/or creation and testing of an opear archive,
in which case all oakpal classpath resources will be found in a non-test scope classpath. |
protected void |
performScan(@NotNull List<File> scanFiles) |
protected void |
reactToReports(@NotNull List<net.adamcin.oakpal.core.CheckReport> reports) |
getLog, getPluginContext, setLog, setPluginContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createContainerClassLoader, depToArtifact, getRepositorySystem, isTestScopeContainer, resolveArtifacts, resolveDependencies
getExecution, getProject, getSession, getSettings
@Parameter(name="preInstallArtifacts") protected List<DependencyFilter> preInstallArtifacts
For example:
<preInstallArtifacts> <preInstallArtifact> <groupId>com.adobe.acs</groupId> <artifactId>acs-aem-commons-content</artifactId> <version>3.9.0</version> <type>zip</type> </preInstallArtifact> </preInstallArtifacts>
@Parameter(name="preInstallFiles") protected List<File> preInstallFiles
@Parameter(name="cndNames") protected List<String> cndNames
src/main/resources
of a common
test-scoped dependency, or under src/test/resources
of the referencing module).@Parameter(name="slingNodeTypes") protected boolean slingNodeTypes
Sling-Nodetypes
Manifest headers
in the plugin dependencies or the project's test
-scope dependencies.@Parameter(name="jcrNamespaces") protected List<net.adamcin.oakpal.core.JcrNs> jcrNamespaces
For example:
<jcrNamespaces> <jcrNamespace> <prefix>crx</prefix> <uri>http://www.day.com/crx/1.0</uri> </jcrNamespace> </jcrNamespaces>
@Parameter(name="jcrPrivileges") protected List<String> jcrPrivileges
For example:
<jcrPrivileges> <jcrPrivilege>crx:replicate</jcrPrivilege> </jcrPrivileges>
@Parameter(name="forcedRoots") protected List<net.adamcin.oakpal.core.ForcedRoot> forcedRoots
For example, to ensure that /home/users/system is created as a rep:AuthorizableFolder, you would add a forcedRoot element with a path of "/home/users/system" and a primaryType of "rep:AuthorizableFolder".
<forcedRoots> <forcedRoot> <path>/home/users/system</path> <primaryType>rep:AuthorizableFolder</primaryType> <mixinTypes> <mixinType>rep:AccessControllable</mixinType> </mixinTypes> </forcedRoot> </forcedRoots>
@Parameter(name="checks") protected List<net.adamcin.oakpal.core.CheckSpec> checks
ProgressCheck
s.
Minimally, there are two ways to define a CheckSpec
. To load a check from the project's test output
directory, you must specify the impl
value as a classPath-relative resource name for script checks, or as
a fully-qualified class name for Java ProgressCheck
implementations.
For example, if your script check source is located at src/test/resources/OAKPAL-INF/scripts/acme-vault-enforcer.js
:
<checks> <check> <impl>OAKPAL-INF/scripts/acme-vault-enforcer.js</impl> </check> </checks>
If your impl
represents a script check or a ProgressCheckFactory
, you can
also provide a config
element that will be translated to a JsonObject
by the
JsonConverter
via the
OakpalComponentConfigurator
:
<checks> <check> <impl>OAKPAL-INF/scripts/acme-vault-enforcer.js</impl> <config> <apples> <apple>Granny Smith</apple> <apple>Red Delicious</apple> <apple>IIe</apple> </apples> <requirePolicyNode>true</requirePolicyNode> </config> </check> </checks>
To reference a check from a specific checklist, available on the plugin or project test-scope classpath, you should
not specify the impl
property, but instead reference it by name, in one of the following formats, in order
of increasing specificity,
name
checklistName/name
module/checklistName/name
For example, the oakpal core library provides some useful checks in the basic
checklist, like echo
,
which prints progress events to System.out:
<checks> <check> <name>net.adamcin.oakpal.core/basic/echo</name> </check> </checks>
It can also be referenced by shorter forms:
<checks> <check> <name>basic/echo</name> </check> </checks>
<checks> <check> <name>echo</name> </check> </checks>
You can also override the configs defined by a checklist for a given check:
<checks> <check> <name>basic/paths</name> <config> <rules> <rule> <pattern>/etc/tags(/.*)?</pattern> <type>deny</type> </rule> <rule> <pattern>/etc/tags/acme(/.*)?</pattern> <type>allow</type> </rule> </rules> <denyAllDeletes>true</denyAllDeletes> </config> </check> </checks>
@Parameter(name="checklists") protected List<String> checklists
[module/]name
to enforce.@Parameter protected boolean enablePreInstallHooks
@Parameter protected net.adamcin.oakpal.core.InstallHookPolicy installHookPolicy
PROHIBIT
REPORT
, and SKIP
,
insofar as the hook will not be executed after registration. Use this level if your policy is to disallow
install hooks in your content packages.REPORT
ABORT
, except scan will proceed.ABORT
SKIP
DEFAULT
(= REPORT
)@Parameter protected boolean silenceAllSubpackages
@Parameter protected boolean deferBuildFailure
If this is set to true, be sure the verify
goal has been activated for the build, otherwise violations
will not be printed and failure-level violations will be implicitly ignored.
@Parameter(property="storeBlobs") protected boolean storeBlobs
blobStorePath
. This forces the blobs to exist in the
memory node store, which should run faster, but can more easily exhaust heap with larger packages.@Parameter(defaultValue="${project.build.directory}/oakpal-plugin/blobs") protected String blobStorePath
@Parameter(property="repoInit") protected String repoInit
repoInitFiles
.
See https://sling.apache.org/documentation/bundles/repository-initialization.html .
Examples:
<repoInit> create path /apps create path (sling:Folder) /content/dam </repoInit>
<repoInit> <![CDATA[ register nodetypes <<=== <'sling'='http://sling.apache.org/jcr/sling/1.0'> [sling:Folder] > nt:folder, nt:unstructured ===>> ]]> </repoInit>
@Parameter(property="repoInitFiles") protected List<File> repoInitFiles
repoInit
parameter, but only after applying all the other state
initialization parameters like jcrNamespaces
, jcrPrivileges
, preInstallArtifacts
, etc.
See https://sling.apache.org/documentation/bundles/repository-initialization.html .@Parameter(property="runModes") protected List<String> runModes
@Parameter(property="skipITs") protected boolean skipITs
@Parameter(property="skipTests") protected boolean skipTests
@Parameter(defaultValue="${project.build.directory}/oakpal-plugin/reports/oakpal-summary.json", required=true) protected File summaryFile
@Parameter(defaultValue="MAJOR") protected net.adamcin.oakpal.api.Severity failOnSeverity
Severity.MINOR
,
Severity.MAJOR
, and
Severity.SEVERE
.
FYI: FileVault Importer errors are reported as MAJOR by default.
@Parameter(defaultValue="${mojoExecution}", readonly=true) protected org.apache.maven.plugin.MojoExecution execution
@Parameter(defaultValue="${session}", readonly=true) protected org.apache.maven.execution.MavenSession session
@Parameter(defaultValue="${settings}", readonly=true) protected org.apache.maven.settings.Settings settings
@Parameter(defaultValue="${project}", readonly=true, required=false) protected org.apache.maven.project.MavenProject project
protected boolean isIndividuallySkipped()
protected void executeGuardedIntegrationTest() throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
@NotNull public final @NotNull PlanBuilderParams getPlanBuilderParams()
public List<DependencyFilter> getPreInstallArtifacts()
getPreInstallArtifacts
in interface PlanBuilderParams
public List<File> getPreInstallFiles()
getPreInstallFiles
in interface PlanBuilderParams
public List<String> getCndNames()
getCndNames
in interface PlanBuilderParams
public boolean isSlingNodeTypes()
isSlingNodeTypes
in interface PlanBuilderParams
public List<net.adamcin.oakpal.core.JcrNs> getJcrNamespaces()
getJcrNamespaces
in interface PlanBuilderParams
public List<String> getJcrPrivileges()
getJcrPrivileges
in interface PlanBuilderParams
public List<net.adamcin.oakpal.core.ForcedRoot> getForcedRoots()
getForcedRoots
in interface PlanBuilderParams
public List<net.adamcin.oakpal.core.CheckSpec> getChecks()
getChecks
in interface PlanBuilderParams
public List<String> getChecklists()
getChecklists
in interface PlanBuilderParams
public boolean isEnablePreInstallHooks()
isEnablePreInstallHooks
in interface PlanBuilderParams
public net.adamcin.oakpal.core.InstallHookPolicy getInstallHookPolicy()
getInstallHookPolicy
in interface PlanBuilderParams
public List<String> getRepoInits()
getRepoInits
in interface PlanBuilderParams
public List<File> getRepoInitFiles()
getRepoInitFiles
in interface PlanBuilderParams
public List<String> getRunModes()
getRunModes
in interface PlanBuilderParams
protected void performScan(@NotNull @NotNull List<File> scanFiles) throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
@NotNull public @NotNull URL getPlanBaseUrl()
@Nullable public @Nullable String getPlanName()
@NotNull public @NotNull List<File> getPreInstallFiles(@NotNull @NotNull PlanBuilderParams params) throws org.apache.maven.plugin.MojoFailureException
params
- the plan builder parametersorg.apache.maven.plugin.MojoFailureException
- if an error occurs@NotNull public @NotNull org.apache.jackrabbit.vault.fs.spi.NodeTypeSet aggregateCnds(@NotNull @NotNull PlanBuilderParams params, @NotNull @NotNull org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping planMapping, @NotNull net.adamcin.oakpal.api.Fun.ThrowingFunction<List<String>,Map<String,URL>> cndResolver, @NotNull net.adamcin.oakpal.api.Fun.ThrowingSupplier<List<URL>> slingCndFinder) throws org.apache.maven.plugin.MojoFailureException
jcrNodetypes
property of a plan.params
- the plan builder parametersplanMapping
- the initial JCR namespace mapping to usecndResolver
- a throwing function that accepts a list of resource names provided by the params to resolve on
the classpath that returns a map of names to resolved urlsslingCndFinder
- a throwing supplier that discovers CND resources on the classpath referenced in
Sling-Nodetypes
manifest headersorg.apache.maven.plugin.MojoFailureException
- if an error occurspublic net.adamcin.oakpal.core.OakpalPlan buildPlan() throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
- if an error occurspublic boolean isTestScopeContainer()
MojoWithRepositoryParams
test
scope, or
2) Creation and testing of an oakpal module with checklists, and/or creation and testing of an opear archive,
in which case all oakpal classpath resources will be found in a non-test
scope classpath. Mojos should
override this method to return true
, to specify that a test
-scope classloader is desired, as in
the first case.test
-scope classloader is desired, or false if a non-test
-scope classloader is
desired.protected ClassLoader getContainerClassLoader() throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
protected void reactToReports(@NotNull @NotNull List<net.adamcin.oakpal.core.CheckReport> reports) throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
public Optional<org.apache.maven.project.MavenProject> getProject()
MojoWithCommonParams
getProject
in interface MojoWithCommonParams
public org.apache.maven.repository.RepositorySystem getRepositorySystem()
getRepositorySystem
in interface MojoWithRepositoryParams
public org.apache.maven.plugin.MojoExecution getExecution()
MojoWithCommonParams
getExecution
in interface MojoWithCommonParams
public org.apache.maven.execution.MavenSession getSession()
MojoWithCommonParams
getSession
in interface MojoWithCommonParams
public org.apache.maven.settings.Settings getSettings()
MojoWithCommonParams
getSettings
in interface MojoWithCommonParams
Copyright © 2017–2020. All rights reserved.