diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..0cbeb64e --- /dev/null +++ b/build.gradle @@ -0,0 +1,154 @@ +plugins { + id "java" + id "com.diffplug.spotless" version "6.19.0" + id "net.ltgt.errorprone" version "3.1.0" +} + +// ignore root project +spotless.enforceCheck(false) +jar.enabled(false) + +allprojects { + apply plugin: 'java' + apply plugin: 'java-library' + apply plugin: 'jacoco' + apply plugin: 'checkstyle' + apply plugin: 'com.diffplug.spotless' + apply plugin: 'net.ltgt.errorprone' + + repositories { + mavenCentral() + maven { + url "https://artifacts.consensys.net/public/teku/maven/" + } + maven { + url "https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/" + } + maven { + url "https://hyperledger.jfrog.io/artifactory/besu-maven/" + } + maven { + url "https://artifacts.consensys.net/public/maven/maven/" + } + } + + java { + toolchain { + languageVersion = JavaLanguageVersion.of(20) + } + withJavadocJar() + withSourcesJar() + } + + javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + options.addBooleanOption('-enable-preview', true) + options.addStringOption('-release', '20') + options.addStringOption('-add-modules', 'jdk.incubator.concurrent') + } + + jacoco { + toolVersion = "0.8.9" + } + + jacocoTestReport { + dependsOn test + + reports { + csv.required = true + } + } + + jacocoTestCoverageVerification { + violationRules { + rule { + limit { + minimum = 0 + } + } + } + } + + check { + dependsOn += jacocoTestCoverageVerification + } + + test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } + finalizedBy jacocoTestReport + } + + checkstyle { + toolVersion = '10.10.0' + // default checkstyle config -- specific to your team agreement + configFile = project(":").file("config/checkstyle/google_checks.xml") + } + + spotless { + // optional: limit format enforcement to just the files changed by this feature branch +// ratchetFrom 'origin/main' + + format 'misc', { + // define the files to apply `misc` to + target '*.gradle', '*.md', '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithTabs() // or spaces. Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // Use the default importOrder configuration + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + googleJavaFormat('1.17.0') + // fix formatting of type annotations + formatAnnotations() + + licenseHeaderFile(project(":").file("config/spotless/java.license")).named('hildr').onlyIfContentMatches('/*\n' + + ' * Copyright 2023 281165273grape@gmail.com') + licenseHeaderFile(project(":").file("config/spotless/besu.license")).named('besu').onlyIfContentMatches('/*\n' + + ' * Copyright ConsenSys AG') + licenseHeaderFile(project(":").file("config/spotless/java-thinkAfCod.license")).named('hildr-batcher').onlyIfContentMatches('/*\n' + + ' * Copyright 2023 q315xia@163.com') + + importOrder() + + removeUnusedImports() + } + } + + tasks.withType(Test).configureEach { + def outputDir = reports.junitXml.outputLocation + jvmArgumentProviders << ({ + [ + "-Djunit.platform.reporting.open.xml.enabled=true", + "-Djunit.platform.reporting.output.dir=${outputDir.get().asFile.absolutePath}", + "--enable-preview" + ] + } as CommandLineArgumentProvider) + } + + tasks.withType(JavaCompile).configureEach { + options.annotationProcessorPath = configurations.annotationProcessor + options.compilerArgs += "--enable-preview" + options.compilerArgs += "-Xlint:preview" + options.compilerArgs += ["--add-modules", "jdk.incubator.concurrent"] + options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] + } + + tasks.withType(Test).configureEach { + jvmArgs += "--enable-preview" + jvmArgs += ["--add-modules", "jdk.incubator.concurrent"] + } + + tasks.withType(JavaExec).configureEach { + jvmArgs += "--enable-preview" + jvmArgs += ["--add-modules", "jdk.incubator.concurrent"] + } +} diff --git a/config/spotless/java-thinkAfCod.license b/config/spotless/java-thinkAfCod.license new file mode 100644 index 00000000..0f83ab8b --- /dev/null +++ b/config/spotless/java-thinkAfCod.license @@ -0,0 +1,15 @@ +/* + * Copyright 2023 q315xia@163.com + * + * 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. + */ \ No newline at end of file diff --git a/hildr-batcher/build.gradle b/hildr-batcher/build.gradle index 00716239..912935e7 100644 --- a/hildr-batcher/build.gradle +++ b/hildr-batcher/build.gradle @@ -1,32 +1,9 @@ plugins { - id 'java' id 'application' - id 'checkstyle' - id "jacoco" - id "com.diffplug.spotless" version "6.19.0" - id "net.ltgt.errorprone" version "3.1.0" - id 'org.graalvm.buildtools.native' version '0.9.22' } group = 'io.optimism' -version = '0.1.0' - -repositories { - // Use Maven Central for resolving dependencies. - mavenCentral() - maven { - url "https://artifacts.consensys.net/public/teku/maven/" - } - maven { - url "https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/" - } - maven { - url "https://hyperledger.jfrog.io/artifactory/besu-maven/" - } - maven { - url "https://artifacts.consensys.net/public/maven/maven/" - } -} +version = '0.1.1' application { // Define the main class for the application. @@ -107,151 +84,6 @@ dependencies { errorprone("com.google.errorprone:error_prone_core:2.18.0") } -// Apply a specific Java toolchain to ease working on different environments. -java { - toolchain { - languageVersion = JavaLanguageVersion.of(20) - } -} - -test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } - finalizedBy jacocoTestReport -} - -jacoco { - toolVersion = "0.8.9" -} - -jacocoTestReport { - dependsOn test - - reports { - csv.required = true - } -} - -jacocoTestCoverageVerification { - - violationRules { - rule { - limit { - minimum = 0 - } - } - } -} - -checkstyle { - toolVersion = '10.10.0' - // default checkstyle config -- specific to your team agreement - configFile = project(":").file("config/checkstyle/google_checks.xml") - // Google style (idiosyncratic to Google): - // configFile = project(":").file("config/checkstyle/google_checks.xml") - // SUN style (closest to modern Java styles) -- the basis for this project: - // configFile = project(":").file("config/checkstyle/sun_checks.xml") -// ignoreFailures = false -// maxWarnings = 0 -} - -spotless { - // optional: limit format enforcement to just the files changed by this feature branch -// ratchetFrom 'origin/main' - - format 'misc', { - // define the files to apply `misc` to - target '*.gradle', '*.md', '.gitignore' - - // define the steps to apply to those files - trimTrailingWhitespace() - indentWithTabs() // or spaces. Takes an integer argument if you don't like 4 - endWithNewline() - } - java { - // Use the default importOrder configuration - - // don't need to set target, it is inferred from java - - // apply a specific flavor of google-java-format - googleJavaFormat('1.17.0') - // fix formatting of type annotations - formatAnnotations() - // make sure every file has the following copyright header. - // optionally, Spotless can set copyright years by digging - // through git history (see "license" section below) - licenseHeaderFile(project(":").file("config/spotless/java.license")).named('hildr').onlyIfContentMatches('/*\n' + - ' * Copyright 2023 281165273grape@gmail.com') - licenseHeaderFile(project(":").file("config/spotless/besu.license")).named('besu').onlyIfContentMatches('/*\n' + - ' * Copyright ConsenSys AG') - - importOrder() - - removeUnusedImports() - } -} - -checkstyleMain - .exclude('io/optimism/rpc/handler/TimeoutHandler.java') - .exclude('io/optimism/rpc/handler/JsonRpcExecutorHandler.java') - .exclude('io/optimism/rpc/handler/JsonRpcParseHandler.java') - .exclude('io/optimism/rpc/methods/JsonRpcMethod.java') - .exclude('io/optimism/rpc/methods/JsonRpcMethodsFactory.java') - .exclude('io/optimism/rpc/methods/JsonRpcProcessor.java') - .exclude('io/optimism/rpc/execution/LoggedJsonRpcProcessor.java') - .exclude('io/optimism/rpc/internal/JsonRpcRequest.java') - .exclude('io/optimism/rpc/internal/JsonRpcRequestContext.java') - .exclude('io/optimism/rpc/internal/JsonRpcRequestId.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcResponse.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcErrorResponse.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcError.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcResponseType.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcSuccessResponse.java') - .exclude('io/optimism/rpc/internal/response/JsonRpcNoResponse.java') - .exclude('io/optimism/rpc/execution/BaseJsonRpcProcessor.java') - .exclude('io/optimism/rpc/execution/JsonRpcProcessor.java') -//testSets { -// integrationTest -//} - -tasks.named('test') { - // Use JUnit Platform for unit tests. - useJUnitPlatform() -} - -check { - dependsOn += jacocoTestCoverageVerification -// dependsOn += integrationTest -} - -tasks.withType(Test).configureEach { - def outputDir = reports.junitXml.outputLocation - jvmArgumentProviders << ({ - [ - "-Djunit.platform.reporting.open.xml.enabled=true", - "-Djunit.platform.reporting.output.dir=${outputDir.get().asFile.absolutePath}", - "--enable-preview" - ] - } as CommandLineArgumentProvider) -} - -java { - withJavadocJar() - withSourcesJar() -} - - -javadoc { - if (JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html5', true) - } - options.addBooleanOption('-enable-preview', true) - options.addStringOption('-release', '20') - options.addStringOption('-add-modules', 'jdk.incubator.concurrent') -} - jar { manifest { attributes "Main-Class": "io.optimism.HildrBatcher" diff --git a/hildr-node/build.gradle b/hildr-node/build.gradle index eeca33cf..bdee2b79 100644 --- a/hildr-node/build.gradle +++ b/hildr-node/build.gradle @@ -7,58 +7,12 @@ */ plugins { - id 'java' - // Apply the application plugin to add support for building a CLI application in Java. id 'application' - id "checkstyle" - id "jacoco" - id "com.diffplug.spotless" version "6.19.0" - id "net.ltgt.errorprone" version "3.1.0" id 'org.graalvm.buildtools.native' version '0.9.22' -// id 'org.unbroken-dome.test-sets' version '4.0.0' -// id 'maven-publish' -// id "io.github.gradle-nexus.publish-plugin" version "1.1.0" -// id 'signing' } -group 'me.grapebaba' -version '0.1.0' - -repositories { - // Use Maven Central for resolving dependencies. - mavenCentral() - maven { - url "https://artifacts.consensys.net/public/teku/maven/" - } - maven { - url "https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/" - } - maven { - url "https://hyperledger.jfrog.io/artifactory/besu-maven/" - } - maven { - url "https://artifacts.consensys.net/public/maven/maven/" - } -} - - -tasks.withType(JavaCompile).configureEach { - options.annotationProcessorPath = configurations.annotationProcessor - options.compilerArgs += "--enable-preview" - options.compilerArgs += "-Xlint:preview" - options.compilerArgs += ["--add-modules", "jdk.incubator.concurrent"] - options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] -} - -tasks.withType(Test).configureEach { - jvmArgs += "--enable-preview" - jvmArgs += ["--add-modules", "jdk.incubator.concurrent"] -} - -tasks.withType(JavaExec).configureEach { - jvmArgs += "--enable-preview" - jvmArgs += ["--add-modules", "jdk.incubator.concurrent"] -} +group 'io.optimism' +version '0.1.1' dependencies { // This dependency is used by the application. @@ -226,97 +180,11 @@ dependencies { testImplementation("com.squareup.okhttp3:mockwebserver:5.0.0-alpha.2") } -// Apply a specific Java toolchain to ease working on different environments. -java { - toolchain { - languageVersion = JavaLanguageVersion.of(20) - } -} - application { // Define the main class for the application. mainClass = 'io.optimism.Hildr' } -test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } - finalizedBy jacocoTestReport -} - -jacoco { - toolVersion = "0.8.9" -} - -jacocoTestReport { - dependsOn test - - reports { - csv.required = true - } -} - -jacocoTestCoverageVerification { - - violationRules { - rule { - limit { - minimum = 0 - } - } - } -} - -checkstyle { - toolVersion = '10.10.0' - // default checkstyle config -- specific to your team agreement - configFile = project(":").file("config/checkstyle/google_checks.xml") - // Google style (idiosyncratic to Google): - // configFile = project(":").file("config/checkstyle/google_checks.xml") - // SUN style (closest to modern Java styles) -- the basis for this project: - // configFile = project(":").file("config/checkstyle/sun_checks.xml") -// ignoreFailures = false -// maxWarnings = 0 -} - -spotless { - // optional: limit format enforcement to just the files changed by this feature branch -// ratchetFrom 'origin/main' - - format 'misc', { - // define the files to apply `misc` to - target '*.gradle', '*.md', '.gitignore' - - // define the steps to apply to those files - trimTrailingWhitespace() - indentWithTabs() // or spaces. Takes an integer argument if you don't like 4 - endWithNewline() - } - java { - // Use the default importOrder configuration - - // don't need to set target, it is inferred from java - - // apply a specific flavor of google-java-format - googleJavaFormat('1.17.0') - // fix formatting of type annotations - formatAnnotations() - // make sure every file has the following copyright header. - // optionally, Spotless can set copyright years by digging - // through git history (see "license" section below) - licenseHeaderFile(project(":").file("config/spotless/java.license")).named('hildr').onlyIfContentMatches('/*\n' + - ' * Copyright 2023 281165273grape@gmail.com') - licenseHeaderFile(project(":").file("config/spotless/besu.license")).named('besu').onlyIfContentMatches('/*\n' + - ' * Copyright ConsenSys AG') - - importOrder() - - removeUnusedImports() - } -} - checkstyleMain .exclude('io/optimism/rpc/handler/TimeoutHandler.java') .exclude('io/optimism/rpc/handler/JsonRpcExecutorHandler.java') @@ -336,45 +204,6 @@ checkstyleMain .exclude('io/optimism/rpc/internal/response/JsonRpcNoResponse.java') .exclude('io/optimism/rpc/execution/BaseJsonRpcProcessor.java') .exclude('io/optimism/rpc/execution/JsonRpcProcessor.java') -//testSets { -// integrationTest -//} - -tasks.named('test') { - // Use JUnit Platform for unit tests. - useJUnitPlatform() -} - -check { - dependsOn += jacocoTestCoverageVerification -// dependsOn += integrationTest -} - -tasks.withType(Test).configureEach { - def outputDir = reports.junitXml.outputLocation - jvmArgumentProviders << ({ - [ - "-Djunit.platform.reporting.open.xml.enabled=true", - "-Djunit.platform.reporting.output.dir=${outputDir.get().asFile.absolutePath}", - "--enable-preview" - ] - } as CommandLineArgumentProvider) -} - -java { - withJavadocJar() - withSourcesJar() -} - - -javadoc { - if (JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html5', true) - } - options.addBooleanOption('-enable-preview', true) - options.addStringOption('-release', '20') - options.addStringOption('-add-modules', 'jdk.incubator.concurrent') -} jar { manifest {