Skip to content

Commit

Permalink
Again splitting up consume-incrementals from produce-incrementals pro…
Browse files Browse the repository at this point in the history
…files, and [JENKINS-50689] formally documenting their usage.
  • Loading branch information
jglick committed Apr 10, 2018
1 parent 3cc4594 commit 5b2f11d
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 35 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -53,6 +53,11 @@ If you had a `jar:test-jar` execution, delete it and add to `properties`:
<no-test-jar>false</no-test-jar>
```

## Incrementals

You can configure your plugin to treat every commit as a release candidate.
See [Incrementals](incrementals.md) for details.

## Baselines

It is handy to be able to select different Jenkins baselines with a Maven profile.
Expand Down
94 changes: 94 additions & 0 deletions incrementals.md
@@ -0,0 +1,94 @@
# Incrementals

See [JENKINS-50686](https://issues.jenkins-ci.org/browse/JENKINS-50686) for status and context.

## 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/).
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
<servers>
<server>
<id>incrementals</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
```

and then add to command lines:

```
-Dincrementals.url=http://localhost:8081/repository/maven-releases/
```

## Enabling production of incrementals

To produce incremental artifacts _from_ your plugin, first edit your `pom.xml`.
If your plugin declares

```xml
<version>1.23-SNAPSHOT</version>
```

then replace that with

```xml
<version>${revision}${changelist}</version>
```

and then in the `<properties>` section add

```xml
<revision>1.23</revision>
<changelist>-SNAPSHOT</changelist>
```

Now run

```bash
echo .flattened-pom.xml >> .gitignore
```

Finally, configure [git-changelist-maven-extension](https://github.com/jglick/git-changelist-maven-extension) in `.mvn/extensions.xml`:

```xml
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</extension>
</extensions>
```

Now if you are authorized to deploy to the Incrementals repository you could run:

```bash
mvn -Dset.changelist clean deploy
```

(See above for local testing; the same `incrementals.url` property may be used to override the deployment destination.)

To produce equivalent artifacts in your local repository while working offline:

```bash
mvn -Dset.changelist -DskipTests clean install
```

If you do not select the `-Pproduce-incrementals -Dset.changelist` options, you will create a regular `*-SNAPSHOT` artifact.
79 changes: 44 additions & 35 deletions pom.xml
Expand Up @@ -104,6 +104,7 @@
<access-modifier-checker.version>${access-modifier.version}</access-modifier-checker.version>
<!-- To opt in to @Restricted(Beta.class) APIs, set to true: -->
<useBeta>false</useBeta>
<incrementals.url>https://repo.jenkins-ci.org/incrementals/</incrementals.url>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -1261,41 +1262,8 @@
</build>
</profile>
<profile>
<!-- https://maven.apache.org/docs/3.3.1/release-notes.html#JVM_and_Command_Line_Options -->
<!-- mkdir -p .mvn && echo -Pincrementals >> .mvn/maven.config -->
<!--
<version>${revision}${changelist}</version>
<properties>
<revision>1.23</revision>
<changelist>-SNAPSHOT</changelist>
</properties>
-->
<!-- echo .flattened-pom.xml >> .gitignore -->
<!-- Configure https://github.com/jglick/git-changelist-maven-extension in .mvn/extensions.xml: -->
<!--
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</extension>
</extensions>
-->
<!-- Now just run: mvn -Pjenkins-release -Dset.changelist clean deploy # -Drelease.skipTests=false -->
<!-- ~/.m2/settings.xml:
<servers>
<server>
<id>incrementals</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
-->
<id>incrementals</id>
<properties>
<!-- Override with -Dincrementals.url=http://localhost:8081/repository/maven-releases/ for testing after: docker run -\-rm -\-name nexus -p 8081:8081 -v nexus-data:/nexus-data sonatype/nexus3 -->
<incrementals.url>https://repo.jenkins-ci.org/incrementals/</incrementals.url>
</properties>
<!-- see incrementals.md -->
<id>consume-incrementals</id>
<repositories>
<repository>
<id>incrementals</id>
Expand All @@ -1314,6 +1282,15 @@
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>produce-incrementals</id>
<activation>
<property>
<name>set.changelist</name>
<value>true</value>
</property>
</activation>
<distributionManagement>
<repository>
<id>incrementals</id>
Expand Down Expand Up @@ -1350,6 +1327,38 @@
</execution>
</executions>
</plugin>
<!-- Copied from jenkins-release: -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>attach-test-sources</id>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<skipSource>${no-test-jar}</skipSource>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down

0 comments on commit 5b2f11d

Please sign in to comment.