Skip to content

Commit 3d19014

Browse files
author
Simon Stone
committed
[FAB-6415] Java 11 support for FabCar sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com> Change-Id: I97cd3ab48f6f2fe828c3328adfaf706be5124387
1 parent e2b7cb7 commit 3d19014

File tree

7 files changed

+51
-23
lines changed

7 files changed

+51
-23
lines changed

chaincode/fabcar/java/build.gradle

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
plugins {
66
id 'checkstyle'
7-
id 'com.github.johnrengelman.shadow' version '2.0.4'
8-
id 'java-library'
7+
id 'java-library-distribution'
98
id 'jacoco'
109
}
1110

1211
group 'org.hyperledger.fabric.samples'
1312
version '1.0-SNAPSHOT'
1413

1514
dependencies {
16-
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.0.0-SNAPSHOT'
15+
compileOnly 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.0.0-SNAPSHOT'
1716
implementation 'com.owlike:genson:1.5'
17+
testImplementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.0.0-SNAPSHOT'
1818
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
1919
testImplementation 'org.assertj:assertj-core:3.11.1'
2020
testImplementation 'org.mockito:mockito-core:2.+'
@@ -25,8 +25,8 @@ repositories {
2525
url "https://nexus.hyperledger.org/content/repositories/snapshots/"
2626
}
2727
jcenter()
28-
maven {
29-
url 'https://jitpack.io'
28+
maven {
29+
url 'https://jitpack.io'
3030
}
3131
}
3232

@@ -43,15 +43,6 @@ checkstyleTest {
4343
source ='src/test/java'
4444
}
4545

46-
shadowJar {
47-
baseName = 'chaincode'
48-
version = null
49-
classifier = null
50-
manifest {
51-
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
52-
}
53-
}
54-
5546
jacocoTestCoverageVerification {
5647
afterEvaluate {
5748
classDirectories = files(classDirectories.files.collect {
@@ -67,7 +58,7 @@ jacocoTestCoverageVerification {
6758
}
6859
}
6960
}
70-
61+
7162
finalizedBy jacocoTestReport
7263
}
7364

Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

chaincode/fabcar/java/gradlew

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

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+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"
@@ -109,8 +125,8 @@ if $darwin; then
109125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110126
fi
111127

112-
# For Cygwin, switch paths to Windows format before running java
113-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
114130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116132
JAVACMD=`cygpath --unix "$JAVACMD"`

chaincode/fabcar/java/gradlew.bat

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
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+
117
@if "%DEBUG%" == "" @echo off
218
@rem ##########################################################################
319
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
1430
set APP_HOME=%DIRNAME%
1531

1632
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17-
set DEFAULT_JVM_OPTS=
33+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
1834

1935
@rem Find java.exe
2036
if defined JAVA_HOME goto findJavaFromJavaHome

chaincode/fabcar/java/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
* SPDX-License-Identifier: Apache-2.0
33
*/
44

5-
rootProject.name = 'java-chaincode-bootstrap'
5+
rootProject.name = 'fabcar'

fabcar/startFabric.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ if [ "$CC_SRC_LANGUAGE" = "go" -o "$CC_SRC_LANGUAGE" = "golang" ]; then
2222
echo Finished vendoring Go dependencies
2323
elif [ "$CC_SRC_LANGUAGE" = "java" ]; then
2424
CC_RUNTIME_LANGUAGE=java
25-
CC_SRC_PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/java
25+
CC_SRC_PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/java/build/install/fabcar
26+
echo Compiling Java code ...
27+
pushd ../chaincode/fabcar/java
28+
./gradlew installDist
29+
popd
30+
echo Finished compiling Java code
2631
elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then
2732
CC_RUNTIME_LANGUAGE=node # chaincode runtime language is node.js
2833
CC_SRC_PATH=/opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/fabcar/javascript
@@ -37,7 +42,7 @@ elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then
3742
echo Finished compiling TypeScript code into JavaScript
3843
else
3944
echo The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script
40-
echo Supported chaincode languages are: go, javascript, and typescript
45+
echo Supported chaincode languages are: go, java, javascript, and typescript
4146
exit 1
4247
fi
4348

0 commit comments

Comments
 (0)