Skip to content

feat(build): maven refactor for maven central #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
server-id: github
- name: Maven Verify
run: |
mvn --batch-mode clean install -DskipTests
mvn --batch-mode verify
env:
BUF_INPUT_HTTPS_USERNAME: opentdf-bot
Expand Down
39 changes: 37 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
release:
types: [created]

permissions:
contents: read
Expand Down Expand Up @@ -43,8 +45,41 @@ jobs:
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish package
run: mvn --batch-mode deploy -DskipTests
- name: Publish to GitHub Packages
if: github.ref == 'refs/heads/main'
run: |
mkdir -p $HOME/.m2
cat > $HOME/.m2/settings.xml <<EOF
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers><server>
<id>github-pkg</id>
<username>${{ secrets.GITHUB_USERNAME }}</username>
<password>${{ secrets.GITHUB_TOKEN }}</password>
</server></servers>
</settings>
EOF
mvn --batch-mode deploy -DskipTests -P stage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUF_INPUT_HTTPS_USERNAME: opentdf-bot
BUF_INPUT_HTTPS_PASSWORD: ${{ secrets.PERSONAL_ACCESS_TOKEN_OPENTDF }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }}
- name: Publish to Maven Central
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p $HOME/.m2
cat > $HOME/.m2/settings.xml <<EOF
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers><server>
<id>central</id>
<username>${{ secrets.MAVEN_USERNAME }}</username>
<password>${{ secrets.MAVEN_PASSWORD }}</password>
</server></servers>
</settings>
EOF
mvn --batch-mode deploy -DskipTests -P release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUF_INPUT_HTTPS_USERNAME: opentdf-bot
Expand Down
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The Clear BSD License

Copyright (c) 2021-2022 Virtru Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below)
provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Virtru Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without
specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import java.io.InputStream;
import java.io.FileInputStream;

public class Example {
public static void main(String args[]) {
public static void main(String[] args) {
SDK sdk =
new SDKBuilder
.clientSecret("myClient", "token")
.platformEndpoint("https://your.cluster/")
.build();
// Encrypt a file
try (InputStream in = new FileInputStream("input.plaintext")) {
Config c = Config.newTDFConfig(Config.withDataAttributes("attr1", "attr2"))
Config c = Config.newTDFConfig(Config.withDataAttributes("attr1", "attr2"));
new TDF().createTDF(in, System.out, tdfConfig, sdk.getServices().kas());
}

Expand All @@ -43,7 +43,7 @@ public class Example {
TDF.Reader reader = new TDF().loadTDF(in, sdk.getServices().kas());
reader.readPayload(System.out);
}
}
}}
```

### Cryptography Library
Expand All @@ -70,5 +70,16 @@ Use the SDKBuilder.withSSL... methods to build an SDKBuilder with:

### Maven Modules
- cmdline: Command line utility
- protocol: Buf generated source code from opentdf proto definitions
- sdk: The OpenTDF Java SDK

### Buf

Create an account, link with GitHub, under User setting, Create a `token`

```shell
[INFO] --- antrun:3.1.0:run (generateSources) @ sdk ---
[INFO] Executing tasks
[INFO] [exec] Failure: too many requests
[INFO] [exec]
[INFO] [exec] Please see https://buf.build/docs/bsr/rate-limits for details about BSR rate limiting.
```
12 changes: 1 addition & 11 deletions cmdline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.opentdf.platform.TDF</mainClass>
<manifestEntries>
<Implementation-Version>${version}</Implementation-Version>
<Implementation-Version>${project.version}</Implementation-Version>
<Main-Class>io.opentdf.platform.TDF</Main-Class>
</manifestEntries>
</transformer>
Expand All @@ -56,16 +56,6 @@
</execution>
</executions>
</plugin>

<!-- Skip deployment for this child module -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
129 changes: 65 additions & 64 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<groupId>io.opentdf.platform</groupId>
<artifactId>sdk-pom</artifactId>
<version>0.7.0-SNAPSHOT</version>
<name>sdk-pom</name>
<name>io.opentdf.platform:sdk-pom</name>
<description>OpenTDF Java SDK</description>
<url>https://github.com/opentdf/java-sdk</url>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -19,6 +21,18 @@
<protobuf.version>3.25.3</protobuf.version>
<sslcontext.version>8.3.5</sslcontext.version>
</properties>
<licenses>
<license>
<name>BSD 3-Clause Clear License</name>
<url>https://spdx.org/licenses/BSD-3-Clause-Clear.html</url>
</license>
</licenses>
<developers>
<developer>
<organization>Virtru</organization>
<organizationUrl>https://www.virtru.com</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/opentdf/java-sdk.git</connection>
<developerConnection>scm:git:[email protected]:opentdf/java-sdk.git</developerConnection>
Expand Down Expand Up @@ -57,18 +71,6 @@
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
Expand Down Expand Up @@ -129,10 +131,6 @@
</plugin>
<!-- default lifecycle, jar packaging: see
https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
Expand All @@ -149,18 +147,10 @@
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.3</version>
</plugin>
<plugin>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
</plugin>
<!-- site lifecycle, see
https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
Expand Down Expand Up @@ -208,23 +198,6 @@
</gpgArguments>
</configuration>
</plugin>
<!-- Plugin for Deploying -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
<!-- Plugin for Nexus Staging -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand Down Expand Up @@ -264,44 +237,72 @@
</execution>
</executions>
</plugin>
<!-- Exclude from lifecycle, phase none -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ghcr</id>
<id>develop</id>
<modules>
<module>sdk</module>
<module>cmdline</module>
</modules>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>stage</id>
<modules>
<module>sdk</module>
</modules>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<distributionManagement>
<repository>
<id>github</id>
<name>ghcr</name>
<id>github-pkg</id>
<name>GitHub opentdf Apache Maven Packages</name>
<url>https://maven.pkg.github.com/opentdf/java-sdk</url>
</repository>
<snapshotRepository>
<id>github</id>
<name>ghcr</name>
<url>https://maven.pkg.github.com/opentdf/java-sdk</url>
</snapshotRepository>
</distributionManagement>
</profile>
<profile>
<id>ossrh</id>
<id>release</id>
<modules>
<module>sdk</module>
</modules>
<activation>
<activeByDefault>true</activeByDefault>
<activeByDefault>false</activeByDefault>
</activation>
<distributionManagement>
<repository>
<id>ossrh</id>
<name>sonatype</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<name>sonatype</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- Publish to Maven Central Deploy -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
<!-- defined in settings.xml -->
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
4 changes: 2 additions & 2 deletions buf.gen.yaml → sdk/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ managed:
- buf.build/grpc-ecosystem/grpc-gateway
plugins:
- plugin: buf.build/protocolbuffers/java:v25.3
out: sdk/src/main/protogen
out: ./
- plugin: buf.build/grpc/java:v1.61.1
out: sdk/src/main/protogen
out: ./
Loading
Loading