Skip to content

Commit a49cec8

Browse files
authored
Merge pull request #82 from cyberark/6-maven-central-publishing
6 Support for Maven Central Publishing
2 parents 1cc283a + 38a9a44 commit a49cec8

33 files changed

+418
-106
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [3.0.0] - 2020-06-22
810
### Fixed
911
- Encode spaces to "%20" instead of "+". This encoding fixes an issue where Conjur
1012
variables that have spaces were not encoded correctly
@@ -17,6 +19,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1719
code
1820
- README has been updated with example SSLContext setup and it's use in Conjur
1921
class constructors
22+
- Introduced [upgrade instructions](https://github.com/cyberark/conjur-api-java/UPGRADING.md) to provide instructions for
23+
upgrading to 3.0.0, or make use of published artifacts. These can be found in
24+
`UPGRADING.md`. ([cyberark/conjur-api-java#77](https://github.com/cyberark/conjur-api-java/issues/77))
25+
26+
### Changed
27+
- Revised package references from `net.conjur.api` to `com.cyberark.conjur.api`
28+
([cyberark/conjur-api-java#6](https://github.com/cyberark/conjur-api-java/issues/6))
2029

2130
## [2.2.1] - 2020-05-08
2231
### Fixed
@@ -55,7 +64,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5564
- Authn tokens now use the new Conjur 5 format - [PR #21](https://github.com/cyberark/conjur-api-java/pull/21)
5665
- Configuration change. When using environment variables, use `CONJUR_AUTHN_LOGIN` and `CONJUR_AUTHN_API_KEY` now instead of `CONJUR_CREDENTIALS` - https://github.com/cyberark/conjur-api-java/commit/60344308fc48cb5380c626e612b91e1e720c03fb
5766

58-
[Unreleased]: https://github.com/cyberark/conjur-api-java/compare/v2.2.1...HEAD
67+
[Unreleased]: https://github.com/cyberark/conjur-api-java/compare/v3.0.0...HEAD
68+
[3.0.0]: https://github.com/cyberark/conjur-api-java/compare/v2.2.1...v3.0.0
5969
[2.0.0]: https://github.com/cyberark/conjur-api-java/compare/v1.1.0...v2.0.0
6070
[2.1.0]: https://github.com/cyberark/conjur-api-java/compare/v2.0.0...v2.1.0
6171
[2.2.0]: https://github.com/cyberark/conjur-api-java/compare/v2.1.0...v2.2.0

Jenkinsfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pipeline {
2020
}
2121
}
2222
}
23-
23+
2424
stage('Create and archive the Maven package') {
2525
steps {
2626
sh './bin/build.sh'
@@ -37,12 +37,21 @@ pipeline {
3737
}
3838
}
3939

40-
stage('Publish the Maven package') {
40+
stage('Perform Snapshot Deployment') {
4141
when {
4242
branch 'master'
4343
}
4444
steps {
45-
echo 'TODO'
45+
sh 'summon ./bin/deploy-snapshot.sh'
46+
}
47+
}
48+
49+
stage('Perform Release Deployment') {
50+
when {
51+
buildingTag()
52+
}
53+
steps {
54+
sh 'summon ./bin/deploy-release.sh'
4655
}
4756
}
4857
}

README.md

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To do so from the source using Maven, following the setup steps below:
4242

4343
```xml
4444
<dependency>
45-
<groupId>net.conjur.api</groupId>
45+
<groupId>com.cyberark.conjur.api</groupId>
4646
<artifactId>conjur-api</artifactId>
4747
<version>2.2.0</version>
4848
<dependency>
@@ -95,12 +95,76 @@ our [Contributing](https://github.com/cyberark/conjur-api-java/blob/master/CONTR
9595
or
9696
```sh-session
9797
$ mvn install:install-file -Dfile=/path/to/api/repo/target/conjur-api-$VERSION-with-dependencies.jar \
98-
-DgroupId=net.conjur.api \
98+
-DgroupId=com.cyberark.conjur.api \
9999
-DartifactId=conjur-api \
100100
-Dversion=$VERSION \
101101
-Dpackaging=jar
102102
```
103103

104+
### Using Maven Releases
105+
106+
To make use of tagged releases published to Maven, verify that you have the dependency
107+
added to your `pom.xml`
108+
109+
1. Add the following snippet to `pom.xml`
110+
```xml
111+
<dependency>
112+
<groupId>com.cyberark.conjur.api</groupId>
113+
<artifactId>conjur-java-api</artifactId>
114+
<version>x.x.x</version>
115+
</dependency>
116+
```
117+
118+
### Using Maven Snapshots
119+
To make use of SNAPSHOTS, which are deployed following a nightly build, there are
120+
several steps required for configuring your project.
121+
122+
> Note: Snapshots contain the latest changes to `conjur-java-api`, but it is recommended
123+
> to use the current stable release unless there is a significant update required by your
124+
> project
125+
126+
1. Add the following to your `settings.xml`
127+
```xml
128+
<profiles>
129+
<profile>
130+
<id>allow-snapshots</id>
131+
<activation><activeByDefault>true</activeByDefault></activation>
132+
<repositories>
133+
<repository>
134+
<id>snapshots-repo</id>
135+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
136+
<releases><enabled>false</enabled></releases>
137+
<snapshots><enabled>true</enabled></snapshots>
138+
</repository>
139+
</repositories>
140+
</profile>
141+
</profiles>
142+
```
143+
144+
Alternatively, add the following to your list of repositories in `pom.xml`
145+
```xml
146+
<repository>
147+
<id>oss.sonatype.org-snapshot</id>
148+
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
149+
<releases>
150+
<enabled>false</enabled>
151+
</releases>
152+
<snapshots>
153+
<enabled>true</enabled>
154+
</snapshots>
155+
</repository>
156+
```
157+
158+
2. In your `pom.xml`, verify that your `conjur-java-api` dependency includes `SNAPSHOT`
159+
in the version tag.
160+
```xml
161+
<dependency>
162+
<groupId>com.cyberark.conjur.api</groupId>
163+
<artifactId>conjur-java-api</artifactId>
164+
<version>x.x.x-SNAPSHOT</version>
165+
</dependency>
166+
```
167+
104168
## Configuration
105169

106170
Once the setup steps have been successfully run, we will now define the variables needed
@@ -317,7 +381,7 @@ export CONJUR_AUTHN_LOGIN=<user/host identity>
317381
export CONJUR_AUTHN_API_KEY=<user/host API key or password - see notes about `CONJUR_AUTHN_URL`>
318382
```
319383
```java
320-
import net.conjur.api.Conjur;
384+
import com.cyberark.conjur.api.Conjur;
321385

322386
// Configured using environment variables
323387
Conjur conjur = new Conjur();
@@ -335,7 +399,7 @@ $ java -jar myConjurClient.jar \
335399
-DCONJUR_AUTHN_API_KEY=<user/host API key - see notes about `CONJUR_AUTHN_URL`>
336400
```
337401
```java
338-
import net.conjur.api.Conjur;
402+
import com.cyberark.conjur.api.Conjur;
339403

340404
// Configured using system properties
341405
Conjur conjur = new Conjur();
@@ -354,7 +418,7 @@ $ mvn exec:java \
354418
-Dexec.mainClass="com.myorg.client.App"
355419
```
356420
```java
357-
import net.conjur.api.Conjur;
421+
import com.cyberark.conjur.api.Conjur;
358422

359423
// Configured using system properties
360424
Conjur conjur = new Conjur();
@@ -370,7 +434,7 @@ export CONJUR_APPLIANCE_URL=<Conjur endpoint URL>
370434
```
371435

372436
```java
373-
import net.conjur.api.Conjur;
437+
import com.cyberark.conjur.api.Conjur;
374438

375439
// Authenticate using provided username/hostname and password/API key. See notes about
376440
// `CONJUR_AUTHN_URL` regarding how 'password-or-api-key' is processed.
@@ -389,8 +453,8 @@ export CONJUR_APPLIANCE_URL=<Conjur endpoint URL>
389453
```
390454

391455
```java
392-
import net.conjur.api.Conjur;
393-
import net.conjur.api.Credentials;
456+
import com.cyberark.conjur.api.Conjur;
457+
import com.cyberark.conjur.api.Credentials;
394458

395459
// Authenticate using a Credentials object. See notes about `CONJUR_AUTHN_URL`
396460
// regarding how 'password-or-api-key' is processed.
@@ -410,8 +474,8 @@ export CONJUR_APPLIANCE_URL=<Conjur endpoint URL>
410474
```
411475

412476
```java
413-
import net.conjur.api.Conjur;
414-
import net.conjur.api.Token;
477+
import com.cyberark.conjur.api.Conjur;
478+
import com.cyberark.conjur.api.Token;
415479

416480
Token token = Token.fromFile(Paths.get('path/to/conjur/authentication/token.json'));
417481
Conjur conjur = new Conjur(token);
@@ -428,8 +492,8 @@ export CONJUR_APPLIANCE_URL=<Conjur endpoint URL>
428492
export CONJUR_AUTHN_TOKEN_FILE="path/to/conjur/authentication/token.json"
429493
```
430494
```java
431-
import net.conjur.api.Conjur;
432-
import net.conjur.api.Token;
495+
import com.cyberark.conjur.api.Conjur;
496+
import com.cyberark.conjur.api.Token;
433497

434498
Token token = Token.fromEnv();
435499
Conjur conjur = new Conjur(token);
@@ -443,7 +507,7 @@ To use the client, you will first create an instance of the client and then call
443507
to send requests to the Conjur API. The most common use case is adding and retrieving
444508
a secret from Conjur, so we provide some sample code for this use case below.
445509

446-
### Conjur Client Instance (`net.conjur.api.Conjur`)
510+
### Conjur Client Instance (`com.cyberark.conjur.api.Conjur`)
447511

448512
The client can be instantiated with any of these methods:
449513
```java
@@ -471,7 +535,7 @@ Sets a variable to a specific value based on its ID.
471535

472536
Example:
473537
```java
474-
import net.conjur.api.Conjur;
538+
import com.cyberark.conjur.api.Conjur;
475539

476540
Conjur conjur = new Conjur();
477541
conjur.variables().addSecret(VARIABLE_ID, VARIABLE_VALUE);
@@ -487,7 +551,7 @@ Retireves a variable based on its ID.
487551

488552
Example:
489553
```java
490-
import net.conjur.api.Conjur;
554+
import com.cyberark.conjur.api.Conjur;
491555

492556
Conjur conjur = new Conjur();
493557
conjur.variables().retrieveSecret("<VARIABLE_ID>");
@@ -504,7 +568,7 @@ alternative implementation.
504568

505569
## Troubleshooting
506570

507-
### `error: package net.conjur does not exist`
571+
### `error: package com.cyberark.conjur does not exist`
508572

509573
This is caused by Maven's (or your dependency resolution tooling) inability to find Conjur
510574
APIs. Please ensure that you have followed the [setup](#setup) section to properly install

UPGRADING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Upgrading Conjur Java API
2+
3+
This guide describes how to upgrade your project to use Conjur Java API.
4+
5+
The main scenario covered in this document is migrating a project with a Conjur-Java-API
6+
to v3.0.0.
7+
8+
For more details about using the Conjur API, or contributing to development, please
9+
refer to the [Conjur Java API](https://github.com/cyberark/conjur-api-java).
10+
11+
For further assistance installing and configuring the Conjur Java API,
12+
please refer to the [Setup](README.md#Setup) section of
13+
the Conjur Java API [README.md](README.md) file.
14+
15+
## Migrating to 3.0.0
16+
17+
With the update to v.3.0.0, the Conjur Java API now makes use of the `com.cyberark`
18+
project namespace. This allows us to publish artifacts to this namespace, which are
19+
immediately available to use in project. As such, your project can make use of the
20+
Conjur Java API without needing to build the Jarfile locally.
21+
22+
### Changes to your code base
23+
Due to the change to the project namespace, we have modified the package name from
24+
`net.conjur.api` to `com.cyberark.conjur.api`. As such, all import statements must be
25+
updated to reflect this.
26+
27+
### Example
28+
Before:
29+
```java
30+
import net.conjur.api.AuthnProvider
31+
```
32+
33+
After:
34+
```java
35+
import com.cyberark.conjur.api.AuthnProvider
36+
```
37+
38+
### Changes to your `pom.xml`
39+
Due to the change to the project namespace, we have modified the package name from
40+
`net.conjur.api` to `com.cyberark.conjur.api`. As such, your dependency configuration
41+
must be updated to reflect this.
42+
43+
### Example
44+
Before:
45+
```xml
46+
<dependency>
47+
<groupId>net.conjur.api</groupId>
48+
<artifactId>conjur-api</artifactId>
49+
<version>2.2.0</version>
50+
<dependency>
51+
```
52+
53+
After:
54+
```xml
55+
<dependency>
56+
<groupId>com.cyberark.conjur.api</groupId>
57+
<artifactId>conjur-api</artifactId>
58+
<version>3.0.0</version>
59+
<dependency>
60+
```

bin/build.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env bash
22
set -eo pipefail
33

4-
5-
#TODO - add rest of steps needed to build the package
6-
7-
docker run --rm -v "$PWD:/conjurinc/api-java" -w /conjurinc/api-java maven:3-jdk-8 /bin/bash -c \
8-
"mvn -X -e clean package -Dmaven.test.skip=true"
4+
docker run --rm \
5+
-v "$PWD:/cyberark/conjur-java-api" \
6+
-w /cyberark/conjur-java-api maven:3-jdk-8 \
7+
/bin/bash -ec "mvn -X -e clean package -Dmaven.test.skip=true"

bin/deploy-release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -exo pipefail
3+
4+
# Strip the 'v' from the Tag Name
5+
export TAG=${TAG_NAME//"v"}
6+
7+
# Deploy release to Sonatype OSSRH (OSS Repository Hosting)
8+
# Setup: Import our GPG key and passphrase
9+
# 1. Set the version in the POM to the Tagged Version
10+
# 2. Sign our build and deploy to OSSRH
11+
# 3. Release our staged deployment
12+
#
13+
# Note: The autoReleaseAfterClose for the nexus-staging-maven-plugin should be
14+
# set to "false" if we do not want releases published automatically
15+
docker run --rm \
16+
-e OSSRH_USERNAME \
17+
-e OSSRH_PASSWORD \
18+
-v "$PWD:/cyberark/conjur-java-api" \
19+
-v "$GPG_PASSWORD:/gpg_password" \
20+
-v "$GPG_PRIVATE_KEY:/gpg_key" \
21+
-w /cyberark/conjur-java-api maven:3-jdk-8 \
22+
/bin/bash -ec "gpg --batch --passphrase-file /gpg_password --trust-model always --import /gpg_key
23+
mvn versions:set -DnewVersion=${TAG}
24+
mvn --settings settings.xml clean deploy -Dmaven.test.skip=true -P ossrh,sign
25+
mvn nexus-staging:release"

bin/deploy-snapshot.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -exo pipefail
3+
4+
# Deploy snapshot to Sonatype OSSRH (OSS Repository Hosting)
5+
# Setup: Import our GPG key and passphrase
6+
# 1. Deploy to snapshot repository of OSSRH
7+
#
8+
# Note: Snapshot releases do not need to meet Maven central requirements,
9+
# but it is best to do so whenever possible
10+
docker run --rm \
11+
-e OSSRH_USERNAME \
12+
-e OSSRH_PASSWORD \
13+
-v "$PWD:/cyberark/conjur-java-api" \
14+
-v "$GPG_PASSWORD:/gpg_password" \
15+
-v "$GPG_PRIVATE_KEY:/gpg_key" \
16+
-w /cyberark/conjur-java-api maven:3-jdk-8 \
17+
/bin/bash -ec "gpg --batch --passphrase-file /gpg_password --trust-model always --import /gpg_key
18+
mvn --settings settings.xml clean deploy -Dmaven.test.skip=true -P ossrh,sign"

0 commit comments

Comments
 (0)