Skip to content

Commit 21dd8ce

Browse files
authored
Migrate build system to gradle (#1592)
Conversion to Gradle Signed-off-by: rs-eliatra <rafal.stobiecki@eliatra.com>
1 parent a4ac46b commit 21dd8ce

12 files changed

+686
-1250
lines changed

.github/workflows/cd.yml

+14-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- '*'
77

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

1111
jobs:
1212
build:
@@ -22,22 +22,25 @@ jobs:
2222
- name: Checkout security
2323
uses: actions/checkout@v2
2424

25-
- name: Cache Maven packages
26-
uses: actions/cache@v1
25+
- name: Cache Gradle packages
26+
uses: actions/cache@v2
2727
with:
28-
path: ~/.m2/repository
29-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
30-
restore-keys: ${{ runner.os }}-m2
28+
path: |
29+
~/.gradle/caches
30+
~/.gradle/wrapper
31+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
32+
restore-keys: |
33+
${{ runner.os }}-gradle-
3134
3235
- name: Build
3336
run: |
34-
mvn -B clean package -Padvanced -DskipTests
35-
artifact_zip=`ls $(pwd)/target/releases/opensearch-security-*.zip | grep -v admin-standalone`
36-
./gradlew build buildDeb buildRpm --no-daemon -ParchivePath=$artifact_zip -Dbuild.snapshot=false
37+
./gradlew clean build -Dbuild.snapshot=false -x test
38+
artifact_zip=`ls $(pwd)/build/distributions/opensearch-security-*.zip | grep -v admin-standalone`
39+
./gradlew build buildDeb buildRpm -ParchivePath=$artifact_zip -Dbuild.snapshot=false -x test
3740
mkdir artifacts
3841
cp $artifact_zip artifacts/
39-
cp gradle-build/distributions/*.deb artifacts/
40-
cp gradle-build/distributions/*.rpm artifacts/
42+
cp build/distributions/*.deb artifacts/
43+
cp build/distributions/*.rpm artifacts/
4144
zip -r artifacts.zip artifacts
4245
echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
4346

.github/workflows/ci.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- opendistro-*
1111

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

1515
jobs:
1616
build:
@@ -36,24 +36,28 @@ jobs:
3636
with:
3737
languages: java
3838

39-
- name: Cache Maven packages
40-
uses: actions/cache@v1
39+
- name: Cache Gradle packages
40+
uses: actions/cache@v2
4141
with:
42-
path: ~/.m2
43-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
44-
restore-keys: ${{ runner.os }}-m2
42+
path: |
43+
~/.gradle/caches
44+
~/.gradle/wrapper
45+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
46+
restore-keys: |
47+
${{ runner.os }}-gradle-
48+
4549
4650
- name: Checkstyle
47-
run: mvn -B checkstyle:checkstyle
51+
run: ./gradlew clean checkstyleMain checkstyleTest
4852

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

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

5559
- name: Test
56-
run: OPENDISTRO_SECURITY_TEST_OPENSSL_OPT=true mvn -B test
60+
run: OPENDISTRO_SECURITY_TEST_OPENSSL_OPT=true ./gradlew test
5761

5862
- name: Coverage
5963
uses: codecov/codecov-action@v1
@@ -64,4 +68,4 @@ jobs:
6468
uses: actions/upload-artifact@v1
6569
with:
6670
name: artifacts
67-
path: target/releases/
71+
path: build/distributions/

DEVELOPER_GUIDE.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ The `curl localhost:9200` call from before should also succeed now. Kill the ser
3535
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:
3636

3737
```bash
38-
mvn -B package -Padvanced -DskipTests
38+
./gradlew clean assemble
3939
```
4040

4141
Install the built plugin into the OpenSearch server:
4242

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

116116
## Using IntelliJ IDEA
117117

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

120120
## Submitting Changes
121121

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ You can also see the [developer guide](https://github.com/opensearch-project/sec
6262

6363
Run all tests:
6464
```bash
65-
mvn clean test
65+
./gradlew clean test
6666
```
6767

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

7575
This produces:
7676

7777
```
78-
target/releases/opensearch-security-<VERSION>.zip
79-
gradle-build/distributions/opensearch-security-<VERSION>.deb
80-
gradle-build/distributions/opensearch-security-<VERSION>.rpm
78+
build/releases/opensearch-security-<VERSION>.zip
79+
build/distributions/opensearch-security-<VERSION>.deb
80+
build/distributions/opensearch-security-<VERSION>.rpm
8181
```
8282

8383
## Config hot reloading

0 commit comments

Comments
 (0)