diff --git a/incrementals.md b/incrementals.md new file mode 100644 index 0000000..0efafd6 --- /dev/null +++ b/incrementals.md @@ -0,0 +1,164 @@ +# Incrementals + +See [JEP-305](https://github.com/jenkinsci/jep/blob/master/jep/305/README.adoc) for context. + +## Usage in plugin POMs + +Since most Jenkins repositories host plugins, this use case will be documented first. + +### Enabling consumption of incrementals + +If your plugin has (or may have) dependencies on incremental versions, run: + +```bash +mkdir -p .mvn +echo -Pconsume-incrementals >> .mvn/maven.config +git add .mvn +``` + +(See [this guide](https://maven.apache.org/docs/3.3.1/release-notes.html#JVM_and_Command_Line_Options) for details on the `.mvn` directory.) + +This profile merely activates access to the [Incrementals repository](https://repo.jenkins-ci.org/incrementals/). + +### Enabling production of incrementals + +To produce incremental artifacts _from_ your plugin, first edit your `pom.xml`. +If your plugin declares + +```xml +1.23-SNAPSHOT +``` + +then replace that with + +```xml +${revision}${changelist} +``` + +and then in the `` section add + +```xml +1.23 +-SNAPSHOT +``` + +If you have a multimodule reactor build, the new `properties` need be defined only in the root POM, +but every child POM should use the edited `version` to refer to its `parent`. +(It should _not_ override the `version`.) +Intermodule `dependency`es may use `${project.version}` to refer to the `version` of the sibling. + +Also change + +```xml + + + HEAD + +``` + +to + + +```xml + + + ${scmTag} + +``` + +Now run + +```bash +mkdir -p .mvn +echo -Pmight-produce-incrementals >> .mvn/maven.config +echo .flattened-pom.xml >> .gitignore +git add .mvn .gitignore +``` + +Finally, configure [git-changelist-maven-extension](https://github.com/jglick/git-changelist-maven-extension) in `.mvn/extensions.xml`: + +```xml + + + io.jenkins.tools + git-changelist-maven-extension + 1.0-alpha-3 + + +``` + +Commit and push your edits. +Now if you are authorized to deploy to the Incrementals repository you could run: + +```bash +mvn -Dset.changelist clean deploy +``` + +To produce equivalent artifacts in your local repository while working offline: + +```bash +mvn -Dset.changelist -DskipTests clean install +``` + +If you do not select the `-Dset.changelist` option, you will create a regular `*-SNAPSHOT` artifact. +(And that is what you _must_ do if you have any local modifications or untracked files.) + +### Running Maven releases + +You may still use the Maven release plugin (MRP) when `might-produce-incrementals` is activated: + +```bash +mvn -B release:{prepare,perform} +``` + +The released artifacts should have sensible metadata. +(You may notice that they deploy a “flattened” POM file, but this should not break anything.) +However, after performing a traditional release, to resume being able to produce incrementals you must run: + +```bash +mvn help:evaluate -Dexpression=project.version -Doutput=version && \ +mvn versions:set -Ddollar='$' -DnewVersion='${dollar}{revision}${dollar}{changelist}' -DgenerateBackupPoms=false && \ +mvn versions:set-property -Dproperty=revision -DnewVersion=`sed -e 's/-SNAPSHOT$//' < version` -DgenerateBackupPoms=false && \ +rm version +``` + + + +and commit and push the resulting `pom.xml` edits. + +## Usage in other POMs + +From repositories with POMs not inheriting from `org.jenkins-ci.plugins:plugin` you can follow similar steps to use Incrementals. +If you inherit from `org.jenkins-ci:jenkins`, the same profiles are available; +otherwise you will need to copy the definitions of the `consume-incrementals`, `might-produce-incrementals`, and `produce-incrementals` profiles from `org.jenkins-ci:jenkins`, +as well as the `incrementals.url` and `scmTag` properties, +into your parent POM or directly into your repository POM. +Some adjustment of `maven-enforcer-plugin` configuration may also be necessary. + +## Offline testing + +If you wish to test usage offline, run + +```bash +docker run --rm --name nexus -p 8081:8081 -v nexus-data:/nexus-data sonatype/nexus3 +``` + +add to your `~/.m2/settings.xml`: + +```xml + + + incrementals + admin + admin123 + + +``` + +and then add to command lines consuming or producing incremental versions: + +``` +-Dincrementals.url=http://localhost:8081/repository/maven-releases/ +``` + +or define an equivalent profile in local settings. diff --git a/pom.xml b/pom.xml index 577c9da..c73e4d1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,10 +12,6 @@ http://jenkins-ci.org/ 2004 - - 2.2.1 - - JIRA http://issues.jenkins-ci.org @@ -638,9 +634,11 @@ [3.3.9,) 3.3.9 is required at least. + [1.${java.level}.0,] @@ -674,10 +672,6 @@ (or just override java.level) --> - - No Snapshots Allowed For Release Versions - true - @@ -739,6 +733,118 @@ always + + consume-incrementals + + + incrementals + ${incrementals.url} + + false + + + + + + incrementals + ${incrementals.url} + + false + + + + + + might-produce-incrementals + + + + org.codehaus.mojo + flatten-maven-plugin + 1.0.1 + + true + + + + flatten + process-resources + + flatten + + + oss + + + + flatten.clean + clean + + clean + + + + + + maven-enforcer-plugin + + + display-info + + + + [3.5.0,) + 3.5.0+ required to use Incrementals. + + + + + + + + + + + produce-incrementals + + + set.changelist + true + + + + + incrementals + ${incrementals.url} + + + + + + maven-source-plugin + + + attach-sources + + jar + + + + + + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + + @@ -765,6 +871,9 @@ Generally it is recommended to use @SuppressFBWarnings annotation unless you want to ignore an entire class of issues --> + https://repo.jenkins-ci.org/incrementals/ + HEAD + 1.16 1.0-alpha-5 @@ -793,8 +902,8 @@ 2.10 3.0.0-M1 1.6 - 2.2 - 2.0 + 3.0.1 + 2.3 2.2 2.5.2 3.0.0-M1