-
Notifications
You must be signed in to change notification settings - Fork 98
Limit parameters to mojos which actually use them #866
Description
Looking at sources I noticed that a lot of mojo parameters and helper methods were defined in an unnecessarily high superclass (used only in a specific subclass). It would be better to push things down into more appropriate places.
It would also be nice to remove gratuitous getter/setter pattern in favor of simple fields (docs clarify that the JavaBeans pattern is an option helpful for integrating with other code, which is not relevant in this context) and limiting Java access to private or protected as appropriate.
Classes to consider:
AbstractJenkinsMojoAbstractHpiMojoAbstractJenkinsManifestMojo
Attempted in #562 but stalled out. Probably better to do this incrementally so as to produce smaller PRs that can be reviewed and merged in a timely fashion without risking merge conflicts.
Reminded of this because even after #862 I checked run parameters
help output
[INFO] Maven Jenkins Plugin 3.1801.v26037216c7d3
Maven2 plugin for developing Jenkins plugins
hpi:run
Runs Jenkins with the current plugin project using Winstone (java -jar
jenkins.war).
Available parameters:
bundledArtifacts (Default: ${hpi.bundledArtifacts})
A list of comma-separated Maven artifact IDs that correspond to Jar files
that are expected to be bundled in the plugin's HPI file. If this list
does not match the actual bundled artifacts, the build will either fail if
strictBundledArtifacts is enabled, or a warning will be logged otherwise.
classesDirectory (Default: ${project.build.outputDirectory})
The directory containing generated classes.
containerConfigXML (Default: ${maven.war.containerConfigXML})
The path to the context.xml file to use.
debugForkedProcess
Attach a debugger to the forked JVM. If set to "true", the process will
suspend and wait for a debugger to attach on a random port. If set to some
other string, that string will be appended to the argLine, allowing you to
configure arbitrary debuggability options.
User property: maven.hpi.debug
debugPort (Default: 5005)
Port number for the debugger to attach to.
Not used if maven.hpi.debug is specified with a custom debug value.
User property: maven.hpi.debug.port
defaultHost (Default: localhost)
Specifies the host (network interface) to bind to.
If connectors are configured in the Mojo, that'll take precedence.
User property: host
defaultPort (Default: 8080)
Specifies the HTTP port number.
If connectors are configured in the Mojo, that'll take precedence.
User property: port
dependencyResolution (Default: test)
Decides the level of dependency resolution.
This controls what plugins are made available to the running Jenkins.
dependentWarExcludes
The comma separated list of tokens to exclude when doing a way overlay.
dependentWarIncludes (Default: **)
The comma separated list of tokens to include when doing a war overlay.
failOnVersionOverrideToDifferentRelease (Default: true)
Controls the safety check that prevents a snapshotPluginVersionOverride
from switching to a different release version.
filters (Default: ${project.build.filters})
jenkinsCoreId
Optional string that represents "groupId:artifactId" of Jenkins core jar.
If left unspecified, the default groupId/artifactId pair for Jenkins is
looked for.
jenkinsCoreVersionOverride
Optional string that represents the version of Jenkins core to report
plugins as requiring. This parameter is only used when unbundling
functionality from Jenkins core and the version specified will be ignored
if older than the autodetected version.
jenkinsHome (Default: ${JENKINS_HOME})
Path to $JENKINS_HOME. The launched Jenkins will use this directory as the
workspace.
User property: jenkinsHome
jenkinsWarId
Optional string that represents "groupId:artifactId" of Jenkins war. If
left unspecified, the default groupId/artifactId pair for Jenkins is
looked for.
jvmArgs (Default: -Xms512M -Xmx1G -XX:+HeapDumpOnOutOfMemoryError
@{jenkins.addOpens})
JVM arguments to be passed when running the Jenkins instance.
User property: maven.hpi.run.jvmArgs
loggers
List of loggers to define. Keys are logger names (usually package or class
names); values are level names (such as FINE).
maskClasses
[ws|tab|CR|LF]+ separated list of package prefixes that your plugin
doesn't want to see from the core.
Tokens in this list is prefix-matched against the fully-qualified class
name, so add "." to the end of each package name, like "com.foo. com.bar."
outputDirectory (Default: ${project.build.directory})
The directory for the generated WAR.
pluginFirstClassLoader
Change the classloader preference such that classes locally bundled in
this plugin will take precedence over those that are defined by the
dependency plugins.
This is useful if the plugins that you want to depend on exposes
conflicting versions of the libraries you are using, but enabling this
switch makes your code susceptible to classloader constraint violations.
pluginName (Default: ${project.name})
Name of the plugin that Jenkins uses for display purpose. It should be one
line text.
pluginVersionDescription (Default: ${plugin.version.description})
Additional information that accompanies the version number of the plugin.
Useful to distinguish snapshot builds. For example, if you are building
snapshot plugins from Jenkins, you can put the build number in here by
running Maven with "-Dplugin.version.description=$BUILD_TAG"
snapshotPluginVersionOverride
Optional - the version to use in place of the project version in the event
that the project version is a -SNAPSHOT. If specified, the value must
start with the project version after removing the terminal -SNAPSHOT, for
example if the project version is 1.2.3-SNAPSHOT then the
snapshotPluginVersionOverride could be 1.2.3-rc45.cafebabe-SNAPSHOT or
1.2.3-20180430.123233-56, etc, but it could not be 1.2.4 as that does not
start with the project version. When testing plugin builds on a locally
hosted update centre, in order to be allowed to update the plugin, the
update centre must report the plugin version as greater than the currently
installed plugin version. If you are using a Continuous Delivery model for
your plugin (i.e. where the master branch stays on a version like
1.x-SNAPSHOT and releases are tagged but not merged back to master (in
order to prevent merge conflicts) then you will find that you cannot
update the plugin when building locally as 1.x-SNAPSHOT is never less than
1.x-SNAPSHOT. Thus in order to test plugin upgrade (in say an acceptance
test), you need to override the plugin version for non-releases. Typically
you would use something like git-timestamp-maven-plugin
<https://github.com/stephenc/git-timestamp-maven-plugin> to populate a
property with the version and then use this configuration to provide the
version.
See also: failOnVersionOverrideToDifferentRelease
strictBundledArtifacts (Default: ${hpi.strictBundledArtifacts})
If true, then if bundledArtifacts does not match the actual list of
bundled artifacts, the build will fail.
systemProperties
Compatibility shim for older configurations which used Jetty's config.
These will be passed to the forked Jenkins JVM as -Dkey=value.
warSourceDirectory (Default: ${basedir}/src/main/webapp)
Single directory for extra files to include in the WAR.
warSourceExcludes
The comma separated list of tokens to exclude from the WAR.
warSourceIncludes (Default: **)
The comma separated list of tokens to include in the WAR.
webApp
Compatibility shim for older configurations which used Jetty's config. We
currently use it only for the contextPath/prefix mapping.
webAppFile
The location of the war file.
Normally this should be left empty, in which case the plugin loads it from
the repository. But this parameter allows that to be overwritten.
User property: webAppFile
webResources
The list of webResources we want to transfer.
webappDirectory (Default:
${project.build.directory}/${project.build.finalName})
The directory where the webapp is built.
wildcardDNS
Optional wildcard DNS domain to help set a distinct Jenkins root URL from
every plugin. Just prints a URL you ought to set. The domain suffix is
expected to be prepended with an identifier and an IP address
(xxx.127.0.0.1.$suffix). Recommended: nip.io but consider
wildcardLocalhostDNS instead.
User property: wildcardDNS
wildcardLocalhostDNS
Optional wildcard localhost DNS domain to help set a distinct Jenkins root
URL from every plugin. Just prints a URL you ought to set. The domain
suffix is expected to be prepended with an identifier (xxx.$suffix) and to
resolve to localhost. Recommended: localtest.me
User property: wildcardLocalhostDNS
winstoneArgs
Arguments to pass to Winstone, e.g. --enable-future-java.
User property: maven.hpi.winstoneArgs
workDirectory (Default: ${project.build.directory}/war/work)
Directory to unpack dependent WARs into if needed
and you can see for example dependentWarIncludes which AFAICT by code inspection is only actually used by the hpi mojo.