diff --git a/bddtests/java_shim.feature b/bddtests/java_shim.feature
index 34f2aef86d7..7bac768d9e8 100644
--- a/bddtests/java_shim.feature
+++ b/bddtests/java_shim.feature
@@ -126,7 +126,7 @@ Scenario: java RangeExample chaincode single peer
||
||
Then I should have received a chaincode name
- Then I wait up to "30" seconds for transaction to be committed to all peers
+ Then I wait up to "240" seconds for transaction to be committed to all peers
When requesting "/chain" from "vp0"
Then I should get a JSON response with "height" = "2"
@@ -178,7 +178,7 @@ Scenario: java RangeExample chaincode single peer
When requesting "/chain" from "vp0"
Then I should get a JSON response with "height" = "1"
# TODO Needs to be replaced with an official test repo in the future.
- When I deploy lang chaincode "http://github.com/hyperledger/fabric-test-resources/javachaincode" of "JAVA" with ctor "init" to "vp0"
+ When I deploy lang chaincode "http://github.com/hyperledger/fabric-test-resources/javachaincodemvn" of "JAVA" with ctor "init" to "vp0"
| arg1 | arg2 | arg3 | arg4 |
| a | 100 | b | 200 |
Then I should have received a chaincode name
diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go
index 62d7e1079f1..3398caaa0d9 100644
--- a/core/chaincode/chaincode_support.go
+++ b/core/chaincode/chaincode_support.go
@@ -376,7 +376,7 @@ func (chaincodeSupport *ChaincodeSupport) getArgsAndEnv(cccid *CCContext, cLang
case pb.ChaincodeSpec_JAVA:
//TODO add security args
args = strings.Split(
- fmt.Sprintf("/root/Chaincode/bin/runChaincode -a %s -i %s",
+ fmt.Sprintf("java -jar chaincode.jar -a %s -i %s",
chaincodeSupport.peerAddress, cccid.Name),
" ")
if chaincodeSupport.peerTLS {
diff --git a/core/chaincode/platforms/java/hash.go b/core/chaincode/platforms/java/hash.go
index 16ea19d559d..369ddf448e4 100644
--- a/core/chaincode/platforms/java/hash.go
+++ b/core/chaincode/platforms/java/hash.go
@@ -1,3 +1,19 @@
+/*
+Copyright DTCC 2016 All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
package java
import (
diff --git a/core/chaincode/platforms/java/package.go b/core/chaincode/platforms/java/package.go
index 82ecfd1395d..f29c171ebb2 100644
--- a/core/chaincode/platforms/java/package.go
+++ b/core/chaincode/platforms/java/package.go
@@ -1,8 +1,25 @@
+/*
+Copyright DTCC 2016 All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
package java
import (
"archive/tar"
"fmt"
+ "io/ioutil"
"strings"
"time"
@@ -13,6 +30,31 @@ import (
"github.com/spf13/viper"
)
+var buildCmd = map[string]string{
+ "build.gradle": "gradle -b build.gradle clean && gradle -b build.gradle build",
+ "pom.xml": "mvn -f pom.xml clean && mvn -f pom.xml package",
+}
+
+//return the type of build gradle/maven based on the file
+//found in java chaincode project root
+//build.gradle - gradle - returns the first found build type
+//pom.xml - maven
+func getBuildCmd(packagePath string) (string, error) {
+ files, err := ioutil.ReadDir(packagePath)
+ if err != nil {
+ return "", err
+ } else {
+ for _, f := range files {
+ if !f.IsDir() {
+ if buildCmd, ok := buildCmd[f.Name()]; ok == true {
+ return buildCmd, nil
+ }
+ }
+ }
+ return "", fmt.Errorf("Build file not found")
+ }
+}
+
//tw is expected to have the chaincode in it from GenerateHashcode.
//This method will just package the dockerfile
func writeChaincodePackage(spec *pb.ChaincodeSpec, tw *tar.Writer) error {
@@ -42,6 +84,10 @@ func writeChaincodePackage(spec *pb.ChaincodeSpec, tw *tar.Writer) error {
urlLocation = urlLocation[:len(urlLocation)-1]
}
+ buildCmd, err := getBuildCmd(urlLocation)
+ if err != nil {
+ return err
+ }
var dockerFileContents string
var buf []string
@@ -49,15 +95,14 @@ func writeChaincodePackage(spec *pb.ChaincodeSpec, tw *tar.Writer) error {
//todo
} else {
buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.java.Dockerfile"))
- buf = append(buf, "COPY src /root")
- buf = append(buf, "RUN gradle -b build.gradle build")
- buf = append(buf, "RUN unzip -od /root build/distributions/Chaincode.zip")
-
+ buf = append(buf, "COPY src /root/chaincode")
+ buf = append(buf, "RUN cd /root/chaincode && "+buildCmd)
+ buf = append(buf, "RUN cp /root/chaincode/build/chaincode.jar /root")
+ buf = append(buf, "RUN cp /root/chaincode/build/libs/* /root/libs")
}
- dockerFileContents = strings.Join(buf, "\n")
+ dockerFileContents = strings.Join(buf, "\n")
dockerFileSize := int64(len([]byte(dockerFileContents)))
-
//Make headers identical by using zero time
var zeroTime time.Time
tw.WriteHeader(&tar.Header{Name: "Dockerfile", Size: dockerFileSize, ModTime: zeroTime, AccessTime: zeroTime, ChangeTime: zeroTime})
diff --git a/core/chaincode/platforms/java/platform.go b/core/chaincode/platforms/java/platform.go
index c0e40dc0cf3..1db2c923151 100644
--- a/core/chaincode/platforms/java/platform.go
+++ b/core/chaincode/platforms/java/platform.go
@@ -1,3 +1,19 @@
+/*
+Copyright DTCC 2016 All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
package java
import (
diff --git a/core/chaincode/shim/java/build.gradle b/core/chaincode/shim/java/build.gradle
index 22bb91b9c50..cbcb11605ea 100644
--- a/core/chaincode/shim/java/build.gradle
+++ b/core/chaincode/shim/java/build.gradle
@@ -15,65 +15,67 @@ limitations under the License.
*/
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
- dependencies {
- classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
+ }
}
plugins {
- id "java"
- id "com.google.protobuf" version "0.7.6"
- id "eclipse"
+ id "java"
+ id "com.google.protobuf" version "0.7.6"
+ id "eclipse"
+ id "maven-publish"
+
}
-archivesBaseName = 'chaincode'
+archivesBaseName = 'shim-client'
version = '1.0'
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- proto {
- srcDir 'src/main/proto'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ proto {
+ srcDir 'src/main/proto'
+ }
+ }
}
repositories {
- mavenLocal()
+ mavenLocal()
mavenCentral()
}
protobuf {
- generatedFilesBaseDir = "$projectDir/src"
- protoc {
- artifact = 'com.google.protobuf:protoc:3.0.0-beta-2'
- }
- plugins {
- grpc {
- artifact = 'io.grpc:protoc-gen-grpc-java:0.13.2'
- }
- }
- generateProtoTasks {
- all().each { task ->
- task.builtins {
- java {
- outputSubDir = 'java'
- }
- }
- task.plugins {
- grpc {
- outputSubDir = 'java'
- }
- }
- }
- }
+ generatedFilesBaseDir = "$projectDir/src"
+ protoc {
+ artifact = 'com.google.protobuf:protoc:3.0.0-beta-2'
+ }
+ plugins {
+ grpc {
+ artifact = 'io.grpc:protoc-gen-grpc-java:0.13.2'
+ }
+ }
+ generateProtoTasks {
+ all().each { task ->
+ task.builtins {
+ java {
+ outputSubDir = 'java'
+ }
+ }
+ task.plugins {
+ grpc {
+ outputSubDir = 'java'
+ }
+ }
+ }
+ }
}
task copyToLib(type: Copy) {
@@ -85,25 +87,36 @@ task copyToLib(type: Copy) {
task copyProtos(type:Copy){
from ("${rootDir}/protos/peer"){
- include '**/chaincodeevent.proto'
- include '**/chaincode.proto'
+ include '**/chaincodeevent.proto'
+ include '**/chaincode.proto'
}
- from ("../") {
- duplicatesStrategy.EXCLUDE
- include '**/table.proto'
- exclude 'java'
- }
- into "${projectDir}/src/main/proto/peer"
+ from ("../") {
+ duplicatesStrategy.EXCLUDE
+ include '**/table.proto'
+ exclude 'java'
+ }
+ into "${projectDir}/src/main/proto/peer"
}
-
tasks['build'].mustRunAfter tasks['copyProtos']
build.dependsOn(copyProtos)
build.finalizedBy(copyToLib)
+build.finalizedBy(publishToMavenLocal)
dependencies {
- compile 'com.google.protobuf:protobuf-java:3.0.0-beta-2'
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
+ compile 'com.google.protobuf:protobuf-java:3.0.0-beta-2'
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+}
+
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ groupId 'org.hyperledger'
+ artifactId 'shim-client'
+ version '1.0'
+ from components.java
+ }
+ }
}
diff --git a/core/chaincode/shim/java/javabuild.sh b/core/chaincode/shim/java/javabuild.sh
index a37300c6853..2555c995fe2 100755
--- a/core/chaincode/shim/java/javabuild.sh
+++ b/core/chaincode/shim/java/javabuild.sh
@@ -40,6 +40,7 @@ if [ x$ARCH == xx86_64 ]
then
gradle -q -b ${PARENTDIR}/core/chaincode/shim/java/build.gradle clean
gradle -q -b ${PARENTDIR}/core/chaincode/shim/java/build.gradle build
+ cp -r ${PARENTDIR}/core/chaincode/shim/java/build/libs /root/
else
echo "FIXME: Java Shim code needs work on ppc64le and s390x."
echo "Commenting it for now."
diff --git a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java
index efb465bc845..35a4274685e 100644
--- a/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java
+++ b/core/chaincode/shim/java/src/main/java/org/hyperledger/java/shim/Handler.java
@@ -1,21 +1,18 @@
-/**
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
- */
+/*
+Copyright DTCC 2016 All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
package org.hyperledger.java.shim;
diff --git a/examples/chaincode/java/Example/build.gradle b/examples/chaincode/java/Example/build.gradle
index 11e24c41451..e0e2555255f 100644
--- a/examples/chaincode/java/Example/build.gradle
+++ b/examples/chaincode/java/Example/build.gradle
@@ -16,18 +16,17 @@ limitations under the License.
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
}
-
plugins {
- id "java"
- id "eclipse"
- id "application"
+ id "java"
+ id "eclipse"
+ id "application"
}
@@ -37,21 +36,21 @@ task printClasspath {
}
}
-archivesBaseName = "java-example"
+archivesBaseName = "chaincode"
mainClassName="example.Example"
run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
+ if (project.hasProperty("appArgs")) {
+ args = Eval.me(appArgs)
+ }
}
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ }
}
repositories {
@@ -60,19 +59,25 @@ repositories {
}
-distZip {
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
+jar.doFirst {
+ destinationDir=file("${buildDir}")
+ manifest {
+ attributes (
+ 'Main-Class': mainClassName,
+ 'Class-Path': configurations.runtime.collect { "libs/"+"$it.name" }.join(' ')
+ )
+ }
}
-
-startScripts{
- applicationName='runChaincode'
+task copyToLib(type: Copy) {
+ into "$buildDir/libs"
+ from configurations.runtime
}
+build.finalizedBy(copyToLib)
dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+ compile 'org.hyperledger:shim-client:1.0'
}
diff --git a/examples/chaincode/java/Example/pom.xml b/examples/chaincode/java/Example/pom.xml
new file mode 100644
index 00000000000..f6db3bd8756
--- /dev/null
+++ b/examples/chaincode/java/Example/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-example
+ jar
+ java-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.Example
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/examples/chaincode/java/LinkExample/build.gradle b/examples/chaincode/java/LinkExample/build.gradle
index e6a7da1108d..5cb19851781 100644
--- a/examples/chaincode/java/LinkExample/build.gradle
+++ b/examples/chaincode/java/LinkExample/build.gradle
@@ -16,18 +16,17 @@ limitations under the License.
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
}
-
plugins {
- id "java"
- id "eclipse"
- id "application"
+ id "java"
+ id "eclipse"
+ id "application"
}
@@ -37,21 +36,21 @@ task printClasspath {
}
}
-archivesBaseName = "java-linkexample"
-mainClassName="example.LinkExample"
+archivesBaseName = "chaincode"
+mainClassName="example.Link"
run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
+ if (project.hasProperty("appArgs")) {
+ args = Eval.me(appArgs)
+ }
}
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ }
}
repositories {
@@ -60,18 +59,25 @@ repositories {
}
-distZip {
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
+jar.doFirst {
+ destinationDir=file("${buildDir}")
+ manifest {
+ attributes (
+ 'Main-Class': mainClassName,
+ 'Class-Path': configurations.runtime.collect { "libs/"+"$it.name" }.join(' ')
+ )
+ }
}
-startScripts{
- applicationName='runChaincode'
+task copyToLib(type: Copy) {
+ into "$buildDir/libs"
+ from configurations.runtime
}
+build.finalizedBy(copyToLib)
dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+ compile 'org.hyperledger:shim-client:1.0'
}
diff --git a/examples/chaincode/java/LinkExample/pom.xml b/examples/chaincode/java/LinkExample/pom.xml
new file mode 100644
index 00000000000..6f4ce37a3f7
--- /dev/null
+++ b/examples/chaincode/java/LinkExample/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-Link
+ jar
+ java-Link-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.Link
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/examples/chaincode/java/MapExample/build.gradle b/examples/chaincode/java/MapExample/build.gradle
index cdd264fb146..138fee746e5 100644
--- a/examples/chaincode/java/MapExample/build.gradle
+++ b/examples/chaincode/java/MapExample/build.gradle
@@ -16,18 +16,17 @@ limitations under the License.
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
}
-
plugins {
- id "java"
- id "eclipse"
- id "application"
+ id "java"
+ id "eclipse"
+ id "application"
}
@@ -37,21 +36,21 @@ task printClasspath {
}
}
-archivesBaseName = "java-mapexample"
+archivesBaseName = "chaincode"
mainClassName="example.MapExample"
run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
+ if (project.hasProperty("appArgs")) {
+ args = Eval.me(appArgs)
+ }
}
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ }
}
repositories {
@@ -59,18 +58,26 @@ repositories {
mavenCentral()
}
-distZip {
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
+
+jar.doFirst {
+ destinationDir=file("${buildDir}")
+ manifest {
+ attributes (
+ 'Main-Class': mainClassName,
+ 'Class-Path': configurations.runtime.collect { "libs/"+"$it.name" }.join(' ')
+ )
+ }
}
-startScripts{
- applicationName='runChaincode'
+task copyToLib(type: Copy) {
+ into "$buildDir/libs"
+ from configurations.runtime
}
+build.finalizedBy(copyToLib)
dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+ compile 'org.hyperledger:shim-client:1.0'
}
diff --git a/examples/chaincode/java/MapExample/pom.xml b/examples/chaincode/java/MapExample/pom.xml
new file mode 100644
index 00000000000..f146d365b4a
--- /dev/null
+++ b/examples/chaincode/java/MapExample/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-Map
+ jar
+ java-Map-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.MapExample
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/examples/chaincode/java/RangeExample/build.gradle b/examples/chaincode/java/RangeExample/build.gradle
index d36b0ed21bd..5434f08930b 100644
--- a/examples/chaincode/java/RangeExample/build.gradle
+++ b/examples/chaincode/java/RangeExample/build.gradle
@@ -16,42 +16,41 @@ limitations under the License.
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
}
-
plugins {
- id "java"
- id "eclipse"
- id "application"
+ id "java"
+ id "eclipse"
+ id "application"
}
-// task printClasspath {
-// doLast {
-// configurations.testRuntime.each { println it }
-// }
-// }
+task printClasspath {
+ doLast {
+ configurations.testRuntime.each { println it }
+ }
+}
-archivesBaseName = "RangeExample"
+archivesBaseName = "chaincode"
mainClassName="example.RangeExample"
run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
+ if (project.hasProperty("appArgs")) {
+ args = Eval.me(appArgs)
+ }
}
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ }
}
repositories {
@@ -60,28 +59,25 @@ repositories {
}
-distZip {
-// destinationDir = file("${projectDir}")
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
+jar.doFirst {
+ destinationDir=file("${buildDir}")
+ manifest {
+ attributes (
+ 'Main-Class': mainClassName,
+ 'Class-Path': configurations.runtime.collect { "libs/"+"$it.name" }.join(' ')
+ )
+ }
}
-startScripts{
- applicationName='runChaincode'
+task copyToLib(type: Copy) {
+ into "$buildDir/libs"
+ from configurations.runtime
}
-
-// jar.doFirst {
-// destinationDir = file("${projectDir}")
-// manifest {
-// attributes ('Main-Class': mainClassName,
-// 'Class-Path': configurations.runtime.each { "/root/lib"+"/$it.name" }.join(' ')
-// )
-// }
-// }
+build.finalizedBy(copyToLib)
dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+ compile 'org.hyperledger:shim-client:1.0'
}
diff --git a/examples/chaincode/java/RangeExample/pom.xml b/examples/chaincode/java/RangeExample/pom.xml
new file mode 100644
index 00000000000..b778b5d40c2
--- /dev/null
+++ b/examples/chaincode/java/RangeExample/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-Range
+ jar
+ java-Range-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.RangeExample
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/examples/chaincode/java/SimpleSample/build.gradle b/examples/chaincode/java/SimpleSample/build.gradle
index 85b14480217..c98e18e29ce 100644
--- a/examples/chaincode/java/SimpleSample/build.gradle
+++ b/examples/chaincode/java/SimpleSample/build.gradle
@@ -16,36 +16,41 @@ limitations under the License.
buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ jcenter()
+ }
}
-
plugins {
- id "java"
- id "eclipse"
- id "application"
+ id "java"
+ id "eclipse"
+ id "application"
}
-archivesBaseName = "java-simplesample"
+task printClasspath {
+ doLast {
+ configurations.testRuntime.each { println it }
+ }
+}
+
+archivesBaseName = "chaincode"
mainClassName="example.SimpleSample"
run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
+ if (project.hasProperty("appArgs")) {
+ args = Eval.me(appArgs)
+ }
}
sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
+ main {
+ java {
+ srcDir 'src/main/java'
+ }
+ }
}
repositories {
@@ -54,18 +59,25 @@ repositories {
}
-distZip {
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
+jar.doFirst {
+ destinationDir=file("${buildDir}")
+ manifest {
+ attributes (
+ 'Main-Class': mainClassName,
+ 'Class-Path': configurations.runtime.collect { "libs/"+"$it.name" }.join(' ')
+ )
+ }
}
-startScripts{
- applicationName='runChaincode'
+task copyToLib(type: Copy) {
+ into "$buildDir/libs"
+ from configurations.runtime
}
+build.finalizedBy(copyToLib)
dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
+ compile 'io.grpc:grpc-all:0.13.2'
+ compile 'commons-cli:commons-cli:1.3.1'
+ compile 'org.hyperledger:shim-client:1.0'
}
diff --git a/examples/chaincode/java/SimpleSample/pom.xml b/examples/chaincode/java/SimpleSample/pom.xml
new file mode 100644
index 00000000000..99047b87446
--- /dev/null
+++ b/examples/chaincode/java/SimpleSample/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-SimpleSample
+ jar
+ java-SimpleSample-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.SimpleSample
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/examples/chaincode/java/TableExample/build.gradle b/examples/chaincode/java/TableExample/build.gradle
deleted file mode 100644
index e0d87bec086..00000000000
--- a/examples/chaincode/java/TableExample/build.gradle
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright DTCC 2016 All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-
-buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- jcenter()
- }
-}
-
-plugins {
- id "java"
- id "eclipse"
- id "application"
- id "idea"
-}
-
-archivesBaseName = "TableExample"
-mainClassName="example.TableExample"
-
-run {
- if (project.hasProperty("appArgs")) {
- args = Eval.me(appArgs)
- }
-}
-
-sourceSets {
- main {
- java {
- srcDir 'src/main/java'
- }
- }
-}
-
-repositories {
- mavenLocal()
- mavenCentral()
-}
-
-
-distZip {
-// destinationDir = file("${projectDir}")
- archiveName='Chaincode.zip'
- duplicatesStrategy='exclude'
-}
-
-startScripts{
- applicationName='runChaincode'
-}
-
-dependencies {
- compile 'io.grpc:grpc-all:0.13.2'
- compile 'commons-cli:commons-cli:1.3.1'
- compile project(':core:chaincode:shim:java')
- }
diff --git a/examples/chaincode/java/TableExample/pom.xml b/examples/chaincode/java/TableExample/pom.xml
new file mode 100644
index 00000000000..856a62c30ea
--- /dev/null
+++ b/examples/chaincode/java/TableExample/pom.xml
@@ -0,0 +1,94 @@
+
+
+
+ 1.8
+ 1.8
+
+
+ 4.0.0
+
+ example
+ chaincode-table
+ jar
+ java-table-example
+ 1.0
+ http://maven.apache.org
+
+ ${project.basedir}/build
+ chaincode
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.0.2
+
+ ${dist.dir}
+
+
+ true
+ libs/
+ example.TableExample
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/libs
+ false
+ false
+ true
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+ io.grpc
+ grpc-all
+ 0.13.2
+
+
+ commons-cli
+ commons-cli
+ 1.3.1
+
+
+ org.hyperledger
+ shim-client
+ 1.0
+
+
+
diff --git a/images/javaenv/Dockerfile.in b/images/javaenv/Dockerfile.in
index 31e1e4f60f0..6d5dfabd412 100644
--- a/images/javaenv/Dockerfile.in
+++ b/images/javaenv/Dockerfile.in
@@ -1,7 +1,15 @@
FROM hyperledger/fabric-baseimage:_BASE_TAG_
RUN wget https://services.gradle.org/distributions/gradle-2.12-bin.zip -P /tmp --quiet
-RUN unzip -q /tmp/gradle-2.12-bin.zip -d /opt && rm /tmp/gradle-2.12-bin.zip
+RUN unzip -qo /tmp/gradle-2.12-bin.zip -d /opt && rm /tmp/gradle-2.12-bin.zip
RUN ln -s /opt/gradle-2.12/bin/gradle /usr/bin
+ENV MAVEN_VERSION=3.3.9
+ENV USER_HOME_DIR="/root"
+RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
+ && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
+ | tar -xzC /usr/share/maven --strip-components=1 \
+ && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
+ENV MAVEN_HOME /usr/share/maven
+ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
ADD payload/javashim.tar.bz2 /root
ADD payload/protos.tar.bz2 /root
ADD payload/settings.gradle /root