├── CONTRIBUTORS.md
├── settings.gradle
├── .idea
├── .gitignore
├── vcs.xml
├── compiler.xml
├── misc.xml
├── proto-java-course.iml
├── runConfigurations
│ ├── IO.xml
│ ├── JSON.xml
│ ├── Maps.xml
│ ├── OneOf.xml
│ ├── Simple.xml
│ ├── Complex.xml
│ └── Enumerations.xml
└── jarRepositories.xml
├── src
└── main
│ ├── proto
│ ├── dummy.proto
│ ├── oneofs.proto
│ ├── maps.proto
│ ├── simple.proto
│ ├── options.proto
│ ├── complex.proto
│ └── enumerations.proto
│ └── java
│ ├── enumerations
│ └── EnumerationsMain.java
│ ├── simple
│ └── SimpleMain.java
│ ├── maps
│ └── MapsMain.java
│ ├── complex
│ └── ComplexMain.java
│ ├── oneofs
│ └── OneOfMain.java
│ ├── io
│ └── IoMain.java
│ └── json
│ └── JsonMain.java
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .github
└── workflows
│ ├── lint.yml
│ └── gradle.yml
├── README.md
├── .protolint
└── .protolint.yaml
├── .gitignore
├── gradlew.bat
└── gradlew
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | - [Darren Rose](https://github.com/darren-rose)
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'proto-java-course'
2 |
3 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/src/main/proto/dummy.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package dummy;
4 |
5 | message DummyMessage {
6 | uint32 id = 1;
7 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Clement-Jean/proto-java-course/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/proto/oneofs.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.oneofs;
4 |
5 | message Result {
6 | oneof result {
7 | string message = 1;
8 | uint32 id = 2;
9 | }
10 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/proto/maps.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.maps;
4 |
5 | message IdWrapper {
6 | uint32 id = 1;
7 | }
8 |
9 | message MapExample {
10 | map ids = 1;
11 | }
--------------------------------------------------------------------------------
/src/main/proto/simple.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.simple;
4 |
5 | message Simple {
6 | uint32 id = 1;
7 | bool is_simple = 2;
8 | string name = 3;
9 | repeated int32 sample_lists = 4;
10 | }
--------------------------------------------------------------------------------
/src/main/proto/options.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.options;
4 |
5 | option java_package = "com.example.options";
6 | option java_multiple_files = true;
7 |
8 | message AnotherDummy {
9 | uint32 id = 1;
10 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/src/main/proto/complex.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.complex;
4 |
5 | message Dummy {
6 | uint32 id = 1;
7 | string name = 2;
8 | }
9 |
10 | message Complex {
11 | Dummy one_dummy = 1;
12 | repeated Dummy dummies = 2;
13 | }
--------------------------------------------------------------------------------
/src/main/proto/enumerations.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package example.enumerations;
4 |
5 | enum EyeColor {
6 | EYE_COLOR_UNSPECIFIED = 0;
7 | EYE_COLOR_GREEN = 1;
8 | EYE_COLOR_BLUE = 2;
9 | EYE_COLOR_BROWN = 3;
10 | }
11 |
12 | message Enumeration {
13 | EyeColor eye_color = 1;
14 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/proto-java-course.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/main/java/enumerations/EnumerationsMain.java:
--------------------------------------------------------------------------------
1 | package enumerations;
2 |
3 | import example.enumerations.Enumerations;
4 |
5 | public class EnumerationsMain {
6 |
7 | public static void main(String[] args) {
8 | Enumerations.Enumeration message = Enumerations.Enumeration.newBuilder()
9 | .setEyeColor(Enumerations.EyeColor.EYE_COLOR_GREEN)
10 | //.setEyeColorValue(1)
11 | .build();
12 |
13 | System.out.println(message);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: Lint protobuf
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | paths:
7 | - "**/*.proto"
8 | pull_request:
9 | branches: [ main ]
10 | paths:
11 | - "**/*.proto"
12 |
13 | jobs:
14 | pr-check:
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Checkout source
18 | uses: actions/checkout@v1
19 |
20 | - name: Run protolint
21 | uses: plexsystems/protolint-action@v0.4.0
22 | with:
23 | configDirectory: .protolint
--------------------------------------------------------------------------------
/.idea/runConfigurations/IO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/JSON.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Maps.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/OneOf.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Complex.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Enumerations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # proto-java-course
2 |
3 | [](https://github.com/Clement-Jean/proto-java-course/actions/workflows/gradle.yml) [](https://github.com/Clement-Jean/proto-java-course/actions/workflows/lint.yml)
4 |
5 | ## COUPON: `START_OCT_2025`
6 |
7 | ## Alternative Run
8 |
9 | ```
10 | gradle simple
11 | gradle complex
12 | gradle enums
13 | gradle maps
14 | gradle oneofs
15 | gradle io
16 | gradle json
17 | ```
18 |
19 | same applies for `./gradlew` or `./gradlew.bat`
20 |
--------------------------------------------------------------------------------
/src/main/java/simple/SimpleMain.java:
--------------------------------------------------------------------------------
1 | package simple;
2 |
3 | import example.simple.SimpleOuterClass;
4 | import java.util.Arrays;
5 |
6 | public class SimpleMain {
7 |
8 | public static void main(String[] args) {
9 | SimpleOuterClass.Simple message = SimpleOuterClass.Simple.newBuilder()
10 | .setId(42)
11 | .setIsSimple(true)
12 | .setName("My name")
13 | .addSampleLists(1)
14 | .addSampleLists(2)
15 | .addSampleLists(3)
16 | .addAllSampleLists(Arrays.asList(4, 5, 6))
17 | .build();
18 |
19 | System.out.println(message);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.protolint/.protolint.yaml:
--------------------------------------------------------------------------------
1 | lint:
2 | rules:
3 | no_default: false
4 | add:
5 | - ENUM_FIELD_NAMES_PREFIX
6 | - ENUM_FIELD_NAMES_UPPER_SNAKE_CASE
7 | - ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH
8 | - ENUM_NAMES_UPPER_CAMEL_CASE
9 | - FILE_NAMES_LOWER_SNAKE_CASE
10 | - FIELD_NAMES_LOWER_SNAKE_CASE
11 | - MPORTS_SORTED
12 | - MESSAGE_NAMES_UPPER_CAMEL_CASE
13 | - ORDER
14 | - PACKAGE_NAME_LOWER_CASE
15 | - RPC_NAMES_UPPER_CAMEL_CASE
16 | - SERVICE_NAMES_UPPER_CAMEL_CASE
17 | - REPEATED_FIELD_NAMES_PLURALIZED
18 | - QUOTE_CONSISTENT
19 | - INDENT
20 | - PROTO3_FIELDS_AVOID_REQUIRED
21 | - PROTO3_GROUPS_AVOID
22 | - MAX_LINE_LENGTH
23 |
--------------------------------------------------------------------------------
/src/main/java/maps/MapsMain.java:
--------------------------------------------------------------------------------
1 | package maps;
2 |
3 | import example.maps.Maps;
4 |
5 | import java.util.HashMap;
6 |
7 | public class MapsMain {
8 |
9 | private static Maps.IdWrapper newIdWrapper(int id) {
10 | return Maps.IdWrapper.newBuilder().setId(id).build();
11 | }
12 |
13 | public static void main(String[] args) {
14 | Maps.MapExample message = Maps.MapExample.newBuilder()
15 | .putIds("myid", newIdWrapper(42))
16 | .putIds("myid2", newIdWrapper(43))
17 | .putAllIds(new HashMap() {{
18 | put("myid3", newIdWrapper(44));
19 | put("myid4", newIdWrapper(45));
20 | }})
21 | .build();
22 |
23 | System.out.println(message);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | name: build master branch
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | paths:
7 | - "src/**/*.java"
8 | - "*.gradle"
9 | - "gradle-*"
10 | pull_request:
11 | branches: [ main ]
12 | paths:
13 | - "src/**/*.java"
14 | - "*.gradle"
15 | - "gradle-*"
16 |
17 | jobs:
18 | build:
19 | runs-on: ${{ matrix.os }}
20 |
21 | strategy:
22 | matrix:
23 | os: [windows-2022, ubuntu-20.04, macos-11]
24 | jdk: ['8', '17']
25 | steps:
26 | - uses: actions/checkout@v2
27 | - name: Set up JDK
28 | uses: actions/setup-java@v2
29 | with:
30 | java-version: ${{ matrix.jdk }}
31 | distribution: 'temurin'
32 |
33 | - name: Build with Gradle
34 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
35 | with:
36 | arguments: build -x test
37 |
--------------------------------------------------------------------------------
/src/main/java/complex/ComplexMain.java:
--------------------------------------------------------------------------------
1 | package complex;
2 |
3 | import example.complex.ComplexOuterClass;
4 |
5 | import java.util.Arrays;
6 |
7 | public class ComplexMain {
8 |
9 | private static ComplexOuterClass.Dummy newDummy(int id, String name) {
10 | return ComplexOuterClass.Dummy.newBuilder()
11 | .setId(id)
12 | .setName(name)
13 | .build();
14 | }
15 |
16 | public static void main(String[] args) {
17 | ComplexOuterClass.Complex message = ComplexOuterClass.Complex.newBuilder()
18 | .setOneDummy(newDummy(55, "One Dummy"))
19 | .addAllDummies(
20 | Arrays.asList(
21 | newDummy(66, "Second dummy"),
22 | newDummy(67, "Third dummy"),
23 | newDummy(68, "Fourth dummy")
24 | )
25 | ).build();
26 |
27 | System.out.println(message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/oneofs/OneOfMain.java:
--------------------------------------------------------------------------------
1 | package oneofs;
2 |
3 | import example.oneofs.Oneofs;
4 |
5 | public class OneOfMain {
6 |
7 | public static void main(String[] args) {
8 | Oneofs.Result message = Oneofs.Result.newBuilder()
9 | .setMessage("a message")
10 | .build();
11 |
12 | System.out.println("hasMessage: " + message.hasMessage());
13 | System.out.println("hasId: " + message.hasId());
14 | System.out.println(message);
15 |
16 | Oneofs.Result message2 = Oneofs.Result.newBuilder(message)
17 | .setId(42)
18 | .build();
19 |
20 | System.out.println("hasMessage: " + message2.hasMessage());
21 | System.out.println("hasId: " + message2.hasId());
22 | System.out.println(message2);
23 |
24 | Oneofs.Result message3 = Oneofs.Result.newBuilder()
25 | .setId(42)
26 | .setMessage("a message")
27 | .build();
28 |
29 | System.out.println("hasMessage: " + message3.hasMessage());
30 | System.out.println("hasId: " + message3.hasId());
31 | System.out.println(message3);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/IoMain.java:
--------------------------------------------------------------------------------
1 | package io;
2 |
3 | import example.simple.SimpleOuterClass;
4 |
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 |
9 | public class IoMain {
10 |
11 | private static void writeTo(SimpleOuterClass.Simple message, String path) {
12 | try {
13 | FileOutputStream fos = new FileOutputStream(path);
14 |
15 | message.writeTo(fos);
16 | fos.close();
17 | } catch (IOException e) {
18 | e.printStackTrace();
19 | }
20 | }
21 |
22 | private static void readFrom(String path) {
23 | try {
24 | FileInputStream fis = new FileInputStream(path);
25 | SimpleOuterClass.Simple message = SimpleOuterClass.Simple.parseFrom(fis);
26 |
27 | System.out.println(message);
28 | } catch (IOException e) {
29 | e.printStackTrace();
30 | }
31 | }
32 |
33 | public static void main(String[] args) {
34 | SimpleOuterClass.Simple message = SimpleOuterClass.Simple.newBuilder()
35 | .setId(42)
36 | .setName("A name")
37 | .setIsSimple(true)
38 | .build();
39 | String path = "simple.bin";
40 |
41 | writeTo(message, path);
42 | readFrom(path);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## IDEA IntelliJ
2 |
3 | # User-specific stuff
4 | .idea/**/workspace.xml
5 | .idea/**/tasks.xml
6 | .idea/**/usage.statistics.xml
7 | .idea/**/dictionaries
8 | .idea/**/shelf
9 |
10 | # Generated files
11 | .idea/**/contentModel.xml
12 |
13 | # Sensitive or high-churn files
14 | .idea/**/dataSources/
15 | .idea/**/dataSources.ids
16 | .idea/**/dataSources.local.xml
17 | .idea/**/sqlDataSources.xml
18 | .idea/**/dynamic.xml
19 | .idea/**/uiDesigner.xml
20 | .idea/**/dbnavigator.xml
21 |
22 | # Gradle
23 | .idea/**/gradle.xml
24 | .idea/**/libraries
25 |
26 | # File-based project format
27 | *.iws
28 |
29 | # IntelliJ
30 | out/
31 |
32 | ## JAVA
33 |
34 | # Compiled class file
35 | *.class
36 |
37 | # Log file
38 | *.log
39 |
40 | # Package Files #
41 | *.jar
42 | *.war
43 | *.nar
44 | *.ear
45 | *.zip
46 | *.tar.gz
47 | *.rar
48 |
49 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
50 | hs_err_pid*
51 | replay_pid*
52 |
53 |
54 | ## Gradle
55 |
56 | .gradle
57 | **/build/
58 | !src/**/build/
59 |
60 | # Ignore Gradle GUI config
61 | gradle-app.setting
62 |
63 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
64 | !gradle-wrapper.jar
65 |
66 | # Cache of project
67 | .gradletasknamecache
68 |
69 | # Eclipse Gradle plugin generated files
70 | # Eclipse Core
71 | .project
72 | # JDT-specific (Eclipse Java Development Tools)
73 | .classpath
74 |
75 | simple.bin
--------------------------------------------------------------------------------
/src/main/java/json/JsonMain.java:
--------------------------------------------------------------------------------
1 | package json;
2 |
3 | import com.google.protobuf.InvalidProtocolBufferException;
4 | import com.google.protobuf.util.JsonFormat;
5 | import example.simple.SimpleOuterClass;
6 |
7 | import java.util.Arrays;
8 |
9 | public class JsonMain {
10 |
11 | private static String toJSON(SimpleOuterClass.Simple message) throws InvalidProtocolBufferException {
12 | return JsonFormat.printer()
13 | // .omittingInsignificantWhitespace()
14 | // .includingDefaultValueFields()
15 | .print(message);
16 | }
17 |
18 | private static SimpleOuterClass.Simple fromJSON(String json) throws InvalidProtocolBufferException {
19 | SimpleOuterClass.Simple.Builder builder = SimpleOuterClass.Simple.newBuilder();
20 |
21 | JsonFormat.parser()
22 | .ignoringUnknownFields()
23 | .merge(json, builder);
24 |
25 | return builder.build();
26 | }
27 |
28 | public static void main(String[] args) throws InvalidProtocolBufferException {
29 | SimpleOuterClass.Simple message = SimpleOuterClass.Simple.newBuilder()
30 | .setId(42)
31 | .setIsSimple(true)
32 | .setName("A name")
33 | .addAllSampleLists(Arrays.asList(1, 2, 3))
34 | .build();
35 |
36 | String json = toJSON(message);
37 |
38 | System.out.println(json);
39 | System.out.println(fromJSON(json));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MSYS* | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------