From bdedc82c38bfabb4be324c923d45397fe6ad0b2b Mon Sep 17 00:00:00 2001 From: Kodai Doki <52027276+KodaiD@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:57:11 +0900 Subject: [PATCH] Replace deprecated Gradle/ScalarDB features (#74) * Replace deprecated Gradle features * Replace deprecated put with update and insert * Replace deprecated put with update and upsert in the Kotilin sample * Change function names from put to insert * Renamed the delete task --- .../client/build.gradle | 13 ++++--- .../customer-service/build.gradle | 13 ++++--- .../java/sample/customer/CustomerService.java | 2 +- .../java/sample/customer/model/Customer.java | 13 +++---- .../order-service/build.gradle | 13 ++++--- .../main/java/sample/order/OrderService.java | 10 +++--- .../main/java/sample/order/model/Item.java | 8 ++--- .../main/java/sample/order/model/Order.java | 8 ++--- .../java/sample/order/model/Statement.java | 8 ++--- .../rpc/build.gradle | 34 ++++++++++++++++--- multi-storage-transaction-sample/build.gradle | 13 ++++--- .../src/main/java/sample/Sample.java | 31 +++++++++-------- scalardb-kotlin-sample/build.gradle.kts | 11 ++---- .../src/main/kotlin/sample/ElectronicMoney.kt | 15 ++++---- scalardb-sample/build.gradle | 13 ++++--- .../src/main/java/sample/Sample.java | 31 +++++++++-------- scalardb-sql-jdbc-sample/build.gradle | 13 ++++--- .../client/build.gradle | 13 ++++--- .../customer-service/build.gradle | 13 ++++--- .../order-service/build.gradle | 13 ++++--- .../rpc/build.gradle | 34 ++++++++++++++++--- .../build.gradle | 13 ++++--- spring-data-sample/build.gradle | 13 ++++--- 23 files changed, 225 insertions(+), 123 deletions(-) diff --git a/microservice-transaction-sample/client/build.gradle b/microservice-transaction-sample/client/build.gradle index d9e03945..99172ba1 100644 --- a/microservice-transaction-sample/client/build.gradle +++ b/microservice-transaction-sample/client/build.gradle @@ -10,10 +10,15 @@ dependencies { } application { - mainClassName = 'sample.client.Client' + mainClass = 'sample.client.Client' } -archivesBaseName = "sample-order-service" +base { + archivesName = "sample-order-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/microservice-transaction-sample/customer-service/build.gradle b/microservice-transaction-sample/customer-service/build.gradle index 06a2d678..6b09fb0b 100644 --- a/microservice-transaction-sample/customer-service/build.gradle +++ b/microservice-transaction-sample/customer-service/build.gradle @@ -14,7 +14,7 @@ dependencies { } application { - mainClassName = 'sample.customer.CustomerServiceServer' + mainClass = 'sample.customer.CustomerServiceServer' } task copyFilesToDockerBuildContextDir(type: Copy) { @@ -47,7 +47,12 @@ installDist { duplicatesStrategy DuplicatesStrategy.EXCLUDE } -archivesBaseName = "sample-customer-service" +base { + archivesName = "sample-customer-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/microservice-transaction-sample/customer-service/src/main/java/sample/customer/CustomerService.java b/microservice-transaction-sample/customer-service/src/main/java/sample/customer/CustomerService.java index c3bb5a89..c797e3d3 100644 --- a/microservice-transaction-sample/customer-service/src/main/java/sample/customer/CustomerService.java +++ b/microservice-transaction-sample/customer-service/src/main/java/sample/customer/CustomerService.java @@ -74,7 +74,7 @@ private void loadCustomerIfNotExists( throws CrudException { Optional customer = Customer.get(transaction, id); if (!customer.isPresent()) { - Customer.put(transaction, id, name, creditLimit, creditTotal); + Customer.insert(transaction, id, name, creditLimit, creditTotal); } } diff --git a/microservice-transaction-sample/customer-service/src/main/java/sample/customer/model/Customer.java b/microservice-transaction-sample/customer-service/src/main/java/sample/customer/model/Customer.java index e241f1a8..ea39dd8f 100644 --- a/microservice-transaction-sample/customer-service/src/main/java/sample/customer/model/Customer.java +++ b/microservice-transaction-sample/customer-service/src/main/java/sample/customer/model/Customer.java @@ -1,8 +1,9 @@ package sample.customer.model; import com.scalar.db.api.Get; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.TransactionCrudOperable; +import com.scalar.db.api.Update; import com.scalar.db.exception.transaction.CrudException; import com.scalar.db.io.Key; import java.util.Optional; @@ -27,11 +28,11 @@ public Customer(int id, String name, int creditLimit, int creditTotal) { this.creditTotal = creditTotal; } - public static void put( + public static void insert( TransactionCrudOperable transaction, int id, String name, int creditLimit, int creditTotal) throws CrudException { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(Key.ofInt(COL_CUSTOMER_ID, id)) @@ -43,8 +44,8 @@ public static void put( public static void updateCreditTotal(TransactionCrudOperable transaction, int id, int creditTotal) throws CrudException { - transaction.put( - Put.newBuilder() + transaction.update( + Update.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(Key.ofInt(COL_CUSTOMER_ID, id)) diff --git a/microservice-transaction-sample/order-service/build.gradle b/microservice-transaction-sample/order-service/build.gradle index 93474998..d6acded6 100644 --- a/microservice-transaction-sample/order-service/build.gradle +++ b/microservice-transaction-sample/order-service/build.gradle @@ -14,7 +14,7 @@ dependencies { } application { - mainClassName = 'sample.order.OrderServiceServer' + mainClass = 'sample.order.OrderServiceServer' } task copyFilesToDockerBuildContextDir(type: Copy) { @@ -47,7 +47,12 @@ installDist { duplicatesStrategy DuplicatesStrategy.EXCLUDE } -archivesBaseName = "sample-order-service" +base { + archivesName = "sample-order-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/microservice-transaction-sample/order-service/src/main/java/sample/order/OrderService.java b/microservice-transaction-sample/order-service/src/main/java/sample/order/OrderService.java index 60fcd5e8..7b206d8d 100644 --- a/microservice-transaction-sample/order-service/src/main/java/sample/order/OrderService.java +++ b/microservice-transaction-sample/order-service/src/main/java/sample/order/OrderService.java @@ -94,7 +94,7 @@ private void loadItemIfNotExists( DistributedTransaction transaction, int id, String name, int price) throws CrudException { Optional item = Item.get(transaction, id); if (!item.isPresent()) { - Item.put(transaction, id, name, price); + Item.insert(transaction, id, name, price); } } @@ -106,13 +106,13 @@ public void placeOrder( transaction -> { String orderId = UUID.randomUUID().toString(); - // Put the order info into the orders table - Order.put(transaction, orderId, request.getCustomerId(), System.currentTimeMillis()); + // Insert the order info into the orders table + Order.insert(transaction, orderId, request.getCustomerId(), System.currentTimeMillis()); int amount = 0; for (ItemOrder itemOrder : request.getItemOrderList()) { - // Put the order statement into the statements table - Statement.put(transaction, orderId, itemOrder.getItemId(), itemOrder.getCount()); + // Insert the order statement into the statements table + Statement.insert(transaction, orderId, itemOrder.getItemId(), itemOrder.getCount()); // Retrieve the item info from the items table Optional item = Item.get(transaction, itemOrder.getItemId()); diff --git a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Item.java b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Item.java index 9ea86692..390c8452 100644 --- a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Item.java +++ b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Item.java @@ -1,7 +1,7 @@ package sample.order.model; import com.scalar.db.api.Get; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.TransactionCrudOperable; import com.scalar.db.exception.transaction.CrudException; import com.scalar.db.io.Key; @@ -25,10 +25,10 @@ public Item(int id, String name, int price) { this.price = price; } - public static void put(TransactionCrudOperable transaction, int id, String name, int price) + public static void insert(TransactionCrudOperable transaction, int id, String name, int price) throws CrudException { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(Key.ofInt(COL_ITEM_ID, id)) diff --git a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Order.java b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Order.java index e0eb2d48..1f8318c4 100644 --- a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Order.java +++ b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Order.java @@ -1,7 +1,7 @@ package sample.order.model; import com.scalar.db.api.Get; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.Result; import com.scalar.db.api.Scan; import com.scalar.db.api.Scan.Ordering; @@ -30,11 +30,11 @@ public Order(String id, int customerId, long timestamp) { this.timestamp = timestamp; } - public static void put( + public static void insert( TransactionCrudOperable transaction, String id, int customerId, long timestamp) throws CrudException { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(Key.ofInt(COL_CUSTOMER_ID, customerId)) diff --git a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Statement.java b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Statement.java index 5e8c8698..9dbe846f 100644 --- a/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Statement.java +++ b/microservice-transaction-sample/order-service/src/main/java/sample/order/model/Statement.java @@ -1,6 +1,6 @@ package sample.order.model; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.Scan; import com.scalar.db.api.TransactionCrudOperable; import com.scalar.db.exception.transaction.CrudException; @@ -26,10 +26,10 @@ public Statement(String orderId, int itemId, int count) { this.count = count; } - public static void put(TransactionCrudOperable transaction, String orderId, int itemId, int count) + public static void insert(TransactionCrudOperable transaction, String orderId, int itemId, int count) throws CrudException { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace(NAMESPACE) .table(TABLE) .partitionKey(Key.ofText(COL_ORDER_ID, orderId)) diff --git a/microservice-transaction-sample/rpc/build.gradle b/microservice-transaction-sample/rpc/build.gradle index c8f3a3d8..9b77d636 100644 --- a/microservice-transaction-sample/rpc/build.gradle +++ b/microservice-transaction-sample/rpc/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'java-library-distribution' - id 'com.google.protobuf' version '0.9.1' + id 'com.google.protobuf' version '0.9.4' } dependencies { @@ -20,10 +20,26 @@ protobuf { generateProtoTasks { all()*.plugins { grpc {} } } - generatedFilesBaseDir = "$projectDir/src" } -archivesBaseName = "sample-rpc" +base { + archivesName = "sample-rpc" +} + +// Task copyGeneratedProtoToSrc copies the generated .java files into src directory +task copyGeneratedProtoToSrc(type: Copy) { + description 'Copies generated Protocol Buffer classes to src/main/java/sample/rpc' + dependsOn generateProto + from "$buildDir/generated/source/proto/main/java/sample/rpc" + into "$projectDir/src/main/java/sample/rpc" + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + +// Task deleteGeneratedProto deletes the generated .java files in build directory +task deleteGeneratedProto(type: Delete) { + dependsOn copyGeneratedProtoToSrc + delete fileTree(dir: "$buildDir/generated/source/proto/main/java/sample/rpc") +} // The processResources task needs to depend on the generateProto task because it uses the output // of the the generateProto task @@ -31,5 +47,13 @@ processResources { dependsOn generateProto } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +// Task deleteGeneratedProto needs to depend on deleteGeneratedProto to avoid duplicate class error +tasks.named("compileJava").configure { + dependsOn deleteGeneratedProto +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/multi-storage-transaction-sample/build.gradle b/multi-storage-transaction-sample/build.gradle index 11e06ee0..eedb249e 100644 --- a/multi-storage-transaction-sample/build.gradle +++ b/multi-storage-transaction-sample/build.gradle @@ -16,10 +16,15 @@ dependencies { } application { - mainClassName = 'sample.command.SampleCommand' + mainClass = 'sample.command.SampleCommand' } -archivesBaseName = "sample" +base { + archivesName = "sample" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/multi-storage-transaction-sample/src/main/java/sample/Sample.java b/multi-storage-transaction-sample/src/main/java/sample/Sample.java index 9458347a..9f015a2d 100644 --- a/multi-storage-transaction-sample/src/main/java/sample/Sample.java +++ b/multi-storage-transaction-sample/src/main/java/sample/Sample.java @@ -3,9 +3,10 @@ import com.scalar.db.api.DistributedTransaction; import com.scalar.db.api.DistributedTransactionManager; import com.scalar.db.api.Get; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.Result; import com.scalar.db.api.Scan; +import com.scalar.db.api.Update; import com.scalar.db.exception.transaction.TransactionException; import com.scalar.db.io.Key; import com.scalar.db.service.TransactionFactory; @@ -62,8 +63,8 @@ private void loadCustomerIfNotExists( .partitionKey(Key.ofInt("customer_id", customerId)) .build()); if (!customer.isPresent()) { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace("customer") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -85,8 +86,8 @@ private void loadItemIfNotExists( .partitionKey(Key.ofInt("item_id", itemId)) .build()); if (!item.isPresent()) { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace("order") .table("items") .partitionKey(Key.ofInt("item_id", itemId)) @@ -146,9 +147,9 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) // Start a transaction transaction = manager.start(); - // Put the order info into the orders table - transaction.put( - Put.newBuilder() + // Insert the order info into the orders table + transaction.insert( + Insert.newBuilder() .namespace("order") .table("orders") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -161,9 +162,9 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) int itemId = itemIds[i]; int count = itemCounts[i]; - // Put the order statement into the statements table - transaction.put( - Put.newBuilder() + // Insert the order statement into the statements table + transaction.insert( + Insert.newBuilder() .namespace("order") .table("statements") .partitionKey(Key.ofText("order_id", orderId)) @@ -206,8 +207,8 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) } // Update credit_total for the customer - transaction.put( - Put.newBuilder() + transaction.update( + Update.newBuilder() .namespace("customer") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -389,8 +390,8 @@ public void repayment(int customerId, int amount) throws TransactionException { } // Reduce credit_total for the customer - transaction.put( - Put.newBuilder() + transaction.update( + Update.newBuilder() .namespace("customer") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) diff --git a/scalardb-kotlin-sample/build.gradle.kts b/scalardb-kotlin-sample/build.gradle.kts index 1bc59a68..eb35aabf 100644 --- a/scalardb-kotlin-sample/build.gradle.kts +++ b/scalardb-kotlin-sample/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "2.0.21" application } @@ -21,13 +21,8 @@ tasks.test { useJUnitPlatform() } -tasks.withType { - kotlinOptions.jvmTarget = "1.8" -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 +kotlin { + jvmToolchain(8) } application { diff --git a/scalardb-kotlin-sample/src/main/kotlin/sample/ElectronicMoney.kt b/scalardb-kotlin-sample/src/main/kotlin/sample/ElectronicMoney.kt index 15cefaa5..43a7de13 100644 --- a/scalardb-kotlin-sample/src/main/kotlin/sample/ElectronicMoney.kt +++ b/scalardb-kotlin-sample/src/main/kotlin/sample/ElectronicMoney.kt @@ -2,7 +2,8 @@ package sample import com.scalar.db.api.DistributedTransactionManager import com.scalar.db.api.Get -import com.scalar.db.api.Put +import com.scalar.db.api.Update +import com.scalar.db.api.Upsert import com.scalar.db.exception.transaction.TransactionException import com.scalar.db.io.Key import com.scalar.db.service.TransactionFactory @@ -43,13 +44,13 @@ class ElectronicMoney(scalarDBProperties: String) { } // Update the balance - val put = Put.newBuilder() + val upsert = Upsert.newBuilder() .namespace(NAMESPACE) .table(TABLENAME) .partitionKey(Key.ofText(ID, id)) .intValue(BALANCE, balance) .build() - tx.put(put) + tx.upsert(upsert) // Commit the transaction (records are automatically recovered in case of failure) tx.commit() @@ -86,20 +87,20 @@ class ElectronicMoney(scalarDBProperties: String) { } // Update the balances - val fromPut = Put.newBuilder() + val fromUpdate = Update.newBuilder() .namespace(NAMESPACE) .table(TABLENAME) .partitionKey(Key.ofText(ID, fromId)) .intValue(BALANCE, newFromBalance) .build() - val toPut = Put.newBuilder() + val toUpdate = Update.newBuilder() .namespace(NAMESPACE) .table(TABLENAME) .partitionKey(Key.ofText(ID, toId)) .intValue(BALANCE, newToBalance) .build() - tx.put(fromPut) - tx.put(toPut) + tx.update(fromUpdate) + tx.update(toUpdate) // Commit the transaction (records are automatically recovered in case of failure) tx.commit() diff --git a/scalardb-sample/build.gradle b/scalardb-sample/build.gradle index 11e06ee0..eedb249e 100644 --- a/scalardb-sample/build.gradle +++ b/scalardb-sample/build.gradle @@ -16,10 +16,15 @@ dependencies { } application { - mainClassName = 'sample.command.SampleCommand' + mainClass = 'sample.command.SampleCommand' } -archivesBaseName = "sample" +base { + archivesName = "sample" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/scalardb-sample/src/main/java/sample/Sample.java b/scalardb-sample/src/main/java/sample/Sample.java index f0763433..5c40457e 100644 --- a/scalardb-sample/src/main/java/sample/Sample.java +++ b/scalardb-sample/src/main/java/sample/Sample.java @@ -3,9 +3,10 @@ import com.scalar.db.api.DistributedTransaction; import com.scalar.db.api.DistributedTransactionManager; import com.scalar.db.api.Get; -import com.scalar.db.api.Put; +import com.scalar.db.api.Insert; import com.scalar.db.api.Result; import com.scalar.db.api.Scan; +import com.scalar.db.api.Update; import com.scalar.db.exception.transaction.TransactionException; import com.scalar.db.io.Key; import com.scalar.db.service.TransactionFactory; @@ -62,8 +63,8 @@ private void loadCustomerIfNotExists( .partitionKey(Key.ofInt("customer_id", customerId)) .build()); if (!customer.isPresent()) { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace("sample") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -85,8 +86,8 @@ private void loadItemIfNotExists( .partitionKey(Key.ofInt("item_id", itemId)) .build()); if (!item.isPresent()) { - transaction.put( - Put.newBuilder() + transaction.insert( + Insert.newBuilder() .namespace("sample") .table("items") .partitionKey(Key.ofInt("item_id", itemId)) @@ -146,9 +147,9 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) // Start a transaction transaction = manager.start(); - // Put the order info into the orders table - transaction.put( - Put.newBuilder() + // Insert the order info into the orders table + transaction.insert( + Insert.newBuilder() .namespace("sample") .table("orders") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -161,9 +162,9 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) int itemId = itemIds[i]; int count = itemCounts[i]; - // Put the order statement into the statements table - transaction.put( - Put.newBuilder() + // Insert the order statement into the statements table + transaction.insert( + Insert.newBuilder() .namespace("sample") .table("statements") .partitionKey(Key.ofText("order_id", orderId)) @@ -205,8 +206,8 @@ public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) } // Update credit_total for the customer - transaction.put( - Put.newBuilder() + transaction.update( + Update.newBuilder() .namespace("sample") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) @@ -388,8 +389,8 @@ public void repayment(int customerId, int amount) throws TransactionException { } // Reduce credit_total for the customer - transaction.put( - Put.newBuilder() + transaction.update( + Update.newBuilder() .namespace("sample") .table("customers") .partitionKey(Key.ofInt("customer_id", customerId)) diff --git a/scalardb-sql-jdbc-sample/build.gradle b/scalardb-sql-jdbc-sample/build.gradle index 42de9652..c8dc0cf8 100644 --- a/scalardb-sql-jdbc-sample/build.gradle +++ b/scalardb-sql-jdbc-sample/build.gradle @@ -17,10 +17,15 @@ dependencies { } application { - mainClassName = 'sample.command.SampleCommand' + mainClass = 'sample.command.SampleCommand' } -archivesBaseName = "sample" +base { + archivesName = "sample" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-microservice-transaction-sample/client/build.gradle b/spring-data-microservice-transaction-sample/client/build.gradle index d9e03945..99172ba1 100644 --- a/spring-data-microservice-transaction-sample/client/build.gradle +++ b/spring-data-microservice-transaction-sample/client/build.gradle @@ -10,10 +10,15 @@ dependencies { } application { - mainClassName = 'sample.client.Client' + mainClass = 'sample.client.Client' } -archivesBaseName = "sample-order-service" +base { + archivesName = "sample-order-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-microservice-transaction-sample/customer-service/build.gradle b/spring-data-microservice-transaction-sample/customer-service/build.gradle index 3262cd70..a530ca2c 100644 --- a/spring-data-microservice-transaction-sample/customer-service/build.gradle +++ b/spring-data-microservice-transaction-sample/customer-service/build.gradle @@ -16,7 +16,7 @@ dependencies { } application { - mainClassName = 'sample.customer.CustomerServiceServer' + mainClass = 'sample.customer.CustomerServiceServer' } task copyFilesToDockerBuildContextDir(type: Copy) { @@ -49,7 +49,12 @@ installDist { duplicatesStrategy DuplicatesStrategy.EXCLUDE } -archivesBaseName = "sample-customer-service" +base { + archivesName = "sample-customer-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-microservice-transaction-sample/order-service/build.gradle b/spring-data-microservice-transaction-sample/order-service/build.gradle index 92ee5f2c..a6013204 100644 --- a/spring-data-microservice-transaction-sample/order-service/build.gradle +++ b/spring-data-microservice-transaction-sample/order-service/build.gradle @@ -16,7 +16,7 @@ dependencies { } application { - mainClassName = 'sample.order.OrderServiceServer' + mainClass = 'sample.order.OrderServiceServer' } task copyFilesToDockerBuildContextDir(type: Copy) { @@ -49,7 +49,12 @@ installDist { duplicatesStrategy DuplicatesStrategy.EXCLUDE } -archivesBaseName = "sample-order-service" +base { + archivesName = "sample-order-service" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-microservice-transaction-sample/rpc/build.gradle b/spring-data-microservice-transaction-sample/rpc/build.gradle index 59b163a7..d8a59ccc 100644 --- a/spring-data-microservice-transaction-sample/rpc/build.gradle +++ b/spring-data-microservice-transaction-sample/rpc/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'java-library-distribution' - id 'com.google.protobuf' version '0.9.1' + id 'com.google.protobuf' version '0.9.4' } dependencies { @@ -20,10 +20,26 @@ protobuf { generateProtoTasks { all()*.plugins { grpc {} } } - generatedFilesBaseDir = "$projectDir/src" } -archivesBaseName = "sample-rpc" +base { + archivesName = "sample-rpc" +} + +// Task copyGeneratedProtoToSrc copies the generated .java files into src directory +task copyGeneratedProtoToSrc(type: Copy) { + description 'Copies generated Protocol Buffer classes to src/main/java/sample/rpc' + dependsOn generateProto + from "$buildDir/generated/source/proto/main/java/sample/rpc" + into "$projectDir/src/main/java/sample/rpc" + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + +// Task deleteGeneratedProto deletes the generated .java files in build directory +task deleteGeneratedProto(type: Delete) { + dependsOn copyGeneratedProtoToSrc + delete fileTree(dir: "$buildDir/generated/source/proto/main/java/sample/rpc") +} // The processResources task needs to depend on the generateProto task because it uses the output // of the the generateProto task @@ -31,5 +47,13 @@ processResources { dependsOn generateProto } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +// Task deleteGeneratedProto needs to depend on deleteGeneratedProto to avoid duplicate class error +tasks.named("compileJava").configure { + dependsOn deleteGeneratedProto +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-multi-storage-transaction-sample/build.gradle b/spring-data-multi-storage-transaction-sample/build.gradle index 359e66ca..7788ccea 100644 --- a/spring-data-multi-storage-transaction-sample/build.gradle +++ b/spring-data-multi-storage-transaction-sample/build.gradle @@ -24,10 +24,15 @@ dependencies { } application { - mainClassName = 'sample.SampleApp' + mainClass = 'sample.SampleApp' } -archivesBaseName = "sample" +base { + archivesName = "sample" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/spring-data-sample/build.gradle b/spring-data-sample/build.gradle index 359e66ca..7788ccea 100644 --- a/spring-data-sample/build.gradle +++ b/spring-data-sample/build.gradle @@ -24,10 +24,15 @@ dependencies { } application { - mainClassName = 'sample.SampleApp' + mainClass = 'sample.SampleApp' } -archivesBaseName = "sample" +base { + archivesName = "sample" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +}