-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-15213] Add Java FabCar sample contract
Change-Id: I0ae40c2a02aea8293a348038e3e1bd02f7030509 Signed-off-by: James Taylor <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
# Gradle | ||
.gradle | ||
/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | ||
# gradle/wrapper/gradle-wrapper.properties | ||
|
||
# Eclipse files | ||
.project | ||
.classpath | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.settings/ | ||
.loadpath | ||
.recommenders | ||
.externalToolBuilders/ | ||
*.launch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Java FabCar contract sample | ||
|
||
The directions for using this sample are documented in the Hyperledger Fabric | ||
[Writing Your First Application](https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html) tutorial. | ||
|
||
The tutorial is based on JavaScript, however the same concepts are applicable when using Java. | ||
|
||
To install and instantiate the Java version of `FabCar`, use the following command instead of the command shown in the [Launch the network](https://hyperledger-fabric.readthedocs.io/en/release-1.4/write_first_app.html#launch-the-network) section of the tutorial: | ||
|
||
``` | ||
./startFabric.sh javascript | ||
``` | ||
|
||
*NOTE:* After navigating to the documentation, choose the documentation version that matches your version of Fabric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
plugins { | ||
id 'checkstyle' | ||
id 'com.github.johnrengelman.shadow' version '2.0.4' | ||
id 'java-library' | ||
id 'jacoco' | ||
} | ||
|
||
group 'org.hyperledger.fabric.samples' | ||
version '1.0-SNAPSHOT' | ||
|
||
dependencies { | ||
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.0.0-SNAPSHOT' | ||
implementation 'com.owlike:genson:1.5' | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' | ||
testImplementation 'org.assertj:assertj-core:3.11.1' | ||
testImplementation 'org.mockito:mockito-core:2.+' | ||
} | ||
|
||
repositories { | ||
maven { | ||
url "https://nexus.hyperledger.org/content/repositories/snapshots/" | ||
} | ||
jcenter() | ||
maven { | ||
url 'https://jitpack.io' | ||
} | ||
} | ||
|
||
checkstyle { | ||
toolVersion '8.21' | ||
configFile file("config/checkstyle/checkstyle.xml") | ||
} | ||
|
||
checkstyleMain { | ||
source ='src/main/java' | ||
} | ||
|
||
checkstyleTest { | ||
source ='src/test/java' | ||
} | ||
|
||
shadowJar { | ||
baseName = 'chaincode' | ||
version = null | ||
classifier = null | ||
manifest { | ||
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' | ||
} | ||
} | ||
|
||
jacocoTestCoverageVerification { | ||
afterEvaluate { | ||
classDirectories = files(classDirectories.files.collect { | ||
fileTree(dir: it, exclude: [ | ||
'org/hyperledger/fabric/samples/fabcar/Start.*' | ||
]) | ||
}) | ||
} | ||
violationRules { | ||
rule { | ||
limit { | ||
minimum = 1.0 | ||
} | ||
} | ||
} | ||
|
||
finalizedBy jacocoTestReport | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
} | ||
} | ||
|
||
check.dependsOn jacocoTestCoverageVerification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE module PUBLIC | ||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" | ||
"https://checkstyle.org/dtds/configuration_1_3.dtd"> | ||
|
||
<!-- | ||
Checkstyle configuration that matches the Eclipse formatter | ||
Checkstyle is very configurable. Be sure to read the documentation at | ||
http://checkstyle.sourceforge.net (or in your downloaded distribution). | ||
Most Checks are configurable, be sure to consult the documentation. | ||
To completely disable a check, just comment it out or delete it from the file. | ||
Finally, it is worth reading the documentation. | ||
--> | ||
|
||
<module name="Checker"> | ||
<!-- | ||
If you set the basedir property below, then all reported file | ||
names will be relative to the specified directory. See | ||
https://checkstyle.org/5.x/config.html#Checker | ||
<property name="basedir" value="${basedir}"/> | ||
--> | ||
|
||
<property name="fileExtensions" value="java, properties, xml"/> | ||
|
||
<module name="SuppressionFilter"> | ||
<property name="file" value="config/checkstyle/suppressions.xml"/> | ||
<property name="optional" value="false"/> | ||
</module> | ||
|
||
<!-- Excludes all 'module-info.java' files --> | ||
<!-- See https://checkstyle.org/config_filefilters.html --> | ||
<module name="BeforeExecutionExclusionFileFilter"> | ||
<property name="fileNamePattern" value="module\-info\.java$"/> | ||
</module> | ||
|
||
<!-- Checks that a package-info.java file exists for each package. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage --> | ||
<!-- <module name="JavadocPackage"/> --> | ||
|
||
<!-- Checks whether files end with a new line. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile --> | ||
<module name="NewlineAtEndOfFile"/> | ||
|
||
<!-- Checks that property files contain the same keys. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_misc.html#Translation --> | ||
<module name="Translation"/> | ||
|
||
<!-- Checks for Size Violations. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_sizes.html --> | ||
<module name="FileLength"/> | ||
|
||
<!-- Checks for whitespace --> | ||
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html --> | ||
<module name="FileTabCharacter"/> | ||
|
||
<!-- Miscellaneous other checks. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_misc.html --> | ||
<module name="RegexpSingleline"> | ||
<property name="format" value="\s+$"/> | ||
<property name="minimum" value="0"/> | ||
<property name="maximum" value="0"/> | ||
<property name="message" value="Line has trailing spaces."/> | ||
</module> | ||
|
||
<!-- Checks for Headers --> | ||
<!-- See http://checkstyle.sourceforge.net/config_header.html --> | ||
<!-- <module name="Header"> --> | ||
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> --> | ||
<!-- <property name="fileExtensions" value="java"/> --> | ||
<!-- </module> --> | ||
|
||
<module name="TreeWalker"> | ||
|
||
<!-- Checks for Javadoc comments. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_javadoc.html --> | ||
<!-- <module name="JavadocMethod"/> --> | ||
<!-- <module name="JavadocType"/> --> | ||
<!-- <module name="JavadocVariable"/> --> | ||
<!-- <module name="JavadocStyle"/> --> | ||
<!-- <module name="MissingJavadocMethod"/> --> | ||
|
||
<!-- Checks for Naming Conventions. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_naming.html --> | ||
<module name="ConstantName"/> | ||
<module name="LocalFinalVariableName"/> | ||
<module name="LocalVariableName"/> | ||
<module name="MemberName"/> | ||
<module name="MethodName"/> | ||
<module name="PackageName"/> | ||
<module name="ParameterName"/> | ||
<module name="StaticVariableName"/> | ||
<module name="TypeName"/> | ||
|
||
<!-- Checks for imports --> | ||
<!-- See http://checkstyle.sourceforge.net/config_import.html --> | ||
<module name="AvoidStarImport"/> | ||
<module name="IllegalImport"/> <!-- defaults to sun.* packages --> | ||
<module name="RedundantImport"/> | ||
<module name="UnusedImports"> | ||
<property name="processJavadoc" value="false"/> | ||
</module> | ||
|
||
<!-- Checks for Size Violations. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_sizes.html --> | ||
<module name="LineLength"> | ||
<property name="max" value="120"/> | ||
</module> | ||
<module name="MethodLength"/> | ||
<module name="ParameterNumber"/> | ||
|
||
<!-- Checks for whitespace --> | ||
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html --> | ||
<module name="EmptyForIteratorPad"/> | ||
<module name="GenericWhitespace"/> | ||
<module name="MethodParamPad"/> | ||
<module name="NoWhitespaceAfter"/> | ||
<module name="NoWhitespaceBefore"/> | ||
<module name="OperatorWrap"/> | ||
<module name="ParenPad"/> | ||
<module name="TypecastParenPad"/> | ||
<module name="WhitespaceAfter"/> | ||
<module name="WhitespaceAround"/> | ||
|
||
<!-- Modifier Checks --> | ||
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html --> | ||
<module name="ModifierOrder"/> | ||
<module name="RedundantModifier"/> | ||
|
||
<!-- Checks for blocks. You know, those {}'s --> | ||
<!-- See http://checkstyle.sourceforge.net/config_blocks.html --> | ||
<module name="AvoidNestedBlocks"/> | ||
<module name="EmptyBlock"/> | ||
<module name="LeftCurly"/> | ||
<module name="NeedBraces"/> | ||
<module name="RightCurly"/> | ||
|
||
<!-- Checks for common coding problems --> | ||
<!-- See http://checkstyle.sourceforge.net/config_coding.html --> | ||
<module name="EmptyStatement"/> | ||
<module name="EqualsHashCode"/> | ||
<module name="HiddenField"> | ||
<property name="ignoreConstructorParameter" value="true"/> | ||
</module> | ||
<module name="IllegalInstantiation"/> | ||
<module name="InnerAssignment"/> | ||
<module name="MagicNumber"/> | ||
<module name="MissingSwitchDefault"/> | ||
<module name="MultipleVariableDeclarations"/> | ||
<module name="SimplifyBooleanExpression"/> | ||
<module name="SimplifyBooleanReturn"/> | ||
|
||
<!-- Checks for class design --> | ||
<!-- See http://checkstyle.sourceforge.net/config_design.html --> | ||
<module name="DesignForExtension"/> | ||
<module name="FinalClass"/> | ||
<module name="HideUtilityClassConstructor"/> | ||
<module name="InterfaceIsType"/> | ||
<module name="VisibilityModifier"> | ||
<property name="allowPublicFinalFields" value="true"/> | ||
</module> | ||
|
||
<!-- Miscellaneous other checks. --> | ||
<!-- See http://checkstyle.sourceforge.net/config_misc.html --> | ||
<module name="ArrayTypeStyle"/> | ||
<module name="FinalParameters"/> | ||
<module name="TodoComment"/> | ||
<module name="UpperEll"/> | ||
|
||
</module> | ||
|
||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!DOCTYPE suppressions PUBLIC | ||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" | ||
"https://checkstyle.org/dtds/suppressions_1_2.dtd"> | ||
|
||
<suppressions> | ||
<suppress files="ChaincodeTest.java" checks="ParameterNumber" /> | ||
</suppressions> |
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
chaincode/fabcar/java/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.