Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: replace Taskfile with Gradle tasks #2179

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions Taskfile.yml

This file was deleted.

1 change: 0 additions & 1 deletion developers.properties

This file was deleted.

18 changes: 7 additions & 11 deletions docs/sdk/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,46 +116,42 @@ More details about how to add/modify dependencies are found in the Hiero Gradle

## Maintaining generated files

> To execute the tasks below, you need to install the tool from this link: https://taskfile.dev/
> (these tasks are from the file Taskfile.yml, which is located in the root of the repository).
> Once installed, you can run the commands as shown below.
>
> Note that the below `task` commands should be run from the root of the project.
> Note that the below `./gradlew` commands should be run from the root of the project.

### Updating unit tests snapshots

```sh
task update:snapshots
./gradlew updateSnapshots
```

### Updating proto files

```sh
task update:proto
./gradlew updateSnapshots
```

### Updating address books

Update all address books:

```sh
task update:addressbooks
./gradlew examples:updateAddressbooks
```

Update address books only for a mainnet:

```sh
task update:addressbooks:mainnet
./gradlew examples:updateAddressbooksMainnet
```

Update address books only for a testnet:

```sh
task update:addressbooks:testnet
./gradlew examples:updateAddressbooksTestnet
```

Update address books only for a previewnet:

```sh
task update:addressbooks:previewnet
./gradlew examples:updateAddressbooksPreviewnet
```
19 changes: 19 additions & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,22 @@ abstract class RunAllExample : DefaultTask() {
}
}
}

val updateAddressbooks = tasks.register("updateAddressbooks")

listOf("mainnet", "testnet", "previewnet").forEach { network ->
val taskName = "updateAddressbooks${network.replaceFirstChar(Char::titlecase)}"
tasks.register<JavaExec>(taskName) {
workingDir = rootDir
classpath = configurations.runtimeClasspath.get() + files(tasks.jar)
mainModule = "com.hedera.hashgraph.examples"
mainClass = "com.hedera.hashgraph.sdk.examples.GetAddressBookExample"
environment("HEDERA_NETWORK", network)
doLast {
val binFile = File(workingDir, "address-book.proto.bin")
val target = File(workingDir, "../sdk/src/main/resources/addressbook/$network.pb")
binFile.copyTo(target, overwrite = true)
}
}
updateAddressbooks { dependsOn(taskName) }
}
24 changes: 3 additions & 21 deletions scripts/premade/FeeDataType-0.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* 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 com.hedera.hashgraph.sdk;
// SPDX-License-Identifier: Apache-2.0
package org.hiero.sdk;

import com.hedera.hashgraph.sdk.proto.SubType;
import org.hiero.sdk.proto.SubType;

/**
* Enum for the fee data types.
Expand Down
22 changes: 2 additions & 20 deletions scripts/premade/FreezeType-0.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* 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 com.hedera.hashgraph.sdk;
// SPDX-License-Identifier: Apache-2.0
package org.hiero.sdk;

/**
* Enum for the freeze types.
Expand Down
6 changes: 3 additions & 3 deletions scripts/premade/FreezeType-2.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
final com.hedera.hashgraph.sdk.proto.FreezeType code;
final org.hiero.sdk.proto.FreezeType code;

FreezeType(com.hedera.hashgraph.sdk.proto.FreezeType code) {
FreezeType(org.hiero.sdk.proto.FreezeType code) {
this.code = code;
}

static FreezeType valueOf(com.hedera.hashgraph.sdk.proto.FreezeType code) {
static FreezeType valueOf(org.hiero.sdk.proto.FreezeType code) {
return switch (code) {
24 changes: 3 additions & 21 deletions scripts/premade/RequestType-0.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* 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 com.hedera.hashgraph.sdk;
// SPDX-License-Identifier: Apache-2.0
package org.hiero.sdk;

import com.hedera.hashgraph.sdk.proto.HederaFunctionality;
import org.hiero.sdk.proto.HederaFunctionality;

/**
* Enum for the request types.
Expand Down
24 changes: 3 additions & 21 deletions scripts/premade/Status-0.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* 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 com.hedera.hashgraph.sdk;
// SPDX-License-Identifier: Apache-2.0
package org.hiero.sdk;

import com.hedera.hashgraph.sdk.proto.ResponseCodeEnum;
import org.hiero.sdk.proto.ResponseCodeEnum;

import java.util.Objects;

Expand Down
4 changes: 2 additions & 2 deletions scripts/update_protobufs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def go_to_script_dir():
MAIN_PATH = os.path.join("..", "sdk", "src", "main")
PROTO_OUT_PATH = os.path.join(MAIN_PATH, "proto")
PROTO_MIRROR_OUT_PATH = os.path.join(PROTO_OUT_PATH, "mirror")
JAVA_OUT_PATH = os.path.join(MAIN_PATH, "java", "com", "hedera", "hashgraph", "sdk")
JAVA_OUT_PATH = os.path.join(MAIN_PATH, "java", "org", "hiero", "sdk")
REQUEST_TYPE_OUT_PATH = os.path.join(JAVA_OUT_PATH, "RequestType.java")
STATUS_OUT_PATH = os.path.join(JAVA_OUT_PATH, "Status.java")
FEE_DATA_TYPE_OUT_PATH = os.path.join(JAVA_OUT_PATH, "FeeDataType.java")
Expand Down Expand Up @@ -325,7 +325,7 @@ def add_to_FeeDataType(original_name, cap_snake_name, comment_lines):

def add_to_FreezeType(original_name, cap_snake_name, comment_lines):
FreezeType_sections[1] += \
generate_enum(original_name, cap_snake_name, comment_lines, "com.hedera.hashgraph.sdk.proto.FreezeType", 1)
generate_enum(original_name, cap_snake_name, comment_lines, "org.hiero.sdk.proto.FreezeType", 1)
FreezeType_sections[3] += generate_valueOf(original_name, cap_snake_name, 3)


Expand Down
10 changes: 10 additions & 0 deletions sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ dependencyAnalysis.abi {
excludeClasses(".*Grpc")
}
}

tasks.register<Delete>("updateSnapshots") {
delete(sourceSets.test.get().allSource.matching { include("**/*.snap") })
finalizedBy(tasks.test)
}

tasks.register<Exec>("updateProto") {
executable = File(rootDir, "scripts/update_protobufs.py").absolutePath
args("main") // argument is the branch/tag
}