Skip to content
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

#27 convert maven build scripts to gradle #46

Merged
merged 9 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ OpenDCS Rest API is intended to run as a stand-alone Java program. It uses embed
# Structure
./rest_api - contains source files for the OpenDCS REST API
./web_client - contains source files for the OpenDCS Web Application Client
./odcs-web-client-jety-standalone - contains build scripts for generating a standalone Jetty installer for the web client
./odcsapi-jetty-standalone - contains build scripts for generating a standalone Jetty installer for the OPENDCS REST API

# Installation and Configuration
There are two types of installations/configurations. One is Jetty and the other is a WAR file.
There are two types of installations/configurations. One is embedded Jetty bundles and the other is WAR files.

## OPENDCS API
The gradle task `./gradlew :odcsapi:war` will create a war file in the `build/libs` directory.

## OPENDCS Web Client
The gradle task `./gradlew :odcs-web-client:war` will create a war file in the `build/libs` directory.

## OPENDCS API Jetty Standalone Installer

The Root URL for the service is specified using the command line arguments when the JETTY server is started. If the defaults are used, you can access the service from the local machine with:
http://localhost:8080/odcsapi/function-call

For example, to get a list of platform references:
http://localhost:8080/odcsapi/platformrefs

## Jetty
- Change directory to the base directory of the project.
- Run the following command: `mvn install`
- In the ‘target’ directory, there will be a .tar.gz file. This is the newly created jetty tar ball.
- Move the tar ball to the desired location and extract it.
- Then change directory to the ‘bin’ directory. There will be a ‘start.sh’ file.
The gradle task `./gradlew :odcs-web-client-jetty-standalone:bundle` will create a tar ball in the `build/distributions` directory.
This tar ball can be extracted and run with the `start.sh` script.
The `start.sh` script can be configured with the following arguments:

- Create a shell script, to run start.sh with some extra configurations.
- Example shell script:
```
Expand Down Expand Up @@ -53,9 +61,15 @@ http://localhost:8080/odcsapi/platformrefs
- -s
- Secure mode. The authentication is done via the header, rather than as parameters passed through parameters.

## WAR file
Once mvn install has been run to create a jetty instance, a war file can then be created.
- Run the following command after the jetty embedded server tar ball is created
- ant -f build-war.xml war
Additionally, the build can run from a developer environment using the gradle task `./gradlew :odcs-web-client-jetty-standalone:startJetty`.
Properties read from gradle.properties will be used to configure the server.

## OPENDCS Web Client Jetty Standalone Installer
The gradle task `./gradlew :odcs-web-client-jetty-standalone:bundle` will create a tar ball in the `build/distributions` directory.
This tar ball can be extracted and run with the `start.sh` script.
The `start.sh` script can be configured with the following arguments:

Additionally, the build can run from a developer environment using the gradle task `./gradlew :odcs-web-client-jetty-standalone:startJetty`.
Properties read from gradle.properties will be used to configure the server.


19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id "com.palantir.git-version" version "3.0.0"
id "org.sonarqube" version "4.4.1.3373"
id "opendcs-rest-api.java-conventions"
id "opendcs-rest-api.deps-conventions"
id "opendcs-rest-api.publishing-conventions"
}

def static versionLabel(gitInfo) {
def branch = gitInfo.branchName // all branches are snapshots, only tags get released
def tag = gitInfo.lastTag
// tag is returned as is. Branch may need cleanup
return branch == null ? tag : 99 + "." + branch.replace("/", "-") + "-SNAPSHOT"
}

allprojects {
group = 'org.opendcs'
version = versionLabel(versionDetails())
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
repositories {
mavenCentral()
}
23 changes: 23 additions & 0 deletions buildSrc/src/main/groovy/opendcs-rest-api.java-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'java-library'
}

java {
withSourcesJar()
withJavadocJar()
}

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.engine)
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id 'maven-publish'
}

publishing {
repositories {
maven {
credentials {
username = ""
password = ""
}
afterEvaluate {
url = ""
}
}
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#DCSTOOL_HOME
#DCSTOOL_USERDIR
43 changes: 43 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[versions]
opendcs = "7.0.10"

jetty = "9.4.53.v20231009"
servlet-api = "3.1.0"
slf4j = "2.0.0"
jersey = "2.40"
postgresql = "42.6.0"
swagger = "2.2.15"
swagger-ui = "5.9.0"
glassfish-jaxb = "2.3.3"
websocket = "1.1"

#Test Dependencies
junit = "5.10.1"

[libraries]
opendcs = { module = "org.opendcs:opendcs", version.ref = "opendcs" }

jetty-server = { module = "org.eclipse.jetty:jetty-server", version.ref = "jetty" }
jetty-servlets = { module = "org.eclipse.jetty:jetty-servlets", version.ref = "jetty" }
jetty-servlet = { module = "org.eclipse.jetty:jetty-servlet", version.ref = "jetty" }
jetty-webapp = { module = "org.eclipse.jetty:jetty-webapp", version.ref = "jetty" }

servlet-api = { module = "javax.servlet:javax.servlet-api", version.ref = "servlet-api" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
jersey-client = { module = "org.glassfish.jersey.core:jersey-client", version.ref = "jersey" }
jersey-server = { module = "org.glassfish.jersey.core:jersey-server", version.ref = "jersey" }
json-jackson = { module = "org.glassfish.jersey.media:jersey-media-json-jackson", version.ref = "jersey" }
jersey-common = { module = "org.glassfish.jersey.core:jersey-common", version.ref = "jersey" }
jersey-container-servlet = { module = "org.glassfish.jersey.containers:jersey-container-servlet", version.ref = "jersey" }
jersey-hk2 = { module = "org.glassfish.jersey.inject:jersey-hk2", version.ref = "jersey" }
postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
swagger-jaxrs2 = { module = "io.swagger.core.v3:swagger-jaxrs2", version.ref = "swagger" }
swagger-ui = { module = "org.webjars:swagger-ui", version.ref = "swagger-ui" }
jaxb-runtime = { module = "org.glassfish.jaxb:jaxb-runtime", version.ref = "glassfish-jaxb" }
websocket = { module = "javax.websocket:javax.websocket-api", version.ref = "websocket" }

#Test Dependencies
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }

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.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading