diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index abb50662..6f81e7f2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,22 +1,19 @@
name: CI
-env:
- GRADLE_VERSION: 6.7.1
-
on: [push, pull_request]
jobs:
build:
name: Build MiniDNS
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-24.04
strategy:
matrix:
java:
- - 11
- - 15
+ - 17
+ - 21
env:
- PRIMARY_JAVA_VERSION: 11
+ PRIMARY_JAVA_VERSION: 21
steps:
- name: Checkout
@@ -57,11 +54,6 @@ jobs:
android-
# Pre-reqs
- - name: Grab gradle wrapper
- run: |
- wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
- unzip gradle-${GRADLE_VERSION}-all.zip
- echo "PATH_TO_GRADLE=./gradle-${GRADLE_VERSION}/bin/gradle" >> $GITHUB_ENV
- name: Install Android SDK Manager
uses: android-actions/setup-android@v2
- name: Install Android SDK
@@ -72,23 +64,28 @@ jobs:
# Testing
- name: Gradle Check
- run: ${PATH_TO_GRADLE} check --stacktrace
+ run: ./gradlew check --stacktrace
# Test local publish
- name: Gradle publish
- run: ${PATH_TO_GRADLE} publishToMavenLocal --stacktrace
+ run: ./gradlew publishToMavenLocal --stacktrace
# Javadoc
- name: Javadoc
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
- run: ${PATH_TO_GRADLE} javadocAll --stacktrace
+ run: ./gradlew javadocAll --stacktrace
# Test Coverage Report
- name: Jacoco Test Coverage
+ run: ./gradlew minidns-hla:testCodeCoverageReport
+
+ # Coveralls
+ - name: Report coverage stats to Coveralls
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
- run: ${PATH_TO_GRADLE} jacocoRootReport coveralls
- env:
- COVERALLS_REPO_TOKEN: S2ecSJja2cKJa9yv45C8ZFPohXuRrTXKd
+ uses: coverallsapp/github-action@v2
+ with:
+ format: jacoco
+ file: minidns-hla/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
# Upload build artifacts
- name: Upload build artifacts
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..61aac247
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+GRADLE ?= ./gradlew
+
+.PHONY: all
+all: check codecov eclipse javadocAll inttest
+
+.PHONY: codecov
+codecov:
+ $(GRADLE) minidns-hla:testCodeCoverageReport
+ echo "Code coverage report available at $(PWD)/minidns-hla/build/reports/jacoco/testCodeCoverageReport/html/index.html"
+
+.PHONY: check
+check:
+ $(GRADLE) $@
+
+.PHONY: eclipse
+eclipse:
+ $(GRADLE) $@
+
+.PHONY: inttest
+inttest:
+ $(GRADLE) $@
+
+.PHONY: javadocAll
+javadocAll:
+ $(GRADLE) $@
+ echo "javadoc available at $(PWD)/build/javadoc/index.html"
diff --git a/build-logic/build.gradle b/build-logic/build.gradle
new file mode 100644
index 00000000..7b02d03a
--- /dev/null
+++ b/build-logic/build.gradle
@@ -0,0 +1,14 @@
+plugins {
+ id 'groovy-gradle-plugin'
+}
+
+repositories {
+ gradlePluginPortal()
+}
+
+dependencies {
+ implementation "biz.aQute.bnd:biz.aQute.bnd.gradle:7.0.0"
+ implementation "me.champeau.jmh:jmh-gradle-plugin:0.7.2"
+ implementation "net.ltgt.gradle:gradle-errorprone-plugin:4.0.1"
+ implementation "ru.vyarus:gradle-animalsniffer-plugin:1.7.1"
+}
diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle
new file mode 100644
index 00000000..e82a44d6
--- /dev/null
+++ b/build-logic/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'minidns-build-logic'
diff --git a/build-logic/src/main/groovy/org.minidns.android-boot-classpath-conventions.gradle b/build-logic/src/main/groovy/org.minidns.android-boot-classpath-conventions.gradle
new file mode 100644
index 00000000..c14cb319
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.android-boot-classpath-conventions.gradle
@@ -0,0 +1,6 @@
+compileJava {
+ options.bootstrapClasspath = files(androidBootClasspath)
+}
+javadoc {
+ classpath += files(androidBootClasspath)
+}
diff --git a/build-logic/src/main/groovy/org.minidns.android-conventions.gradle b/build-logic/src/main/groovy/org.minidns.android-conventions.gradle
new file mode 100644
index 00000000..019c943c
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.android-conventions.gradle
@@ -0,0 +1,10 @@
+plugins {
+ id 'ru.vyarus.animalsniffer'
+ id 'org.minidns.common-conventions'
+}
+dependencies {
+ signature "net.sf.androidscents.signature:android-api-level-${minAndroidSdk}:4.4.2_r4@signature"
+}
+animalsniffer {
+ sourceSets = [sourceSets.main]
+}
diff --git a/build-logic/src/main/groovy/org.minidns.application-conventions.gradle b/build-logic/src/main/groovy/org.minidns.application-conventions.gradle
new file mode 100644
index 00000000..fa4c7011
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.application-conventions.gradle
@@ -0,0 +1,12 @@
+plugins {
+ id 'application'
+}
+
+application {
+ applicationDefaultJvmArgs = ["-enableassertions"]
+}
+
+run {
+ // Pass all system properties down to the "application" run
+ systemProperties System.getProperties()
+}
diff --git a/build-logic/src/main/groovy/org.minidns.common-conventions.gradle b/build-logic/src/main/groovy/org.minidns.common-conventions.gradle
new file mode 100644
index 00000000..6e63cff3
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.common-conventions.gradle
@@ -0,0 +1,36 @@
+ext {
+ javaVersion = JavaVersion.VERSION_11
+ javaMajor = javaVersion.getMajorVersion()
+ minAndroidSdk = 19
+
+ androidBootClasspath = getAndroidRuntimeJar(minAndroidSdk)
+
+ // Export the function by turning it into a closure.
+ // https://stackoverflow.com/a/23290820/194894
+ getAndroidRuntimeJar = this.&getAndroidRuntimeJar
+}
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+}
+
+def getAndroidRuntimeJar(androidApiLevel) {
+ def androidHome = getAndroidHome()
+ def androidJar = new File("$androidHome/platforms/android-${androidApiLevel}/android.jar")
+ if (androidJar.isFile()) {
+ return androidJar
+ } else {
+ throw new Exception("Can't find android.jar for API level ${androidApiLevel}. Please install corresponding SDK platform package")
+ }
+}
+
+def getAndroidHome() {
+ def androidHomeEnv = System.getenv("ANDROID_HOME")
+ if (androidHomeEnv == null) {
+ throw new Exception("ANDROID_HOME environment variable is not set")
+ }
+ def androidHome = new File(androidHomeEnv)
+ if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
+ return androidHome
+}
diff --git a/build-logic/src/main/groovy/org.minidns.java-conventions.gradle b/build-logic/src/main/groovy/org.minidns.java-conventions.gradle
new file mode 100644
index 00000000..1eec20ac
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.java-conventions.gradle
@@ -0,0 +1,330 @@
+plugins {
+ id 'biz.aQute.bnd.builder'
+ id 'checkstyle'
+ id 'eclipse'
+ id 'idea'
+ id 'jacoco'
+ id 'java'
+ id 'java-library'
+ id 'java-test-fixtures'
+ id 'maven-publish'
+ id 'net.ltgt.errorprone'
+ id 'signing'
+
+ id 'jacoco-report-aggregation'
+ id 'test-report-aggregation'
+
+ id 'org.minidns.common-conventions'
+ id 'org.minidns.javadoc-conventions'
+}
+
+version readVersionFile()
+
+// TODO: verify settings done here
+ext {
+ isSnapshot = version.endsWith('-SNAPSHOT')
+ gitCommit = getGitCommit()
+ rootConfigDir = new File(rootDir, 'config')
+ sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
+ isReleaseVersion = !isSnapshot
+ isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
+ signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
+ sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
+ sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
+ builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
+ oneLineDesc = 'An Open Source XMPP (Jabber) client library'
+
+ junitVersion = '5.9.2'
+ commonsIoVersion = '2.6'
+ bouncyCastleVersion = '1.73'
+ guavaVersion = '30.1-jre'
+ mockitoVersion = '5.13.0'
+ orgReflectionsVersion = '0.9.11'
+
+ if (project.hasProperty("useSonatype")) {
+ useSonatype = project.getProperty("useSonatype").toBoolean()
+ } else {
+ // Default to true
+ useSonatype = true
+ }
+
+ gplLicensedProjects = [
+ ].collect{ project(it) }
+}
+
+group = 'org.igniterealtime.smack'
+
+java {
+ sourceCompatibility = javaVersion
+ targetCompatibility = sourceCompatibility
+}
+
+eclipse {
+ classpath {
+ downloadJavadoc = true
+ }
+}
+
+// Make all project's 'test' target depend on javadoc, so that
+// javadoc is also linted.
+test.dependsOn javadoc
+
+tasks.withType(JavaCompile) {
+ // Some systems may not have set their platform default
+ // converter to 'utf8', but we use unicode in our source
+ // files. Therefore ensure that javac uses unicode
+ options.encoding = "utf8"
+ options.compilerArgs = [
+ '-Xlint:all',
+ // Set '-options' because a non-java7 javac will emit a
+ // warning if source/target is set to 1.7 and
+ // bootclasspath is *not* set.
+ '-Xlint:-options',
+ // TODO: Enable xlint serial
+ '-Xlint:-serial',
+ '-Werror',
+ ]
+ options.release = Integer.valueOf(javaMajor)
+}
+
+jacoco {
+ toolVersion = "0.8.12"
+}
+
+jacocoTestReport {
+ dependsOn test
+ reports {
+ xml.required = true
+ }
+}
+
+dependencies {
+ testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
+ testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
+
+ testFixturesApi "org.junit.jupiter:junit-jupiter-api:$junitVersion"
+ testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
+ testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
+ // https://stackoverflow.com/a/77274251/194894
+ testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.11.0"
+
+ // The smack-extensions subproject uses mockito in its fest
+ // fixtures, and we want to have mockito also available in
+ // test, so we use API here.
+ testFixturesApi "org.mockito:mockito-core:${mockitoVersion}"
+
+ testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
+
+ errorprone 'com.google.errorprone:error_prone_core:2.32.0'
+}
+
+test {
+ useJUnitPlatform()
+
+ maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
+
+ // Enable full stacktraces of failed tests. Especially handy
+ // for CI environments.
+ testLogging {
+ events "failed"
+ exceptionFormat "full"
+ }
+}
+
+jar {
+ manifest {
+ attributes(
+ 'Implementation-Version': version,
+ 'Implementation-GitRevision': gitCommit,
+ 'Built-JDK': System.getProperty('java.version'),
+ 'Built-Gradle': gradle.gradleVersion,
+ 'Built-By': System.getProperty('user.name')
+ )
+ }
+
+ bundle {
+ bnd(
+ '-removeheaders': 'Tool, Bnd-*',
+ '-exportcontents': '*',
+ )
+ }
+}
+
+checkstyle {
+ toolVersion = '8.27'
+
+ if (project in gplLicensedProjects) {
+ configProperties.checkstyleLicenseHeader = "${project.name}-gplv3-license-header"
+ } else {
+ configProperties.checkstyleLicenseHeader = "header"
+ }
+}
+task sourcesJar(type: Jar, dependsOn: classes) {
+ archiveClassifier = 'sources'
+ from sourceSets.main.allSource
+}
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ archiveClassifier = 'javadoc'
+ from javadoc.destinationDir
+}
+task testsJar(type: Jar) {
+ archiveClassifier = 'tests'
+ from sourceSets.test.output
+}
+configurations {
+ testRuntime
+}
+artifacts {
+ // Add a 'testRuntime' configuration including the tests so that
+ // it can be consumed by other projects (smack-omemo-signal for
+ // example). See http://stackoverflow.com/a/21946676/194894
+ testRuntime testsJar
+}
+
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ from components.java
+ artifact sourcesJar
+ artifact javadocJar
+ artifact testsJar
+ pom {
+ name = 'Smack'
+ packaging = 'jar'
+ inceptionYear = '2003'
+ url = 'http://www.igniterealtime.org/projects/jxmpp/'
+ afterEvaluate {
+ description = project.description
+ }
+
+ issueManagement {
+ system = 'JIRA'
+ url = 'http://issues.igniterealtime.org/browse/SMACK'
+ }
+
+ scm {
+ url = 'https://github.com/igniterealtime/Smack'
+ connection = 'scm:git:https://github.com/igniterealtime/Smack.git'
+ developerConnection = 'scm:git:https://github.com/igniterealtime/Smack.git'
+ }
+
+ licenses {
+ if (project in gplLicensedProjects) {
+ license {
+ name = 'GNU General Public License, version 3 or any later version'
+ url = 'https://www.gnu.org/licenses/gpl.txt'
+ distribution = 'repo'
+ }
+ } else {
+ license {
+ name = 'The Apache Software License, Version 2.0'
+ url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution = 'repo'
+ }
+ }
+ }
+
+ developers {
+ developer {
+ id = 'flow'
+ name = 'Florian Schmaus'
+ email = 'flow@igniterealtime.org'
+ }
+ }
+ }
+ }
+ }
+ repositories {
+ if (sonatypeCredentialsAvailable && useSonatype) {
+ maven {
+ url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
+ credentials {
+ username = sonatypeUsername
+ password = sonatypePassword
+ }
+ }
+ }
+ // Use
+ // gradle publish -P customRepoUrl=https://www.igniterealtime.org/archiva/repository/maven -P customRepoUsername=bamboo -P customRepoPassword=hidden -P useSonatype=false
+ // to deploy to this repo.
+ if (project.hasProperty("customRepoUrl")) {
+ maven {
+ name 'customRepo'
+ url customRepoUrl
+ if (project.hasProperty("customRepoUsername")) {
+ credentials {
+ username customRepoUsername
+ password customRepoPassword
+ }
+ }
+ }
+ }
+ }
+}
+
+// Workaround for gpg signatory not supporting the 'required' option
+// See https://github.com/gradle/gradle/issues/5064#issuecomment-381924984
+// Note what we use 'signing.gnupg.keyName' instead of 'signing.keyId'.
+tasks.withType(Sign) {
+ onlyIf {
+ project.hasProperty('signing.gnupg.keyName')
+ }
+}
+signing {
+ required { signingRequired }
+ useGpgCmd()
+ sign publishing.publications.mavenJava
+}
+
+tasks.withType(JavaCompile) {
+ options.errorprone {
+ disableWarningsInGeneratedCode = true
+ excludedPaths = ".*/jmh_generated/.*"
+ error(
+ "UnusedVariable",
+ "UnusedMethod",
+ "MethodCanBeStatic",
+ )
+ errorproneArgs = [
+ // Disable MissingCasesInEnumSwitch error prone check
+ // because this check is already done by javac as incomplete-switch.
+ '-Xep:MissingCasesInEnumSwitch:OFF',
+ '-Xep:StringSplitter:OFF',
+ '-Xep:JavaTimeDefaultTimeZone:OFF',
+ '-Xep:InlineMeSuggester:OFF',
+ ]
+ }
+}
+
+// Work around https://github.com/gradle/gradle/issues/4046
+task copyJavadocDocFiles(type: Copy) {
+ from('src/javadoc')
+ into 'build/docs/javadoc'
+ include '**/doc-files/*.*'
+}
+javadoc.dependsOn copyJavadocDocFiles
+
+def getGitCommit() {
+ def projectDirFile = new File("$projectDir")
+
+ def cmd = 'git describe --always --tags --dirty=+'
+ def proc = cmd.execute(null, projectDirFile)
+
+ def exitStatus = proc.waitFor()
+ if (exitStatus != 0) return "non-git build"
+
+ def gitCommit = proc.text.trim()
+ assert !gitCommit.isEmpty()
+ gitCommit
+}
+
+def readVersionFile() {
+ def versionFile = new File(rootDir, 'version')
+ if (!versionFile.isFile()) {
+ throw new Exception("Could not find version file")
+ }
+ if (versionFile.text.isEmpty()) {
+ throw new Exception("Version file does not contain a version")
+ }
+ versionFile.text.trim()
+}
diff --git a/build-logic/src/main/groovy/org.minidns.javadoc-conventions.gradle b/build-logic/src/main/groovy/org.minidns.javadoc-conventions.gradle
new file mode 100644
index 00000000..49b0e8f6
--- /dev/null
+++ b/build-logic/src/main/groovy/org.minidns.javadoc-conventions.gradle
@@ -0,0 +1,24 @@
+plugins {
+ // Javadoc linking requires repositories to bet configured. And
+ // those are declared in common-conventions, hence we add it here.
+ id 'org.minidns.common-conventions'
+}
+
+
+tasks.withType(Javadoc) {
+ // The '-quiet' as second argument is actually a hack,
+ // since the one parameter addStringOption doesn't seem to
+ // work, we extra add '-quiet', which is added anyway by
+ // gradle.
+ // We disable 'missing' as we do most of javadoc checking via checkstyle.
+ options.addStringOption('Xdoclint:all,-missing', '-quiet')
+ // Abort on javadoc warnings.
+ // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
+ // for information about the -Xwerror option.
+ options.addStringOption('Xwerror', '-quiet')
+ options.addStringOption('-release', javaMajor)
+}
+
+tasks.withType(Javadoc) {
+ options.charSet = "UTF-8"
+}
diff --git a/build.gradle b/build.gradle
index 4ed1d3e6..9eb644a4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,406 +1,65 @@
-buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- jcenter()
- mavenLocal()
- mavenCentral()
- }
-
- dependencies {
- classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1"
- classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.1.0"
- }
-}
-
plugins {
- id 'ru.vyarus.animalsniffer' version '1.5.1'
- id 'net.ltgt.errorprone' version '0.8.1'
-}
-
-allprojects {
- apply plugin: 'java'
- apply plugin: 'eclipse'
- apply plugin: 'checkstyle'
- apply plugin: 'jacoco'
- apply plugin: 'net.ltgt.errorprone'
-
- group = 'org.minidns'
- description = "A minimal DNS client library with support for A, AAAA, NS and SRV records"
- version readVersionFile()
-
- ext {
- isSnapshot = version.endsWith('-SNAPSHOT')
- minidnsMinAndroidSdk = 19
- junitVersion = '5.7.1'
- androidBootClasspath = getAndroidRuntimeJar(minidnsMinAndroidSdk)
- rootConfigDir = new File(rootDir, 'config')
- gitCommit = getGitCommit()
- isReleaseVersion = !isSnapshot
- isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
- signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
- sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
- sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
- sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
- javaCompatilibity = JavaVersion.VERSION_1_8
- javaMajor = javaCompatilibity.getMajorVersion()
- }
-
- sourceCompatibility = javaCompatilibity
-
- if (!ext.isSnapshot && !'git describe --exact-match HEAD'.execute().text.trim().equals(version)) {
- throw new org.gradle.api.InvalidUserDataException('Untagged version detected! Please tag every release.')
- }
- if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute().text.trim()) {
- throw new org.gradle.api.InvalidUserDataException(
- 'Tag mismatch detected, version is ' + version + ' but should be ' +
- 'git tag --points-at HEAD'.execute().text.trim())
- }
-
- test {
- useJUnitPlatform()
-
- maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
-
- // Enable full stacktraces of failed tests. Especially handy
- // for environments like Travis.
- testLogging {
- events "failed"
- exceptionFormat "full"
- }
- }
-
- repositories {
- mavenLocal()
- mavenCentral()
- }
-
- tasks.withType(JavaCompile) {
- // Some systems may not have set their platform default
- // converter to 'utf8', but we use unicode in our source
- // files. Therefore ensure that javac uses unicode
- options.encoding = "utf8"
- options.compilerArgs = [
- '-Xlint:all',
- // Set '-options' because a non-java7 javac will emit a
- // warning if source/traget is set to 1.7 and
- // bootclasspath is *not* set.
- // TODO implement a sound heuristic to determine a java7
- // rt.jar on the build host. And if none is found,
- // fallback to using a environment variable,
- // e.g. JAVA7_HOME. See SMACK-651.
- '-Xlint:-options',
- '-Werror',
- ]
- options.errorprone {
- error(
- "UnusedVariable",
- "UnusedMethod",
- "MethodCanBeStatic",
- )
- errorproneArgs = [
- // Disable errorprone checks
- '-Xep:TypeParameterUnusedInFormals:OFF',
- // Disable errorpone StringSplitter check, as it
- // recommends using Splitter from Guava, which we don't
- // have (nor want to use in Smack).
- '-Xep:StringSplitter:OFF',
- '-Xep:JdkObsolete:OFF',
- '-Xep:MixedMutabilityReturnType:OFF',
- '-Xep:ImmutableEnumChecker:OFF',
- ]
- }
-
- }
-
- checkstyle {
- toolVersion = '8.24'
- }
-
- jacoco {
- toolVersion = "0.8.6"
- }
-
- jacocoTestReport {
- dependsOn test
- getSourceDirectories().setFrom(project.files(sourceSets.main.allSource.srcDirs))
- getClassDirectories().setFrom(project.files(sourceSets.main.output))
- reports {
- xml.enabled true
- }
- }
-
- eclipse {
- classpath {
- downloadJavadoc = true
- }
- }
-
- // Make all project's 'test' targets depend on javadoc, so that
- // javadoc is also linted.
- test.dependsOn javadoc
-
- if (JavaVersion.current().isJava8Compatible()) {
- tasks.withType(Javadoc) {
- // The '-quiet' as second argument is actually a hack,
- // since the one paramater addStringOption doesn't seem to
- // work, we extra add '-quiet', which is added anyway by
- // gradle.
- // See https://github.com/gradle/gradle/issues/2354
- options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet')
- // Abort on javadoc warnings.
- // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
- // for information about the -Xwerror option.
- options.addStringOption('Xwerror', '-quiet')
- }
- }
-
- if (JavaVersion.current().isJava9Compatible()) {
- tasks.withType(Javadoc) {
- options.addStringOption('-release', javaMajor)
- }
- tasks.withType(JavaCompile) {
- options.compilerArgs.addAll([
- '--release', javaMajor,
- ])
- }
- }
-
- dependencies {
- testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
- testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
- testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
-
- errorprone 'com.google.errorprone:error_prone_core:2.3.3'
- errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
- }
+ // The scalastyle plugin of smack-repl wants the root project to
+ // have a ideaProject task, so let's add one.
+ id 'idea'
+ id 'org.minidns.javadoc-conventions'
}
-subprojects {
- apply plugin: 'maven-publish'
- apply plugin: 'signing'
- apply plugin: "biz.aQute.bnd.builder"
+ext {
+ javadocAllDir = new File(buildDir, 'javadoc')
+ nonJavadocAllProjects = [
+ ':minidns-integration-test',
+ ':minidns-repl',
+ ].collect{ project(it) }
+ javadocAllProjects = subprojects - nonJavadocAllProjects
+}
- jar {
- bundle {
- bnd(
- '-removeheaders': 'Tool, Bnd-*',
- '-exportcontents': 'org.minidns.*',
- 'Import-Package': '!android,*'
- )
+evaluationDependsOnChildren()
+task javadocAll(type: Javadoc) {
+ source javadocAllProjects.collect {project ->
+ project.sourceSets.main.allJava.findAll {
+ // Filter out symbolic links to avoid
+ // "warning: a package-info.java file has already been seen for package"
+ // javadoc warnings.
+ !java.nio.file.Files.isSymbolicLink(it.toPath())
}
}
-
- task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
- }
- task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
- }
- task testsJar(type: Jar, dependsOn: testClasses) {
- classifier = 'tests'
- from sourceSets.test.output
- }
-
- artifacts {
- archives sourcesJar
- archives javadocJar
- archives testsJar
- // See http://stackoverflow.com/a/21946676/194894
- testRuntime testsJar
- }
-
- publishing {
- publications {
- mavenJava(MavenPublication) {
- from components.java
- artifact sourcesJar
- artifact javadocJar
- artifact testsJar
- pom {
- name = 'minidns'
- description = 'A DNS library for Java and Android systems'
- url = 'https://github.com/minidns/minidns'
- inceptionYear = '2014'
-
- scm {
- url = 'https://github.com/minidns/minidns'
- connection = 'scm:https://github.com/minidns/minidns'
- developerConnection = 'scm:git://github.com/minidns/minidns.git'
- }
-
- licenses {
- license {
- name = 'The Apache Software License, Version 2.0'
- url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution = 'repo'
- }
- }
-
- developers {
- developer {
- id = 'rtreffer'
- name = 'Rene Treffer'
- email = 'treffer@measite.de'
- }
- developer {
- id = 'flow'
- name = 'Florian Schmaus'
- email = 'flow@geekplace.eu'
- }
- }
- }
- }
- }
- repositories {
- maven {
- url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
- if (sonatypeCredentialsAvailable) {
- credentials {
- username = sonatypeUsername
- password = sonatypePassword
- }
+ destinationDir = javadocAllDir
+ // Might need a classpath
+ classpath = files(subprojects.collect {project ->
+ project.sourceSets.main.compileClasspath})
+ classpath += files(androidBootClasspath)
+ options {
+ linkSource = true
+ use = true
+ links = [
+ "https://docs.oracle.com/en/java/javase/${javaMajor}/docs/api/",
+ ] as String[]
+ overview = "$projectDir/resources/javadoc-overview.html"
+ }
+
+ // Finally copy the javadoc doc-files from the subprojects, which
+ // are potentially generated, to the javadocAll directory. Note
+ // that we use a copy *method* and not a *task* because the inputs
+ // of copy tasks is determined within the configuration phase. And
+ // since some of the inputs are generated, they will not get
+ // picked up if we used a copy method. See also
+ // https://stackoverflow.com/a/40518516/194894
+ doLast {
+ copy {
+ javadocAllProjects.each {
+ from ("${it.projectDir}/src/javadoc") {
+ include '**/doc-files/*.*'
}
}
- }
- }
- // Workaround for gpg signatory not supporting the 'required' option
- // See https://github.com/gradle/gradle/issues/5064#issuecomment-381924984
- // Note what we use 'signing.gnupg.keyName' instead of 'signing.keyId'.
- tasks.withType(Sign) {
- onlyIf {
- project.hasProperty('signing.gnupg.keyName')
+ into javadocAllDir
}
}
- signing {
- required { signingRequired }
- useGpgCmd()
- sign publishing.publications.mavenJava
- }
-}
-
-configure(subprojects.findAll{!it.name.endsWith('-java7') && !it.name.endsWith('-android21')}) {
- apply plugin: 'ru.vyarus.animalsniffer'
- dependencies {
- signature "net.sf.androidscents.signature:android-api-level-${minidnsMinAndroidSdk}:4.4.2_r4@signature"
- }
- animalsniffer {
- sourceSets = [sourceSets.main]
- }
-}
-
-jar {
- // Root project should not create empty jar artifact
- enabled = false
-}
-
-apply plugin: "com.github.kt3k.coveralls"
-coveralls {
- sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
-}
-
-task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
- dependsOn = subprojects.jacocoTestReport
- getSourceDirectories().setFrom(files(subprojects.sourceSets.main.allSource.srcDirs))
- getClassDirectories().setFrom(files(subprojects.sourceSets.main.output))
- getExecutionData().setFrom(files(subprojects.jacocoTestReport.executionData))
- reports {
- xml.enabled true
- xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
- }
- // We could remove the following setOnlyIf line, but then
- // jacocoRootReport would silently be SKIPPED if something with
- // the subprojects is wrong (e.g. a project is missing
- // in there).
- setOnlyIf { true }
}
-task integrationTest {
- // Depend on the integration test's 'run' task using a closure, as
- // usually the subprojects are evaluated after the parent
- // project. The closure defers the lookup, compared to
- // dependsOn project(':minidns-integration-test').tasks.run
- // which won't work. See also: https://discuss.gradle.org/t/4387/2
- dependsOn { project(':minidns-integration-test').tasks.run }
-}
-
-task checkFull {
- dependsOn = subprojects.tasks.check
- dependsOn {
- integrationTest
- }
-}
-
-def getAndroidRuntimeJar(androidSdkApiLevel) {
- def androidHome = getAndroidHome()
- def androidJar = new File("$androidHome/platforms/android-$androidSdkApiLevel/android.jar")
- if (androidJar.isFile()) {
- return androidJar
- } else {
- throw new Exception("Can't find android.jar for $androidSdkApiLevel API. Please install corresponding SDK platform package")
- }
-}
-
-def getAndroidHome() {
- def androidHomeEnv = System.getenv("ANDROID_HOME")
- if (androidHomeEnv == null) {
- throw new Exception("ANDROID_HOME environment variable is not set")
- }
- def androidHome = new File(androidHomeEnv)
- if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
- return androidHome
-}
-
-def getGitCommit() {
- def dotGit = new File("$projectDir/.git")
- if (!dotGit.isDirectory()) return 'non-git build'
-
- def cmd = 'git describe --always --tags --dirty=+'
- def proc = cmd.execute()
- def gitCommit = proc.text.trim()
- assert !gitCommit.isEmpty()
-
- def srCmd = 'git symbolic-ref --short HEAD'
- def srProc = srCmd.execute()
- srProc.waitForOrKill(10 * 1000)
- if (srProc.exitValue() == 0) {
- // Only add the information if the git command was
- // successful. There may be no symbolic reference for HEAD if
- // e.g. in detached mode.
- def symbolicReference = srProc.text.trim()
- assert !symbolicReference.isEmpty()
- gitCommit += "-$symbolicReference"
- }
-
- gitCommit
-}
-
-task javadocAll(type: Javadoc) {
- source subprojects.collect {project ->
- project.sourceSets.main.allJava }
- destinationDir = new File(buildDir, 'javadoc')
- // Might need a classpath
- classpath = files(subprojects.collect {project ->
- project.sourceSets.main.compileClasspath})
- options.linkSource = true
- options.use = true
- options.links = [
- "https://docs.oracle.com/javase/${javaMajor}/docs/api/",
- ] as String[]
-}
-
-def readVersionFile() {
- def versionFile = new File(rootDir, 'version')
- if (!versionFile.isFile()) {
- throw new Exception("Could not find version file")
- }
- if (versionFile.text.isEmpty()) {
- throw new Exception("Version file does not contain a version")
- }
- versionFile.text.trim()
+task inttest {
+ description 'Verify correct functionality by running some integration tests.'
+ dependsOn project(':minidns-integration-test').tasks.run
}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index c456026a..8f490b2a 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -85,7 +85,6 @@
-
diff --git a/config/scalaStyle.xml b/config/scalaStyle.xml
new file mode 100644
index 00000000..fd191485
--- /dev/null
+++ b/config/scalaStyle.xml
@@ -0,0 +1,144 @@
+
+ Scalastyle standard configuration
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..a4b76b95
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..df97d72b
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 00000000..f5feea6d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# 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
+#
+# https://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.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 00000000..9b42019c
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/minidns-android21/build.gradle b/minidns-android21/build.gradle
deleted file mode 100644
index 2513161a..00000000
--- a/minidns-android21/build.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-apply plugin: 'ru.vyarus.animalsniffer'
-
-ext {
- androidBootClasspath = getAndroidRuntimeJar(23)
-}
-
-dependencies {
- compile project(':minidns-client')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
-
- // Add the Android jar to the Eclipse .classpath.
- compile files(androidBootClasspath)
-
- // For AnimalSniffer
- signature "net.sf.androidscents.signature:android-api-level-23:6.0_r3@signature"
-}
-
-animalsniffer {
- sourceSets = [sourceSets.main]
-}
diff --git a/minidns-android23/build.gradle b/minidns-android23/build.gradle
new file mode 100644
index 00000000..9ff6e4bb
--- /dev/null
+++ b/minidns-android23/build.gradle
@@ -0,0 +1,20 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
+ext {
+ myAndroidSdkApi = 23
+ androidBootClasspath = getAndroidRuntimeJar(myAndroidSdkApi)
+}
+
+dependencies {
+ api project(':minidns-client')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
+
+ // Add the Android jar to the Eclipse .classpath.
+ implementation files(androidBootClasspath)
+
+ // For AnimalSniffer
+ signature "net.sf.androidscents.signature:android-api-level-${myAndroidSdkApi}:6.0_r3@signature"
+}
diff --git a/minidns-android21/src/main/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkProperties.java b/minidns-android23/src/main/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkProperties.java
similarity index 100%
rename from minidns-android21/src/main/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkProperties.java
rename to minidns-android23/src/main/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkProperties.java
diff --git a/minidns-android21/src/test/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkPropertiesTest.java b/minidns-android23/src/test/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkPropertiesTest.java
similarity index 100%
rename from minidns-android21/src/test/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkPropertiesTest.java
rename to minidns-android23/src/test/java/org/minidns/dnsserverlookup/android21/AndroidUsingLinkPropertiesTest.java
diff --git a/minidns-async/build.gradle b/minidns-async/build.gradle
index a74061ed..9992b827 100644
--- a/minidns-async/build.gradle
+++ b/minidns-async/build.gradle
@@ -1,4 +1,9 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
dependencies {
- compile project(':minidns-client')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
+ api project(':minidns-client')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
}
diff --git a/minidns-async/src/main/java/org/minidns/source/async/AsyncDnsRequest.java b/minidns-async/src/main/java/org/minidns/source/async/AsyncDnsRequest.java
index b4e2e205..e276646c 100644
--- a/minidns-async/src/main/java/org/minidns/source/async/AsyncDnsRequest.java
+++ b/minidns-async/src/main/java/org/minidns/source/async/AsyncDnsRequest.java
@@ -110,7 +110,7 @@ public boolean cancel(boolean mayInterruptIfRunning) {
private void ensureWriteBufferIsInitialized() {
if (writeBuffer != null) {
if (!writeBuffer.hasRemaining()) {
- writeBuffer.rewind();
+ ((java.nio.Buffer) writeBuffer).rewind();
}
return;
}
@@ -411,7 +411,7 @@ public void handleChannelSelectedAndNotCancelled(SelectableChannel channel, Sele
int messageLength = writeBuffer.capacity();
assert messageLength <= Short.MAX_VALUE;
messageLengthByteBuffer.putShort((short) (messageLength & 0xffff));
- messageLengthByteBuffer.rewind();
+ ((java.nio.Buffer) messageLengthByteBuffer).rewind();
writeBuffers = new ByteBuffer[2];
writeBuffers[0] = messageLengthByteBuffer;
@@ -489,7 +489,7 @@ public void handleChannelSelectedAndNotCancelled(SelectableChannel channel, Sele
return;
}
- messageLengthByteBuffer.rewind();
+ ((java.nio.Buffer) messageLengthByteBuffer).rewind();
short messageLengthSignedShort = messageLengthByteBuffer.getShort();
int messageLength = messageLengthSignedShort & 0xffff;
byteBuffer = ByteBuffer.allocate(messageLength);
diff --git a/minidns-async/src/main/java/org/minidns/source/async/AsyncNetworkDataSource.java b/minidns-async/src/main/java/org/minidns/source/async/AsyncNetworkDataSource.java
index c7f7f3a9..f2beaa23 100644
--- a/minidns-async/src/main/java/org/minidns/source/async/AsyncNetworkDataSource.java
+++ b/minidns-async/src/main/java/org/minidns/source/async/AsyncNetworkDataSource.java
@@ -159,7 +159,7 @@ private static void handleSelectedKeys(Collection selectedKeys) {
}
}
- @SuppressWarnings("LockNotBeforeTry")
+ @SuppressWarnings({"LockNotBeforeTry", "MixedMutabilityReturnType"})
private static Collection performSelect() {
AsyncDnsRequest nearestDeadline = null;
AsyncDnsRequest nextInQueue;
diff --git a/minidns-client/build.gradle b/minidns-client/build.gradle
index 1584bd34..88cab4fb 100644
--- a/minidns-client/build.gradle
+++ b/minidns-client/build.gradle
@@ -1,6 +1,11 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
dependencies {
- compile project(':minidns-core')
- testCompile project(path: ":minidns-core", configuration: "testRuntime")
+ api project(':minidns-core')
+ testImplementation project(path: ":minidns-core", configuration: "testRuntime")
}
jar {
diff --git a/minidns-client/src/main/java/org/minidns/cache/ExtendedLruCache.java b/minidns-client/src/main/java/org/minidns/cache/ExtendedLruCache.java
index 6205387a..b977e92f 100644
--- a/minidns-client/src/main/java/org/minidns/cache/ExtendedLruCache.java
+++ b/minidns-client/src/main/java/org/minidns/cache/ExtendedLruCache.java
@@ -10,8 +10,8 @@
*/
package org.minidns.cache;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -92,7 +92,7 @@ private void gather(Map>> extraCaches, Dn
List> additionalRecords = extraCaches.get(additionalRecordQuestion);
if (additionalRecords == null) {
- additionalRecords = new LinkedList<>();
+ additionalRecords = new ArrayList<>();
extraCaches.put(additionalRecordQuestion, additionalRecords);
}
additionalRecords.add(extraRecord);
diff --git a/minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingExec.java b/minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingExec.java
index 70651cd8..98773ff4 100644
--- a/minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingExec.java
+++ b/minidns-client/src/main/java/org/minidns/dnsserverlookup/AndroidUsingExec.java
@@ -63,7 +63,7 @@ public boolean isAvailable() {
}
private static final String PROP_DELIM = "]: [";
- protected static Set parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException {
+ static Set parseProps(BufferedReader lnr, boolean logWarning) throws UnknownHostException, IOException {
String line = null;
Set server = new HashSet(6);
diff --git a/minidns-client/src/test/java/org/minidns/DnsWorld.java b/minidns-client/src/test/java/org/minidns/DnsWorld.java
index 15563014..412c2488 100644
--- a/minidns-client/src/test/java/org/minidns/DnsWorld.java
+++ b/minidns-client/src/test/java/org/minidns/DnsWorld.java
@@ -48,7 +48,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -256,7 +255,7 @@ public Zone(String zoneName, InetAddress address, List> r
}
public List getRRSets() {
- List rrSetBuilders = new LinkedList<>();
+ List rrSetBuilders = new ArrayList<>();
outerloop: for (Record extends Data> record : records) {
for (RrSet.Builder builder : rrSetBuilders) {
if (builder.addIfPossible(record)) {
diff --git a/minidns-core/build.gradle b/minidns-core/build.gradle
index 04cbaa5d..fa8e6f8a 100644
--- a/minidns-core/build.gradle
+++ b/minidns-core/build.gradle
@@ -1,3 +1,8 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
class CreateFileTask extends DefaultTask {
@Input
String fileContent
@@ -16,4 +21,4 @@ task createVersionResource(type: CreateFileTask) {
outputFile = new File(projectDir, 'src/main/resources/org.minidns/version')
}
-compileJava.dependsOn(createVersionResource)
+processResources.dependsOn(createVersionResource)
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/ALabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/ALabel.java
index 21dc6099..9b541fef 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/ALabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/ALabel.java
@@ -14,7 +14,7 @@
public final class ALabel extends XnLabel {
- protected ALabel(String label) {
+ ALabel(String label) {
super(label);
}
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/FakeALabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/FakeALabel.java
index d62aaeb0..bd4c791d 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/FakeALabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/FakeALabel.java
@@ -12,7 +12,7 @@
public final class FakeALabel extends XnLabel {
- protected FakeALabel(String label) {
+ FakeALabel(String label) {
super(label);
}
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/LeadingOrTrailingHyphenLabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/LeadingOrTrailingHyphenLabel.java
index 52554cf1..c48df9f5 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/LeadingOrTrailingHyphenLabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/LeadingOrTrailingHyphenLabel.java
@@ -15,11 +15,11 @@
*/
public final class LeadingOrTrailingHyphenLabel extends NonLdhLabel {
- protected LeadingOrTrailingHyphenLabel(String label) {
+ LeadingOrTrailingHyphenLabel(String label) {
super(label);
}
- protected static boolean isLeadingOrTrailingHypenLabelInternal(String label) {
+ static boolean isLeadingOrTrailingHypenLabelInternal(String label) {
if (label.isEmpty()) {
return false;
}
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/NonReservedLdhLabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/NonReservedLdhLabel.java
index de67d357..329ce6e8 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/NonReservedLdhLabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/NonReservedLdhLabel.java
@@ -16,7 +16,7 @@
*/
public final class NonReservedLdhLabel extends LdhLabel {
- protected NonReservedLdhLabel(String label) {
+ NonReservedLdhLabel(String label) {
super(label);
assert isNonReservedLdhLabelInternal(label);
}
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/OtherNonLdhLabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/OtherNonLdhLabel.java
index fb9e3fec..13bbd2c4 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/OtherNonLdhLabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/OtherNonLdhLabel.java
@@ -16,7 +16,7 @@
*/
public final class OtherNonLdhLabel extends NonLdhLabel {
- protected OtherNonLdhLabel(String label) {
+ OtherNonLdhLabel(String label) {
super(label);
}
diff --git a/minidns-core/src/main/java/org/minidns/dnslabel/UnderscoreLabel.java b/minidns-core/src/main/java/org/minidns/dnslabel/UnderscoreLabel.java
index 2b44e638..e75ff8f9 100644
--- a/minidns-core/src/main/java/org/minidns/dnslabel/UnderscoreLabel.java
+++ b/minidns-core/src/main/java/org/minidns/dnslabel/UnderscoreLabel.java
@@ -16,11 +16,11 @@
*/
public final class UnderscoreLabel extends NonLdhLabel {
- protected UnderscoreLabel(String label) {
+ UnderscoreLabel(String label) {
super(label);
}
- protected static boolean isUnderscoreLabelInternal(String label) {
+ static boolean isUnderscoreLabelInternal(String label) {
return label.charAt(0) == '_';
}
}
diff --git a/minidns-core/src/main/java/org/minidns/dnsmessage/DnsMessage.java b/minidns-core/src/main/java/org/minidns/dnsmessage/DnsMessage.java
index da06b14d..d584eab0 100644
--- a/minidns-core/src/main/java/org/minidns/dnsmessage/DnsMessage.java
+++ b/minidns-core/src/main/java/org/minidns/dnsmessage/DnsMessage.java
@@ -170,6 +170,7 @@ public enum OPCODE {
* Create a new opcode for a given byte value.
*
*/
+ @SuppressWarnings("EnumOrdinal")
OPCODE() {
this.value = (byte) this.ordinal();
}
@@ -675,7 +676,8 @@ public String toString() {
*
* @return This message as a String suitable for terminal output.
*/
- public String asTerminalOutput() {
+ @SuppressWarnings("JavaUtilDate")
+ public String asTerminalOutput() {
if (terminalOutputCache != null) return terminalOutputCache;
StringBuilder sb = new StringBuilder(";; ->>HEADER<<-")
@@ -1186,7 +1188,7 @@ public List> getAdditionalResourceRecords() {
}
/**
- * Get the @{link EDNS} builder. If no builder has been set so far, then a new one will be created.
+ * Get the {@link Edns} builder. If no builder has been set so far, then a new one will be created.
*
* The EDNS record can be used to announce the supported size of UDP payload as well as additional flags.
*
@@ -1194,7 +1196,7 @@ public List> getAdditionalResourceRecords() {
* Note that some networks and firewalls are known to block big UDP payloads. 1280 should be a reasonable value,
* everything below 512 is treated as 512 and should work on all networks.
*
- *
+ *
* @return a EDNS builder.
*/
public Edns.Builder getEdnsBuilder() {
diff --git a/minidns-core/src/main/java/org/minidns/dnsname/DnsName.java b/minidns-core/src/main/java/org/minidns/dnsname/DnsName.java
index 240bac8d..86036382 100644
--- a/minidns-core/src/main/java/org/minidns/dnsname/DnsName.java
+++ b/minidns-core/src/main/java/org/minidns/dnsname/DnsName.java
@@ -61,7 +61,7 @@ public final class DnsName extends SafeCharSequence implements Serializable, Com
private static final String LABEL_SEP_REGEX = "[.\u3002\uFF0E\uFF61]";
/**
- * @see RFC 1035 § 2.3.4.RFC 1035 § 2.3.4.
*/
static final int MAX_DNSNAME_LENGTH_IN_OCTETS = 255;
@@ -489,6 +489,7 @@ public static DnsName parse(DataInputStream dis, byte[] data)
* @return The parsed domain name.
* @throws IllegalStateException on cycles.
*/
+ @SuppressWarnings("NonApiType")
private static DnsName parse(byte[] data, int offset, HashSet jumps)
throws IllegalStateException {
int c = data[offset] & 0xff;
diff --git a/minidns-core/src/main/java/org/minidns/edns/Edns.java b/minidns-core/src/main/java/org/minidns/edns/Edns.java
index 339e94fa..e3306fcc 100644
--- a/minidns-core/src/main/java/org/minidns/edns/Edns.java
+++ b/minidns-core/src/main/java/org/minidns/edns/Edns.java
@@ -129,7 +129,7 @@ public Edns(Builder builder) {
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public O getEdnsOption(OptionCode optionCode) {
for (EdnsOption o : variablePart) {
if (o.getOptionCode().equals(optionCode)) {
diff --git a/minidns-core/src/main/java/org/minidns/record/DelegatingDnssecRR.java b/minidns-core/src/main/java/org/minidns/record/DelegatingDnssecRR.java
index e6184927..5d089ec4 100644
--- a/minidns-core/src/main/java/org/minidns/record/DelegatingDnssecRR.java
+++ b/minidns-core/src/main/java/org/minidns/record/DelegatingDnssecRR.java
@@ -15,6 +15,7 @@
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
+import java.util.Locale;
import org.minidns.constants.DnssecConstants.DigestAlgorithm;
import org.minidns.constants.DnssecConstants.SignatureAlgorithm;
@@ -74,10 +75,10 @@ protected static SharedData parseSharedData(DataInputStream dis, int length) thr
}
protected static final class SharedData {
- protected final int keyTag;
- protected final byte algorithm;
- protected final byte digestType;
- protected final byte[] digest;
+ final int keyTag;
+ final byte algorithm;
+ final byte digestType;
+ final byte[] digest;
private SharedData(int keyTag, byte algorithm, byte digestType, byte[] digest) {
this.keyTag = keyTag;
@@ -128,7 +129,7 @@ public String toString() {
.append(keyTag).append(' ')
.append(algorithm).append(' ')
.append(digestType).append(' ')
- .append(new BigInteger(1, digest).toString(16).toUpperCase());
+ .append(new BigInteger(1, digest).toString(16).toUpperCase(Locale.ROOT));
return sb.toString();
}
@@ -145,7 +146,7 @@ public BigInteger getDigestBigInteger() {
public String getDigestHex() {
if (digestHexCache == null) {
- digestHexCache = getDigestBigInteger().toString(16).toUpperCase();
+ digestHexCache = getDigestBigInteger().toString(16).toUpperCase(Locale.ROOT);
}
return digestHexCache;
}
diff --git a/minidns-core/src/main/java/org/minidns/record/NSEC3.java b/minidns-core/src/main/java/org/minidns/record/NSEC3.java
index a9cb1054..bcc99c71 100644
--- a/minidns-core/src/main/java/org/minidns/record/NSEC3.java
+++ b/minidns-core/src/main/java/org/minidns/record/NSEC3.java
@@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -166,7 +167,7 @@ public String toString() {
.append(hashAlgorithm).append(' ')
.append(flags).append(' ')
.append(iterations).append(' ')
- .append(salt.length == 0 ? "-" : new BigInteger(1, salt).toString(16).toUpperCase()).append(' ')
+ .append(salt.length == 0 ? "-" : new BigInteger(1, salt).toString(16).toUpperCase(Locale.ROOT)).append(' ')
.append(Base32.encodeToString(nextHashed));
for (TYPE type : types) {
sb.append(' ').append(type);
diff --git a/minidns-core/src/main/java/org/minidns/record/NSEC3PARAM.java b/minidns-core/src/main/java/org/minidns/record/NSEC3PARAM.java
index 5c99e072..62b4df3d 100644
--- a/minidns-core/src/main/java/org/minidns/record/NSEC3PARAM.java
+++ b/minidns-core/src/main/java/org/minidns/record/NSEC3PARAM.java
@@ -17,6 +17,7 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.math.BigInteger;
+import java.util.Locale;
/**
* NSEC3PARAM record payload.
@@ -91,7 +92,7 @@ public String toString() {
.append(hashAlgorithm).append(' ')
.append(flags).append(' ')
.append(iterations).append(' ')
- .append(salt.length == 0 ? "-" : new BigInteger(1, salt).toString(16).toUpperCase());
+ .append(salt.length == 0 ? "-" : new BigInteger(1, salt).toString(16).toUpperCase(Locale.ROOT));
return sb.toString();
}
diff --git a/minidns-core/src/main/java/org/minidns/record/RRSIG.java b/minidns-core/src/main/java/org/minidns/record/RRSIG.java
index bcae7e19..8c089d9f 100644
--- a/minidns-core/src/main/java/org/minidns/record/RRSIG.java
+++ b/minidns-core/src/main/java/org/minidns/record/RRSIG.java
@@ -78,6 +78,7 @@ public class RRSIG extends Data {
*/
private final byte[] signature;
+ @SuppressWarnings("JavaUtilDate")
public static RRSIG parse(DataInputStream dis, byte[] data, int length) throws IOException {
TYPE typeCovered = TYPE.getType(dis.readUnsignedShort());
byte algorithm = dis.readByte();
@@ -167,6 +168,7 @@ public void serialize(DataOutputStream dos) throws IOException {
dos.write(signature);
}
+ @SuppressWarnings("JavaUtilDate")
public void writePartialSignature(DataOutputStream dos) throws IOException {
dos.writeShort(typeCovered.getValue());
dos.writeByte(algorithmByte);
diff --git a/minidns-core/src/main/java/org/minidns/record/TLSA.java b/minidns-core/src/main/java/org/minidns/record/TLSA.java
index 5c6aff81..a1d58deb 100644
--- a/minidns-core/src/main/java/org/minidns/record/TLSA.java
+++ b/minidns-core/src/main/java/org/minidns/record/TLSA.java
@@ -184,6 +184,7 @@ public void serialize(DataOutputStream dos) throws IOException {
}
@Override
+ @SuppressWarnings("UnnecessaryStringBuilder")
public String toString() {
return new StringBuilder()
.append(certUsageByte).append(' ')
diff --git a/minidns-core/src/main/java/org/minidns/record/TXT.java b/minidns-core/src/main/java/org/minidns/record/TXT.java
index c52c3ff3..fe8c4f16 100644
--- a/minidns-core/src/main/java/org/minidns/record/TXT.java
+++ b/minidns-core/src/main/java/org/minidns/record/TXT.java
@@ -13,7 +13,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -69,11 +69,7 @@ public List getCharacterStrings() {
List extents = getExtents();
List characterStrings = new ArrayList<>(extents.size());
for (byte[] extent : extents) {
- try {
- characterStrings.add(new String(extent, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new AssertionError(e);
- }
+ characterStrings.add(new String(extent, StandardCharsets.UTF_8));
}
characterStringsCache = Collections.unmodifiableList(characterStrings);
diff --git a/minidns-core/src/main/java/org/minidns/util/SrvUtil.java b/minidns-core/src/main/java/org/minidns/util/SrvUtil.java
index a16a8f4f..77b4442d 100644
--- a/minidns-core/src/main/java/org/minidns/util/SrvUtil.java
+++ b/minidns-core/src/main/java/org/minidns/util/SrvUtil.java
@@ -34,6 +34,7 @@ public class SrvUtil {
* a collection of SRV records.
* @return a sorted list of the given records.
*/
+ @SuppressWarnings({"MixedMutabilityReturnType", "JdkObsolete"})
public static List sortSrvRecords(Collection srvRecords) {
// RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "."
// (the root domain), abort."
diff --git a/minidns-core/src/test/java/org/minidns/record/RecordsTest.java b/minidns-core/src/test/java/org/minidns/record/RecordsTest.java
index fbf9c202..ff433450 100644
--- a/minidns-core/src/test/java/org/minidns/record/RecordsTest.java
+++ b/minidns-core/src/test/java/org/minidns/record/RecordsTest.java
@@ -219,6 +219,7 @@ public void testPtrRecord() throws Exception {
}
@Test
+ @SuppressWarnings("JavaUtilDate")
public void testRrsigRecord() throws Exception {
RRSIG rrsig = new RRSIG(TYPE.A, (byte) 8, (byte) 2, 3600, new Date(1000), new Date(0), 42, "example.com", new byte[] {42});
// TODO: Compare with real Base64 once done
diff --git a/minidns-dane-java7/build.gradle b/minidns-dane-java7/build.gradle
index 23e3c593..40159ea6 100644
--- a/minidns-dane-java7/build.gradle
+++ b/minidns-dane-java7/build.gradle
@@ -1,5 +1,9 @@
+plugins {
+ id 'org.minidns.java-conventions'
+}
+
dependencies {
- compile project(':minidns-dnssec')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
- testCompile project(path: ":minidns-dnssec", configuration: "testRuntime")
+ api project(':minidns-dnssec')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
+ testImplementation project(path: ":minidns-dnssec", configuration: "testRuntime")
}
diff --git a/minidns-dnssec/build.gradle b/minidns-dnssec/build.gradle
index fa9c7b9e..cfd38211 100644
--- a/minidns-dnssec/build.gradle
+++ b/minidns-dnssec/build.gradle
@@ -1,5 +1,10 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
dependencies {
- compile project(':minidns-client')
- compile project(':minidns-iterative-resolver')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
+ api project(':minidns-client')
+ api project(':minidns-iterative-resolver')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
}
diff --git a/minidns-dnssec/src/main/java/org/minidns/dane/DaneVerifier.java b/minidns-dnssec/src/main/java/org/minidns/dane/DaneVerifier.java
index e13e7895..ed519db5 100644
--- a/minidns-dnssec/src/main/java/org/minidns/dane/DaneVerifier.java
+++ b/minidns-dnssec/src/main/java/org/minidns/dane/DaneVerifier.java
@@ -35,7 +35,6 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
@@ -117,7 +116,7 @@ public boolean verifyCertificateChain(X509Certificate[] chain, String hostName,
return false;
}
- List certificateMismatchExceptions = new LinkedList<>();
+ List certificateMismatchExceptions = new ArrayList<>();
boolean verified = false;
for (Record extends Data> record : res.answerSection) {
if (record.type == Record.TYPE.TLSA && record.name.equals(req)) {
diff --git a/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecClient.java b/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecClient.java
index 034d3891..aaa8e9a8 100644
--- a/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecClient.java
+++ b/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecClient.java
@@ -40,7 +40,6 @@
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -278,9 +277,10 @@ private static class VerifySignaturesResult {
Set reasons = new HashSet<>();
}
+ @SuppressWarnings("JavaUtilDate")
private VerifySignaturesResult verifySignatures(Question q, Collection> reference, List> toBeVerified) throws IOException {
final Date now = new Date();
- final List outdatedRrSigs = new LinkedList<>();
+ final List outdatedRrSigs = new ArrayList<>();
VerifySignaturesResult result = new VerifySignaturesResult();
final List> rrsigs = new ArrayList<>(toBeVerified.size());
diff --git a/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecValidationFailedException.java b/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecValidationFailedException.java
index 6fd71e9d..5cc230d1 100644
--- a/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecValidationFailedException.java
+++ b/minidns-dnssec/src/main/java/org/minidns/dnssec/DnssecValidationFailedException.java
@@ -20,6 +20,7 @@
import java.math.BigInteger;
import java.security.spec.InvalidKeySpecException;
import java.util.List;
+import java.util.Locale;
public class DnssecValidationFailedException extends IOException {
private static final long serialVersionUID = 5413184667629832742L;
@@ -142,7 +143,7 @@ public String getDigestHex() {
public static DigestComparisonFailedException from(Record extends Data> record, DelegatingDnssecRR ds, byte[] digest) {
BigInteger digestBigInteger = new BigInteger(1, digest);
- String digestHex = digestBigInteger.toString(16).toUpperCase();
+ String digestHex = digestBigInteger.toString(16).toUpperCase(Locale.ROOT);
String message = "Digest for " + record + " does not match. Digest of delegating DNSSEC RR " + ds + " is '"
+ ds.getDigestHex() + "' while we calculated '" + digestHex + "'";
diff --git a/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java b/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java
index 883a01c0..b3eddb04 100644
--- a/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java
+++ b/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecClientTest.java
@@ -385,7 +385,7 @@ public void testInvalidRRSIG() throws IOException, NoSuchFieldException, Securit
);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "JavaUtilDate"})
@Test
public void testUnknownAlgorithm() throws IOException {
DnssecClient client = constructDnssecClient();
@@ -474,7 +474,7 @@ public void testUnknownDelegationDigestType() throws IOException {
checkCorrectExampleMessage(message);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "JavaUtilDate"})
@Test
public void testSignatureOutOfDate() throws IOException {
DnssecClient client = constructDnssecClient();
@@ -506,7 +506,7 @@ public void testSignatureOutOfDate() throws IOException {
checkCorrectExampleMessage(message);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "JavaUtilDate"})
@Test
public void testSignatureInFuture() throws IOException {
DnssecClient client = constructDnssecClient();
diff --git a/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecWorld.java b/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecWorld.java
index d48e5248..382263a7 100644
--- a/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecWorld.java
+++ b/minidns-dnssec/src/test/java/org/minidns/dnssec/DnssecWorld.java
@@ -203,7 +203,7 @@ public static Record rrsigRecord(DNSKEY key, String signerName, PrivateKe
return rrsigRecord(key, DnsName.from(signerName), privateKey, algorithm, records);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "JavaUtilDate"})
public static Record rrsigRecord(DNSKEY key, DnsName signerName, PrivateKey privateKey, SignatureAlgorithm algorithm, Record extends Data>... records) {
Record.TYPE typeCovered = records[0].type;
int labels = records[0].name.getLabelCount();
diff --git a/minidns-hla/build.gradle b/minidns-hla/build.gradle
index 23e3c593..fbc41441 100644
--- a/minidns-hla/build.gradle
+++ b/minidns-hla/build.gradle
@@ -1,5 +1,10 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
dependencies {
- compile project(':minidns-dnssec')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
- testCompile project(path: ":minidns-dnssec", configuration: "testRuntime")
+ api project(':minidns-dnssec')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
+ testImplementation project(path: ":minidns-dnssec", configuration: "testRuntime")
}
diff --git a/minidns-hla/src/main/java/org/minidns/hla/SrvResolverResult.java b/minidns-hla/src/main/java/org/minidns/hla/SrvResolverResult.java
index 5e3785b0..54a87821 100644
--- a/minidns-hla/src/main/java/org/minidns/hla/SrvResolverResult.java
+++ b/minidns-hla/src/main/java/org/minidns/hla/SrvResolverResult.java
@@ -17,7 +17,6 @@
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.minidns.AbstractDnsClient.IpVersionSetting;
@@ -180,7 +179,7 @@ public static List sortMultiple(Collection
}
List srvToSort = new ArrayList<>(srvRecordsCount);
- Map identityMap = new IdentityHashMap<>(srvRecordsCount);
+ IdentityHashMap identityMap = new IdentityHashMap<>(srvRecordsCount);
for (Collection resolvedSrvRecords : resolvedSrvRecordCollections) {
if (resolvedSrvRecords == null) {
continue;
diff --git a/minidns-hla/src/main/java/org/minidns/hla/srv/SrvProto.java b/minidns-hla/src/main/java/org/minidns/hla/srv/SrvProto.java
index 54e7fec6..62b2997e 100644
--- a/minidns-hla/src/main/java/org/minidns/hla/srv/SrvProto.java
+++ b/minidns-hla/src/main/java/org/minidns/hla/srv/SrvProto.java
@@ -20,6 +20,7 @@ public enum SrvProto {
;
// @formatter:on
+ @SuppressWarnings("ImmutableEnumChecker")
public final DnsLabel dnsLabel;
SrvProto() {
diff --git a/minidns-hla/src/main/java/org/minidns/hla/srv/SrvService.java b/minidns-hla/src/main/java/org/minidns/hla/srv/SrvService.java
index ebae7bfd..646a1e92 100644
--- a/minidns-hla/src/main/java/org/minidns/hla/srv/SrvService.java
+++ b/minidns-hla/src/main/java/org/minidns/hla/srv/SrvService.java
@@ -34,6 +34,7 @@ public enum SrvService {
;
// @formatter:on
+ @SuppressWarnings("ImmutableEnumChecker")
public final DnsLabel dnsLabel;
SrvService() {
diff --git a/minidns-integration-test/build.gradle b/minidns-integration-test/build.gradle
index c79394ed..a03022af 100644
--- a/minidns-integration-test/build.gradle
+++ b/minidns-integration-test/build.gradle
@@ -8,20 +8,23 @@
* upon the condition that you accept all of the terms of either
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
*/
-apply plugin: 'application'
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.application-conventions'
+}
mainClassName = 'org.minidns.integrationtest.IntegrationTestHelper'
applicationDefaultJvmArgs = ["-enableassertions"]
dependencies {
- compile project(':minidns-client')
- compile project(':minidns-async')
- compile project(':minidns-iterative-resolver')
- compile project(':minidns-dnssec')
- compile project(':minidns-hla')
+ api project(':minidns-client')
+ api project(':minidns-async')
+ api project(':minidns-iterative-resolver')
+ api project(':minidns-dnssec')
+ api project(':minidns-hla')
implementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
}
run {
diff --git a/minidns-integration-test/src/main/java/org/minidns/jul/MiniDnsJul.java b/minidns-integration-test/src/main/java/org/minidns/jul/MiniDnsJul.java
index 2d7dc966..b7f95549 100644
--- a/minidns-integration-test/src/main/java/org/minidns/jul/MiniDnsJul.java
+++ b/minidns-integration-test/src/main/java/org/minidns/jul/MiniDnsJul.java
@@ -16,8 +16,8 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Handler;
@@ -38,9 +38,9 @@ public class MiniDnsJul {
);
// @formatter:on
- private static final SimpleDateFormat LONG_LOG_TIME_FORMAT = new SimpleDateFormat("hh:mm:ss.SSS");
+ private static final DateTimeFormatter LONG_LOG_TIME_FORMAT = DateTimeFormatter.ofPattern("hh:mm:ss.SSS");
- private static final SimpleDateFormat SHORT_LOG_TIME_FORMAT = new SimpleDateFormat("mm:ss.SSS");
+ private static final DateTimeFormatter SHORT_LOG_TIME_FORMAT = DateTimeFormatter.ofPattern("mm:ss.SSS");
private static final Handler CONSOLE_HANDLER = new ConsoleHandler();
@@ -59,16 +59,12 @@ public class MiniDnsJul {
public String format(LogRecord logRecord) {
StringBuilder sb = new StringBuilder(256);
- Date date = new Date(logRecord.getMillis());
+ Instant date = Instant.ofEpochMilli(logRecord.getMillis());
String dateString;
if (shortLog) {
- synchronized (SHORT_LOG_TIME_FORMAT) {
- dateString = SHORT_LOG_TIME_FORMAT.format(date);
- }
+ dateString = SHORT_LOG_TIME_FORMAT.format(date);
} else {
- synchronized (LONG_LOG_TIME_FORMAT) {
- dateString = LONG_LOG_TIME_FORMAT.format(date);
- }
+ dateString = LONG_LOG_TIME_FORMAT.format(date);
}
sb.append(dateString).append(' ');
diff --git a/minidns-iterative-resolver/build.gradle b/minidns-iterative-resolver/build.gradle
index a74061ed..9992b827 100644
--- a/minidns-iterative-resolver/build.gradle
+++ b/minidns-iterative-resolver/build.gradle
@@ -1,4 +1,9 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id 'org.minidns.android-conventions'
+}
+
dependencies {
- compile project(':minidns-client')
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
+ api project(':minidns-client')
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
}
diff --git a/minidns-iterative-resolver/src/main/java/org/minidns/iterative/IterativeDnsClient.java b/minidns-iterative-resolver/src/main/java/org/minidns/iterative/IterativeDnsClient.java
index 8a75a3ee..34c746ad 100644
--- a/minidns-iterative-resolver/src/main/java/org/minidns/iterative/IterativeDnsClient.java
+++ b/minidns-iterative-resolver/src/main/java/org/minidns/iterative/IterativeDnsClient.java
@@ -42,7 +42,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
@@ -176,7 +175,7 @@ private DnsQueryResult queryRecursive(ResolutionState resolutionState, DnsMessag
}
}
- List ioExceptions = new LinkedList<>();
+ List ioExceptions = new ArrayList<>();
try {
return queryRecursive(resolutionState, q, primaryTarget, authoritativeZone);
@@ -213,7 +212,7 @@ private DnsQueryResult queryRecursive(ResolutionState resolutionState, DnsMessag
List> authorities = resMessage.copyAuthority();
- List ioExceptions = new LinkedList<>();
+ List ioExceptions = new ArrayList<>();
// Glued NS first
for (Iterator> iterator = authorities.iterator(); iterator.hasNext(); ) {
diff --git a/minidns-iterative-resolver/src/main/java/org/minidns/iterative/ReliableDnsClient.java b/minidns-iterative-resolver/src/main/java/org/minidns/iterative/ReliableDnsClient.java
index b712312e..715bd6cb 100644
--- a/minidns-iterative-resolver/src/main/java/org/minidns/iterative/ReliableDnsClient.java
+++ b/minidns-iterative-resolver/src/main/java/org/minidns/iterative/ReliableDnsClient.java
@@ -11,7 +11,7 @@
package org.minidns.iterative;
import java.io.IOException;
-import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@@ -91,7 +91,7 @@ public ReliableDnsClient() {
protected DnsQueryResult query(DnsMessage.Builder q) throws IOException {
DnsQueryResult dnsMessage = null;
String unacceptableReason = null;
- List ioExceptions = new LinkedList<>();
+ List ioExceptions = new ArrayList<>();
if (mode != Mode.iterativeOnly) {
// Try a recursive query.
diff --git a/minidns-repl/build.gradle b/minidns-repl/build.gradle
index 4509d821..889cd4b9 100644
--- a/minidns-repl/build.gradle
+++ b/minidns-repl/build.gradle
@@ -1,25 +1,35 @@
+plugins {
+ id 'org.minidns.java-conventions'
+ id "com.github.alisiikh.scalastyle" version "3.5.0"
+}
+
+apply plugin: 'scala'
+apply plugin: 'com.github.alisiikh.scalastyle'
+
ext {
- scalaVersion = '2.12.4'
+ scalaVersion = '2.13.13'
}
dependencies {
- compile project(':minidns-client')
- compile project(':minidns-iterative-resolver')
- compile project(':minidns-dnssec')
- compile project(':minidns-integration-test')
- compile project(':minidns-hla')
- compile "com.lihaoyi:ammonite_$scalaVersion:1.1.2"
- testCompile project(path: ":minidns-client", configuration: "testRuntime")
+ api project(':minidns-client')
+ api project(':minidns-iterative-resolver')
+ api project(':minidns-dnssec')
+ api project(':minidns-integration-test')
+ api project(':minidns-hla')
+ implementation "com.lihaoyi:ammonite_$scalaVersion:3.0.0-M1"
+ testImplementation project(path: ":minidns-client", configuration: "testRuntime")
+}
+
+scalastyle {
+ config = new File(rootConfigDir, 'scalaStyle.xml')
+ verbose = true
+ failOnWarning = true
}
+check.dependsOn(scalastyleCheck)
+
task printClasspath(dependsOn: assemble) {
doLast {
println sourceSets.main.runtimeClasspath.asPath
}
}
-
-animalsniffer {
- // Disable AnimalSniffer for minidns-repl.
- // Unfortunately I found no better way to disable it besided making the sourceSets set an empty set.
- sourceSets = []
-}
diff --git a/settings.gradle b/settings.gradle
index ca59a4d1..2d847ada 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,3 +1,7 @@
+pluginManagement {
+ includeBuild('build-logic')
+}
+
// The name of the root project.
// If we would not set the name, then gradle would use the directory
// name of the root directory
@@ -12,4 +16,4 @@ include 'minidns-dane-java7'
include 'minidns-integration-test'
include 'minidns-repl'
include 'minidns-hla'
-include 'minidns-android21'
+include 'minidns-android23'