Skip to content

Commit

Permalink
Merge pull request #27 from ftsrg/24-hypernate
Browse files Browse the repository at this point in the history
Use Hypernate library instead of subpackage

See #24
  • Loading branch information
bzp99 authored May 14, 2024
2 parents d31b322 + 222dd6c commit b3a74c0
Show file tree
Hide file tree
Showing 40 changed files with 169 additions and 1,035 deletions.
1 change: 1 addition & 0 deletions smart-contract/hyperledger-fabric/v2/java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY buildSrc/ buildSrc/
COPY build.gradle.kts ./
COPY gradle.properties ./
COPY specs/ ./specs/
COPY libs/ ./libs/

RUN gradle --no-daemon shadowJar

Expand Down
31 changes: 18 additions & 13 deletions smart-contract/hyperledger-fabric/v2/java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import hu.bme.mit.ftsrg.openjmlhelper.*
import java.io.File

val openJMLDir = layout.projectDirectory.dir(".openjml")
val openJMLJavaHomeDir = openJMLDir.dir("jdk")
Expand All @@ -21,7 +20,7 @@ plugins {
id("com.diffplug.spotless") version "6.19.0"
}

group = "hu.bme.mit.ftsrg.tpcc"
group = "hu.bme.mit.ftsrg.chaincode.tpcc"

version = "0.1.0"

Expand All @@ -31,7 +30,9 @@ repositories {
}

dependencies {
implementation("ch.qos.logback:logback-classic:1.4.8")
implementation("ch.qos.logback:logback-core:1.5.6")
implementation("ch.qos.logback:logback-classic:1.5.6")
implementation("org.slf4j:slf4j-api:2.0.13")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.jcabi:jcabi-aspects:0.25.1")
implementation("org.aspectj:aspectjrt:1.9.19")
Expand All @@ -40,6 +41,7 @@ dependencies {
implementation("org.hyperledger.fabric:fabric-protos:0.3.0")
implementation("org.json:json:20230227")
implementation("org.projectlombok:lombok:1.18.28")
implementation(files("libs/hypernate-0.1.0.jar"))
// Included also as implementation dependency so shadow will package it
implementation(files("$openJMLDir/jmlruntime.jar"))

Expand All @@ -60,9 +62,7 @@ tasks.named<ShadowJar>("shadowJar") {
tasks.named<Test>("test") { useJUnitPlatform() }

if (!noOpenJML) {
tasks.named<ShadowJar>("shadowJar") {
dependsOn(tasks.named("initOpenJML"))
}
tasks.named<ShadowJar>("shadowJar") { dependsOn(tasks.named("initOpenJML")) }

tasks.test {
java {
Expand All @@ -76,14 +76,20 @@ if (!noOpenJML) {
// Only when not compiling because of Spotless
if (!gradle.startParameter.taskNames.any { it.contains("spotlessApply") }) {
val mode =
when (System.getenv("JML_MODE")) {
"esc" -> "esc"
else -> "rac"
}
when (System.getenv("JML_MODE")) {
"esc" -> "esc"
else -> "rac"
}
options.isFork = true
options.compilerArgs.addAll(
listOf(
"-jml", "-$mode", "-timeout", "30", "--nullable-by-default", "--specs-path", "specs/"))
listOf(
"-jml",
"-$mode",
"-timeout",
"30",
"--nullable-by-default",
"--specs-path",
"specs/"))
options.forkOptions.javaHome = openJMLJavaHomeDir.asFile
}
}
Expand Down Expand Up @@ -120,4 +126,3 @@ if (!noOpenJML) {
logger.lifecycle("✅ OpenJML successfully initialized in $openJMLDir")
}
}

Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
openJMLVersion = 0.17.0-alpha-15
withoutOpenJML = false
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

package hu.bme.mit.ftsrg.chaincode.tpcc;

import hu.bme.mit.ftsrg.chaincode.dataaccess.exception.EntityExistsException;
import hu.bme.mit.ftsrg.chaincode.dataaccess.exception.EntityNotFoundException;
import hu.bme.mit.ftsrg.hypernate.entity.EntityExistsException;
import hu.bme.mit.ftsrg.hypernate.entity.EntityNotFoundException;
import hu.bme.mit.ftsrg.chaincode.tpcc.data.input.*;
import hu.bme.mit.ftsrg.chaincode.tpcc.data.output.*;
import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public class Customer extends SerializableEntityBase<Customer> {
public class Customer implements Entity<Customer> {

public /*@ pure @*/ int getC_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class District extends SerializableEntityBase<District> {
public final class District implements Entity<District> {

public /*@ pure @*/ int getD_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class History extends SerializableEntityBase<History> {
public final class History implements Entity<History> {

public /*@ pure @*/ int getH_c_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class Item extends SerializableEntityBase<Item> {
public final class Item implements Entity<Item> {

public /*@ pure @*/ int getI_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class NewOrder extends SerializableEntityBase<NewOrder> {
public final class NewOrder implements Entity<NewOrder> {

public /*@ pure @*/ int getNo_o_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class Order extends SerializableEntityBase<Order> {
public final class Order implements Entity<Order> {

public /*@ pure @*/ int getO_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class OrderLine extends SerializableEntityBase<OrderLine> {
public final class OrderLine implements Entity<OrderLine> {

public /*@ pure @*/ int getOl_o_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public final class Stock extends SerializableEntityBase<Stock> {
public final class Stock implements Entity<Stock> {

public /*@ pure @*/ int getS_i_id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package hu.bme.mit.ftsrg.chaincode.tpcc.data.entity;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntityBase;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;

public class Warehouse extends SerializableEntityBase<Warehouse> {
public class Warehouse implements Entity<Warehouse> {

public /*@ pure @*/ int getW_id();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hu.bme.mit.ftsrg.chaincode;

import hu.bme.mit.ftsrg.chaincode.dataaccess.SerializableEntity;
import hu.bme.mit.ftsrg.hypernate.entity.Entity;
import java.util.ArrayList;
import java.util.List;
import org.hyperledger.fabric.contract.Context;
Expand Down Expand Up @@ -40,7 +40,7 @@ public String generateParamsString(final Context ctx, final int... params) {
return "%s,%s".formatted(ctx.toString(), generateParamsString(params));
}

public <Type extends SerializableEntity<Type>> String generateParamsString(
public <Type extends Entity<Type>> String generateParamsString(
final Context ctx, final Type obj) {
return "%s,%s".formatted(ctx.toString(), obj.toString());
}
Expand Down
Loading

0 comments on commit b3a74c0

Please sign in to comment.