Skip to content

Commit

Permalink
Migrate build system to gradle (opensearch-project#1592)
Browse files Browse the repository at this point in the history
Conversion to Gradle

Signed-off-by: rs-eliatra <[email protected]>
  • Loading branch information
rs-eliatra authored Feb 15, 2022
1 parent a4ac46b commit 21dd8ce
Show file tree
Hide file tree
Showing 12 changed files with 686 additions and 1,250 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'

env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
GRADLE_OPTS: -Dhttp.keepAlive=false

jobs:
build:
Expand All @@ -22,22 +22,25 @@ jobs:
- name: Checkout security
uses: actions/checkout@v2

- name: Cache Maven packages
uses: actions/cache@v1
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: |
mvn -B clean package -Padvanced -DskipTests
artifact_zip=`ls $(pwd)/target/releases/opensearch-security-*.zip | grep -v admin-standalone`
./gradlew build buildDeb buildRpm --no-daemon -ParchivePath=$artifact_zip -Dbuild.snapshot=false
./gradlew clean build -Dbuild.snapshot=false -x test
artifact_zip=`ls $(pwd)/build/distributions/opensearch-security-*.zip | grep -v admin-standalone`
./gradlew build buildDeb buildRpm -ParchivePath=$artifact_zip -Dbuild.snapshot=false -x test
mkdir artifacts
cp $artifact_zip artifacts/
cp gradle-build/distributions/*.deb artifacts/
cp gradle-build/distributions/*.rpm artifacts/
cp build/distributions/*.deb artifacts/
cp build/distributions/*.rpm artifacts/
zip -r artifacts.zip artifacts
echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- opendistro-*

env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
GRADLE_OPTS: -Dhttp.keepAlive=false

jobs:
build:
Expand All @@ -36,24 +36,28 @@ jobs:
with:
languages: java

- name: Cache Maven packages
uses: actions/cache@v1
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Checkstyle
run: mvn -B checkstyle:checkstyle
run: ./gradlew clean checkstyleMain checkstyleTest

- name: Package
run: mvn -B clean package -Padvanced -DskipTests
run: ./gradlew clean build -Dbuild.snapshot=false -x test

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

- name: Test
run: OPENDISTRO_SECURITY_TEST_OPENSSL_OPT=true mvn -B test
run: OPENDISTRO_SECURITY_TEST_OPENSSL_OPT=true ./gradlew test

- name: Coverage
uses: codecov/codecov-action@v1
Expand All @@ -64,4 +68,4 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: artifacts
path: target/releases/
path: build/distributions/
6 changes: 3 additions & 3 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ The `curl localhost:9200` call from before should also succeed now. Kill the ser
First create a fork of this repo and clone it locally. Changing into the directory of the newly cloned repository, run the following to build the project:

```bash
mvn -B package -Padvanced -DskipTests
./gradlew clean assemble
```

Install the built plugin into the OpenSearch server:

```bash
export OPENSEARCH_SECURITY_HOME=$OPENSEARCH_HOME/plugins/opensearch-security
cp target/releases/opensearch-security-1.3.0.0-SNAPSHOT.zip $OPENSEARCH_SECURITY_HOME
cp build/distributions/opensearch-security-1.3.0.0-SNAPSHOT.zip $OPENSEARCH_SECURITY_HOME
cd $OPENSEARCH_SECURITY_HOME
unzip opensearch-security-1.3.0.0-SNAPSHOT.zip
rm opensearch-security-1.3.0.0-SNAPSHOT.zip
Expand Down Expand Up @@ -115,7 +115,7 @@ curl -XGET https://localhost:9200/_plugins/_security/authinfo -u 'admin:admin' -

## Using IntelliJ IDEA

Launch IntelliJ IDEA, choose **Import Project**, and select the `pom.xml` file in the root of this package.
Launch IntelliJ IDEA, choose **Project from Existing Sources**, and select directory with Gradle build script (`build.gradle`).

## Submitting Changes

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ You can also see the [developer guide](https://github.com/opensearch-project/sec

Run all tests:
```bash
mvn clean test
./gradlew clean test
```

Build artifacts (zip, deb, rpm):
```bash
mvn clean package -Padvanced -DskipTests
artifact_zip=`ls $(pwd)/target/releases/opensearch-security-*.zip | grep -v admin-standalone`
./gradlew build buildDeb buildRpm --no-daemon -ParchivePath=$artifact_zip -Dbuild.snapshot=false
./gradlew clean assemble
artifact_zip=`ls $(pwd)/build/distributions/opensearch-security-*.zip | grep -v admin-standalone`
./gradlew buildDeb buildRpm -ParchivePath=$artifact_zip
```

This produces:

```
target/releases/opensearch-security-<VERSION>.zip
gradle-build/distributions/opensearch-security-<VERSION>.deb
gradle-build/distributions/opensearch-security-<VERSION>.rpm
build/releases/opensearch-security-<VERSION>.zip
build/distributions/opensearch-security-<VERSION>.deb
build/distributions/opensearch-security-<VERSION>.rpm
```

## Config hot reloading
Expand Down
Loading

0 comments on commit 21dd8ce

Please sign in to comment.