Skip to content

Commit

Permalink
Merge pull request #48 from Keyfactor/feat/migrate_erce_to_gradle
Browse files Browse the repository at this point in the history
feat!: converted erce from maven to gradle
  • Loading branch information
mike-agrenius-kushner authored Dec 16, 2024
2 parents f17d428 + cb372c8 commit 433e8d0
Show file tree
Hide file tree
Showing 17 changed files with 529 additions and 252 deletions.
40 changes: 0 additions & 40 deletions .classpath

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.DS_Store
/target/
.gradle
.gradle/**
14 changes: 4 additions & 10 deletions .project
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>erce</name>
<comment></comment>
<name>Easy-Rest-Client-EJBCA</name>
<comment>Project Easy-Rest-Client-EJBCA created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=false
show.console.view=false
show.executions.view=false
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ Erce is a fully FOSS REST Client for EJBCA Community Edition. Its purpose is to

## Get started

Erce is a fully self-contained Maven project. To build:
Erce is a fully self-contained Gradle project. To build:

1. Check out a local branch
2. Build and package using Maven (-llr is for newer versions of maven to recognize the local repository in the lib directory):
2. Build and package using Gradle
```
mvn -llr clean package
./gradlew build
```
3. Run the resulting .jar file with the --help flag to see the available commands.

```
java -jar target/erce-x.y.x-SNAPSHOT.jar --help
java -jar build/erce-x.y.x.jar --help
```
An example command can looks like:

```
java -jar target/erce-0.2.0-SNAPSHOT.jar enroll genkeys --authkeystore /opt/ejbca/p12/superadmin.p12 --authkeystorepass **** --endentityprofile "Server" --certificateprofile "Server" --ca ServerCA --subjectaltname "dnsName=test-erces-01.test" --hostname localhost --destination ./certs --subjectdn "C=SE,O=Keyfactor Community,CN=test-erces-01.test" --username test-erces-01.test -p --keyalg EC --keyspec P-256 --verbose
java -jar build/erce-1.0.0.jar enroll genkeys --authkeystore /opt/ejbca/p12/superadmin.p12 --authkeystorepass **** --endentityprofile "Server" --certificateprofile "Server" --ca ServerCA --subjectaltname "dnsName=test-erces-01.test" --hostname localhost --destination ./certs --subjectdn "C=SE,O=Keyfactor Community,CN=test-erces-01.test" --username test-erces-01.test -p --keyalg EC --keyspec P-256 --verbose
```

## Supported Endpoints
Expand Down
84 changes: 84 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

plugins {
`java-library`
}

repositories {
mavenLocal()
maven {
url = uri("file:////Users/mikek/eclipse-workspace/Easy-Rest-Client-EJBCA/lib")
}

maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}

dependencies {
api(libs.com.googlecode.json.simple.json.simple)
api(libs.org.bouncycastle.bcprov.jdk18on)
api(libs.org.bouncycastle.bcutil.jdk18on)
api(libs.org.bouncycastle.bcpkix.jdk18on)
api(libs.commons.io.commons.io)
api(libs.org.apache.httpcomponents.httpclient)
api(libs.org.apache.logging.log4j.log4j.core)
api(libs.org.apache.logging.log4j.log4j.v1.v2.api)
api(libs.org.apache.commons.commons.lang3)
api(libs.commons.lang.commons.lang)
api(libs.org.codehaus.mojo.exec.maven.plugin)
api(libs.org.jboss.resteasy.resteasy.client)
api(libs.jakarta.ws.rs.jakarta.ws.rs.api)
api(libs.com.keyfactor.keyfactor.commons.cli)
api(libs.com.keyfactor.x509.common.util)
}

tasks.register<Copy>("copyDependencies") {
from(configurations.runtimeClasspath.get().filter { it.name.endsWith(".jar") }) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Options: EXCLUDE, INCLUDE, or WARN
}
into(layout.buildDirectory.dir("lib"))
}

tasks.build {
dependsOn("copyDependencies")
}

tasks.register("cli") {
group = "Application"
description = "Run the EJBCA CLI with arguments."
println("Hello")
}

tasks.jar {
// Specify the directory where the JAR file will be created
destinationDirectory.set(layout.buildDirectory)

manifest {
attributes["Main-Class"] = "com.keyfactor.ejbca.client.ErceClient"
val classPathEntries = configurations.runtimeClasspath.get().map {
"lib/${it.name}" // Prefix each entry with "lib/"
}
attributes("Class-Path" to classPathEntries.joinToString(" "))
}
}

group = "com.keyfactor"
version = "1.0.0"
description = "Easy REST Client for EJBCA"
java.sourceCompatibility = JavaVersion.VERSION_17


sourceSets {
main {
java {
setSrcDirs(listOf("src"))
}
}
test {
java {
setSrcDirs(listOf("src-test"))
}
}
}


6 changes: 6 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/classes/
/lib/
/reports/
/resources/
/tmp/
/erce-*.jar
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.configuration-cache=true
org.gradle.parallel=true
org.gradle.caching=true

38 changes: 38 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
com-googlecode-json-simple-json-simple = "1.1.1"
com-keyfactor-keyfactor-commons-cli = "2.0.0"
com-keyfactor-servicemanifestbuilder = "1.0.2"
com-keyfactor-x509-common-util = "4.1.4"
commons-io-commons-io = "2.18.0"
commons-lang-commons-lang = "2.6"
jakarta-ws-rs-jakarta-ws-rs-api = "4.0.0"
org-apache-commons-commons-lang3 = "3.17.0"
org-apache-httpcomponents-httpclient = "4.5.14"
org-apache-logging-log4j-log4j-core = "2.24.2"
org-apache-logging-log4j-log4j-v1-v2-api = "2.24.2"
org-bouncycastle-bcpkix-jdk18on = "1.79"
org-bouncycastle-bcprov-jdk18on = "1.79"
org-bouncycastle-bcutil-jdk18on = "1.79"
org-codehaus-mojo-exec-maven-plugin = "3.5.0"
org-jboss-resteasy-resteasy-client = "6.2.11.Final"

[libraries]
com-googlecode-json-simple-json-simple = { module = "com.googlecode.json-simple:json-simple", version.ref = "com-googlecode-json-simple-json-simple" }
com-keyfactor-keyfactor-commons-cli = { module = "com.keyfactor:keyfactor-commons-cli", version.ref = "com-keyfactor-keyfactor-commons-cli" }
com-keyfactor-servicemanifestbuilder = { module = "com.keyfactor:servicemanifestbuilder", version.ref = "com-keyfactor-servicemanifestbuilder" }
com-keyfactor-x509-common-util = { module = "com.keyfactor:x509-common-util", version.ref = "com-keyfactor-x509-common-util" }
commons-io-commons-io = { module = "commons-io:commons-io", version.ref = "commons-io-commons-io" }
commons-lang-commons-lang = { module = "commons-lang:commons-lang", version.ref = "commons-lang-commons-lang" }
jakarta-ws-rs-jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "jakarta-ws-rs-jakarta-ws-rs-api" }
org-apache-commons-commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "org-apache-commons-commons-lang3" }
org-apache-httpcomponents-httpclient = { module = "org.apache.httpcomponents:httpclient", version.ref = "org-apache-httpcomponents-httpclient" }
org-apache-logging-log4j-log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "org-apache-logging-log4j-log4j-core" }
org-apache-logging-log4j-log4j-v1-v2-api = { module = "org.apache.logging.log4j:log4j-1.2-api", version.ref = "org-apache-logging-log4j-log4j-v1-v2-api" }
org-bouncycastle-bcpkix-jdk18on = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "org-bouncycastle-bcpkix-jdk18on" }
org-bouncycastle-bcprov-jdk18on = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "org-bouncycastle-bcprov-jdk18on" }
org-bouncycastle-bcutil-jdk18on = { module = "org.bouncycastle:bcutil-jdk18on", version.ref = "org-bouncycastle-bcutil-jdk18on" }
org-codehaus-mojo-exec-maven-plugin = { module = "org.codehaus.mojo:exec-maven-plugin", version.ref = "org-codehaus-mojo-exec-maven-plugin" }
org-jboss-resteasy-resteasy-client = { module = "org.jboss.resteasy:resteasy-client", version.ref = "org-jboss-resteasy-resteasy-client" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 433e8d0

Please sign in to comment.