Skip to content

Commit 2570693

Browse files
committed
Add additional contracts for deployment test
Signed-off-by: Matthew B White <[email protected]>
1 parent e096d4f commit 2570693

File tree

17 files changed

+1098
-1
lines changed

17 files changed

+1098
-1
lines changed

fabric-chaincode-docker/build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ buildMaven() {
3939
cd ${TMP_DIR}
4040
echo "Maven build"
4141

42-
./mvnw compile package -DskipTests -Dmaven.test.skip=true
42+
if [ -f ./mvnw ]; then
43+
chmod +x ./gradlew
44+
./mvnw compile package -DskipTests -Dmaven.test.skip=true
45+
else
46+
/root/chaincode-java/mvnw compile package -DskipTests -Dmaven.test.skip=true
47+
fi
4348

4449
retval=$?
4550
if [ $retval -ne 0 ]; then
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id 'com.github.johnrengelman.shadow' version '5.1.0'
3+
id 'java'
4+
}
5+
6+
group 'org.hyperledger.fabric-chaincode-java'
7+
version '1.0-SNAPSHOT'
8+
9+
sourceCompatibility = 1.8
10+
11+
repositories {
12+
mavenLocal()
13+
mavenCentral()
14+
maven { url = "https://www.jitpack.io" }
15+
}
16+
17+
dependencies {
18+
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.3.1'
19+
implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-protos', version: '2.3.1'
20+
testImplementation group: 'junit', name: 'junit', version: '4.12'
21+
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
22+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
23+
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0'
24+
}
25+
26+
shadowJar {
27+
baseName = 'chaincode'
28+
version = null
29+
classifier = null
30+
31+
manifest {
32+
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
package org.hyperledger.fabric.example;
5+
6+
import org.hyperledger.fabric.contract.Context;
7+
import org.hyperledger.fabric.contract.ContractInterface;
8+
import org.hyperledger.fabric.contract.annotation.*;
9+
import org.hyperledger.fabric.metrics.Metrics;
10+
import org.hyperledger.fabric.metrics.MetricsProvider;
11+
import org.hyperledger.fabric.shim.ledger.*;
12+
import org.hyperledger.fabric.shim.*;
13+
14+
import java.util.*;
15+
import static java.nio.charset.StandardCharsets.UTF_8;
16+
17+
@Contract(name = "BareGradle",
18+
info = @Info(title = "BareGradle contract",
19+
description = "Contract but using all the APIs",
20+
version = "0.0.1",
21+
license =
22+
@License(name = "SPDX-License-Identifier: Apache-2.0",
23+
url = ""),
24+
contact = @Contact(email = "[email protected]",
25+
name = "fred",
26+
url = "http://fred.example.com")))
27+
@Default
28+
public class BareGradle implements ContractInterface {
29+
public BareGradle() {
30+
31+
}
32+
33+
@Transaction()
34+
public String whoami(Context ctx){
35+
this.getClass().getSimpleName();
36+
}
37+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MAX_INBOUND_MESSAGE_SIZE=4000
2+
CHAINCODE_METRICS_ENABLED=true
3+
TP_CORE_POOL_SIZE=4
4+
TP_MAX_POOL_SIZE=4
5+
TP_QUEUE_SIZE=4000
6+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>MyAssetContract</groupId>
5+
<artifactId>MyAssetContract</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<properties>
8+
9+
<!-- Generic properties -->
10+
<java.version>1.8</java.version>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
13+
14+
<!-- fabric-chaincode-java -->
15+
<fabric-chaincode-java.version>2.3.1</fabric-chaincode-java.version>
16+
17+
<!-- Logging -->
18+
<logback.version>1.0.13</logback.version>
19+
<slf4j.version>1.7.5</slf4j.version>
20+
21+
<!-- Test -->
22+
<junit.jupiter.version>5.3.0-RC1</junit.jupiter.version>
23+
<junit.platform.version>1.3.0-RC1</junit.platform.version>
24+
25+
</properties>
26+
27+
<repositories>
28+
<repository>
29+
<id>jitpack.io</id>
30+
<url>https://www.jitpack.io</url>
31+
</repository>
32+
<repository>
33+
<id>artifactory</id>
34+
<url>https://hyperledger.jfrog.io/hyperledger/fabric-maven</url>
35+
</repository>
36+
</repositories>
37+
38+
<dependencies>
39+
40+
<!-- fabric-chaincode-java -->
41+
<dependency>
42+
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
43+
<artifactId>fabric-chaincode-shim</artifactId>
44+
<version>${fabric-chaincode-java.version}</version>
45+
<scope>compile</scope>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>org.hyperledger.fabric-chaincode-java</groupId>
50+
<artifactId>fabric-chaincode-protos</artifactId>
51+
<version>${fabric-chaincode-java.version}</version>
52+
<scope>compile</scope>
53+
</dependency>
54+
55+
56+
<!-- fabric-sdk-java -->
57+
58+
<!-- Logging with SLF4J & LogBack -->
59+
<dependency>
60+
<groupId>org.slf4j</groupId>
61+
<artifactId>slf4j-api</artifactId>
62+
<version>${slf4j.version}</version>
63+
<scope>compile</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>ch.qos.logback</groupId>
67+
<artifactId>logback-classic</artifactId>
68+
<version>${logback.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
72+
<!-- Test Artifacts -->
73+
<dependency>
74+
<groupId>org.junit.jupiter</groupId>
75+
<artifactId>junit-jupiter-api</artifactId>
76+
<version>${junit.jupiter.version}</version>
77+
<scope>compile</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.junit.jupiter</groupId>
81+
<artifactId>junit-jupiter-params</artifactId>
82+
<version>${junit.jupiter.version}</version>
83+
<scope>test</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.junit.jupiter</groupId>
87+
<artifactId>junit-jupiter-engine</artifactId>
88+
<version>${junit.jupiter.version}</version>
89+
<scope>test</scope>
90+
</dependency>
91+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
92+
<dependency>
93+
<groupId>org.mockito</groupId>
94+
<artifactId>mockito-core</artifactId>
95+
<version>2.10.0</version>
96+
</dependency>
97+
98+
<!-- https://mvnrepository.com/artifact/org.json/json -->
99+
<dependency>
100+
<groupId>org.json</groupId>
101+
<artifactId>json</artifactId>
102+
<version>20180813</version>
103+
</dependency>
104+
105+
</dependencies>
106+
<build>
107+
<sourceDirectory>src</sourceDirectory>
108+
<plugins>
109+
<!-- JUnit 5 requires Surefire version 2.22.0 or higher -->
110+
<plugin>
111+
<artifactId>maven-surefire-plugin</artifactId>
112+
<version>2.22.0</version>
113+
</plugin>
114+
<plugin>
115+
<artifactId>maven-compiler-plugin</artifactId>
116+
<version>3.1</version>
117+
<configuration>
118+
<source>${java.version}</source>
119+
<target>${java.version}</target>
120+
</configuration>
121+
</plugin>
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-shade-plugin</artifactId>
125+
<version>3.1.0</version>
126+
<executions>
127+
<execution>
128+
<phase>package</phase>
129+
<goals>
130+
<goal>shade</goal>
131+
</goals>
132+
<configuration>
133+
<finalName>chaincode</finalName>
134+
<transformers>
135+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
136+
<mainClass>org.hyperledger.fabric.contract.ContractRouter</mainClass>
137+
</transformer>
138+
</transformers>
139+
<filters>
140+
<filter>
141+
<!-- filter out signature files from signed dependencies, else repackaging fails with security ex -->
142+
<artifact>*:*</artifact>
143+
<excludes>
144+
<exclude>META-INF/*.SF</exclude>
145+
<exclude>META-INF/*.DSA</exclude>
146+
<exclude>META-INF/*.RSA</exclude>
147+
</excludes>
148+
</filter>
149+
</filters>
150+
</configuration>
151+
</execution>
152+
</executions>
153+
</plugin>
154+
</plugins>
155+
</build>
156+
157+
158+
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
package org.hyperledger.fabric.example;
5+
6+
import org.hyperledger.fabric.contract.Context;
7+
import org.hyperledger.fabric.contract.ContractInterface;
8+
import org.hyperledger.fabric.contract.annotation.*;
9+
import org.hyperledger.fabric.metrics.Metrics;
10+
import org.hyperledger.fabric.metrics.MetricsProvider;
11+
import org.hyperledger.fabric.shim.ledger.*;
12+
import org.hyperledger.fabric.shim.*;
13+
14+
import java.util.*;
15+
import static java.nio.charset.StandardCharsets.UTF_8;
16+
17+
@Contract(name = "BareMaven",
18+
info = @Info(title = "BareGradle contract",
19+
description = "Contract but using all the APIs",
20+
version = "0.0.1",
21+
license =
22+
@License(name = "SPDX-License-Identifier: Apache-2.0",
23+
url = ""),
24+
contact = @Contact(email = "[email protected]",
25+
name = "fred",
26+
url = "http://fred.example.com")))
27+
@Default
28+
public class BareMaven implements ContractInterface {
29+
public BareMaven() {
30+
31+
}
32+
33+
@Transaction()
34+
public String whoami(Context ctx){
35+
this.getClass().getSimpleName();
36+
}
37+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MAX_INBOUND_MESSAGE_SIZE=4000
2+
CHAINCODE_METRICS_ENABLED=true
3+
TP_CORE_POOL_SIZE=4
4+
TP_MAX_POOL_SIZE=4
5+
TP_QUEUE_SIZE=4000
6+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

0 commit comments

Comments
 (0)