Skip to content

Commit

Permalink
fix: Fix Gradle deprecation warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Sheehy <[email protected]>
  • Loading branch information
steven-sheehy committed Jan 22, 2025
1 parent 5907944 commit 1f91732
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

*
* Fix Gradle deprecation warnings

### Features

Expand Down
19 changes: 13 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ plugins {
id 'jacoco'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.gradle.plugin-publish' version '1.2.1'
id 'de.undercouch.download' version '4.1.2'
id 'de.undercouch.download' version '5.6.0'
}

description = 'Gradle plugin providing tasks to generate Web3j contracts from Solidity.'
sourceCompatibility = 17

java {
sourceCompatibility = 17
}

ext {
web3jVersion = version
Expand All @@ -25,7 +28,7 @@ apply {
'spotless',
'junit'
].each { buildScript ->
download {
download.run {
src "https://raw.githubusercontent.com/hyperledger-web3j/web3j-build-tools/main/gradle/$buildScript/build.gradle"
dest "$rootDir/gradle/$buildScript/build.gradle"
overwrite true
Expand Down Expand Up @@ -89,16 +92,16 @@ sourceSets {
}
}

task generateVersionProperties {
tasks.register("generateVersionProperties") {
doLast {
new File(generatedResources).mkdirs()
def generated = new File(generatedResources, "version.properties")
generated.text = "version=$rootProject.version"
}
}

tasks.withType(Test) {
reports.html.destination file("${reporting.baseDir}/${name}")
test {
reports.html.outputLocation = file("${reporting.baseDir}/${name}")
}

tasks.named('spotlessKotlin') {
Expand All @@ -112,3 +115,7 @@ tasks.named('spotlessJava') {
dependsOn tasks.named('javadoc')
dependsOn tasks.named('test')
}

tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:-missing', '-quiet')
}
4 changes: 3 additions & 1 deletion src/main/java/org/web3j/gradle/plugin/Web3jExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public void setAddressBitLength(final int addressBitLength) {

public Web3jExtension(final Project project) {
generatedFilesBaseDir =
project.getBuildDir().getAbsolutePath() + "/generated/sources/" + NAME;
project.getLayout().getBuildDirectory().getAsFile().get().getAbsolutePath()
+ "/generated/sources/"
+ NAME;

// Use the project's group name in generated package
generatedPackageName = getDefaultGeneratedPackageName(project);
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/web3j/gradle/plugin/Web3jPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.gradle.api.internal.plugins.PluginApplicationException;
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.SourceTask;
Expand All @@ -50,7 +50,7 @@ public void apply(final Project target) {
registerExtensions(target);

final SourceSetContainer sourceSets =
target.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
target.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();

target.afterEvaluate(p -> sourceSets.all(sourceSet -> configure(target, sourceSet)));
}
Expand Down Expand Up @@ -98,9 +98,7 @@ private void configure(final Project project, final SourceSet sourceSet) {
sourceSet.getJava().srcDir(outputDir);

final String srcSetName =
sourceSet.getName().equals("main")
? ""
: capitalize((CharSequence) sourceSet.getName());
sourceSet.getName().equals("main") ? "" : capitalize(sourceSet.getName());

final String generateTaskName = "generate" + srcSetName + "ContractWrappers";

Expand Down Expand Up @@ -154,7 +152,7 @@ private void configure(final Project project, final SourceSet sourceSet) {
protected SourceDirectorySet buildSourceDirectorySet(
Project project, final SourceSet sourceSet) {

final String displayName = capitalize((CharSequence) sourceSet.getName()) + " Solidity BIN";
final String displayName = capitalize(sourceSet.getName()) + " Solidity BIN";

final SourceDirectorySet directorySet =
project.getObjects().sourceDirectorySet(sourceSet.getName(), displayName);
Expand Down

0 comments on commit 1f91732

Please sign in to comment.