From 1c8167eed8d758dca75be8f74a92dd109f47ccba Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Sun, 13 Dec 2020 02:04:06 +0100 Subject: [PATCH 1/4] Add validate plugin check --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2c03c49..4cdad50 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -22,7 +22,7 @@ jobs: java-version: 11 - name: Run verifications - run: ./gradlew detekt ktLintCheck test + run: ./gradlew validatePlugin detekt ktLintCheck test - name: Upload reports uses: actions/upload-artifact@v2 From 7c9d9cfe90637ed934604758e4b2eb665f4bf7ab Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Sun, 13 Dec 2020 02:17:47 +0100 Subject: [PATCH 2/4] Bump version in readme + use the plugin again --- README.md | 5 +++-- build.gradle.kts | 15 ++++++++++----- src/main/java/se/eelde/buildOptimization/Check.kt | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 62c64bd..e072c79 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Plugin published [here](https://plugins.gradle.org/plugin/se.eelde.build-optimiz ##### Use it ```kotlin plugins { - id("se.eelde.build-optimizations") version "0.1.1" + id("se.eelde.build-optimizations") version "0.2.0" } ``` @@ -23,7 +23,7 @@ plugins { ```kotlin buildscript { dependencies { - classpath("se.eelde.build-optimizations:se.eelde.build-optimizations.gradle.plugin:0.1.1") + classpath("se.eelde.build-optimizations:se.eelde.build-optimizations.gradle.plugin:0.2.0") } } @@ -49,3 +49,4 @@ Checks are [here](src/main/java/se/eelde/build_optimization/Check.kt) * Default File encoding * Require a specific setting of jvmXmx (default -Xmx=2g) * Require a specific setting of jvmXms (default -Xms=500m) +* Require file system watcher to be enabled after gradle 6.5 diff --git a/build.gradle.kts b/build.gradle.kts index 04c6103..d2f701f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("maven-publish") id("signing") // use this dependency to run plugin from plugin repository - // id("se.eelde.build-optimizations") version "0.1.2" + id("se.eelde.build-optimizations") version "0.2.0" id("org.jlleitschuh.gradle.ktlint") version "9.4.1" id("io.gitlab.arturbosch.detekt") version "1.14.2" } @@ -15,17 +15,17 @@ plugins { buildscript { // use this dependency to run plugin locally // dependencies { - // classpath("se.eelde.build-optimizations:se.eelde.build-optimizations.gradle.plugin:0.1.3-SNAPSHOT") + // classpath("se.eelde.build-optimizations:se.eelde.build-optimizations.gradle.plugin:0.2.0") // } repositories { - jcenter() + mavenCentral() mavenLocal() } } allprojects { repositories { - jcenter() + mavenCentral() } } @@ -47,7 +47,12 @@ detekt { autoCorrect = true } -// apply(plugin= "se.eelde.build-optimizations") +apply(plugin = "se.eelde.build-optimizations") + +buildOptimization { + jvmXmx = "2GB" + jvmXms = "500MB" +} java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/java/se/eelde/buildOptimization/Check.kt b/src/main/java/se/eelde/buildOptimization/Check.kt index c99278c..cd49677 100644 --- a/src/main/java/se/eelde/buildOptimization/Check.kt +++ b/src/main/java/se/eelde/buildOptimization/Check.kt @@ -79,7 +79,7 @@ sealed class Check(val aDefault: CheckSeverity, val link: String, val hints: Lis link = "https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory", hints = listOf( "Expecting more jvm xms memory to be defined", - "gradle.properties >> org.gradle.jvmargs=-Xmx500m" + "gradle.properties >> org.gradle.jvmargs=-Xms500m" ), praise = "You have ample jvm xms memory assigned :+1" ) From 6f1be4e7898bb78b488b6e07ac18f5fe1e979c46 Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Fri, 4 Feb 2022 01:19:31 +0100 Subject: [PATCH 3/4] Add some input annotations --- build.gradle.kts | 30 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../BuildOptimizationPlugin.kt | 3 +- .../BuildOptimizationPluginExtension.kt | 10 +++++++ .../BuildOptimizationTask.kt | 17 ++++++++--- .../eelde/buildOptimization/JvmArgsParser.kt | 7 +++-- .../evaluators/FileWatcherEvaluator.kt | 23 +++++--------- .../BuildOptimizationPluginTest.kt | 3 +- 8 files changed, 54 insertions(+), 41 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d2f701f..5147f63 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,15 +1,15 @@ plugins { - id("com.github.ben-manes.versions") version "0.36.0" + id("com.github.ben-manes.versions") version "0.41.0" id("java") id("java-gradle-plugin") - id("com.gradle.plugin-publish") version "0.12.0" - id("org.jetbrains.kotlin.jvm") version "1.4.21" + id("com.gradle.plugin-publish") version "0.20.0" + id("org.jetbrains.kotlin.jvm") version "1.6.10" id("maven-publish") id("signing") // use this dependency to run plugin from plugin repository - id("se.eelde.build-optimizations") version "0.2.0" + // id("se.eelde.build-optimizations") version "0.2.0" id("org.jlleitschuh.gradle.ktlint") version "9.4.1" - id("io.gitlab.arturbosch.detekt") version "1.14.2" + id("io.gitlab.arturbosch.detekt") version "1.19.0" } buildscript { @@ -40,19 +40,19 @@ detekt { } dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.14.2") + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0") } detekt { autoCorrect = true } -apply(plugin = "se.eelde.build-optimizations") +// apply(plugin = "se.eelde.build-optimizations") -buildOptimization { - jvmXmx = "2GB" - jvmXms = "500MB" -} +//buildOptimization { +// jvmXmx = "2GB" +// jvmXms = "500MB" +//} java { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -71,12 +71,12 @@ tasks.withType { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.21") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.10") implementation(gradleApi()) testImplementation(gradleTestKit()) - testImplementation("com.google.truth:truth:1.1") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0") + testImplementation("com.google.truth:truth:1.1.3") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") } // Use java-gradle-plugin to generate plugin descriptors and specify plugin ids diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f3fdbc..669386b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt index ac08f7c..1554b04 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt @@ -3,10 +3,12 @@ package se.eelde.buildOptimization import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.internal.project.DefaultProject +import org.gradle.api.tasks.Internal class BuildOptimizationPlugin : Plugin { var buildOptimizationPluginExtension: BuildOptimizationPluginExtension? = null + @Internal lateinit var buildOptimizationOutputter: BuildOptimizationOutputter override fun apply(project: Project) { @@ -26,7 +28,6 @@ class BuildOptimizationPlugin : Plugin { val buildOptimizationTask = project.tasks.register("checkBuildOptimizations", BuildOptimizationTask::class.java) { task -> - task.buildOptimizationOutputter = buildOptimizationOutputter task.buildOptimizationPluginExtension = buildOptimizationPluginExtension as BuildOptimizationPluginExtension } diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt index eeb797f..1f3aca0 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt @@ -1,9 +1,14 @@ package se.eelde.buildOptimization +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.Optional + open class BuildOptimizationPluginExtension { private val maxRegExp = """(\d*)([kKmMgG])([bB])""".toRegex() + @Nested fun getJvmXmxMemory(): Memory { jvmXmx?.let { jvmXmx -> val matches = maxRegExp.matchEntire(jvmXmx) @@ -17,6 +22,7 @@ open class BuildOptimizationPluginExtension { return Memory.Gigabyte(2) } + @Nested fun getJvmXmsMemory(): Memory { jvmXms?.let { jvmXms -> val matches = maxRegExp.matchEntire(jvmXms) @@ -37,7 +43,11 @@ open class BuildOptimizationPluginExtension { else -> throw IllegalArgumentException("Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}") } + @Input + @Optional var jvmXmx: String? = null + @Input + @Optional var jvmXms: String? = null companion object { diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt index 13bbb02..afa971e 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt @@ -3,25 +3,34 @@ package se.eelde.buildOptimization import org.gradle.api.DefaultTask import org.gradle.api.GradleException import org.gradle.api.internal.project.DefaultProject -import org.gradle.api.tasks.TaskAction +import org.gradle.api.provider.Property +import org.gradle.api.tasks.* import se.eelde.buildOptimization.evaluators.DaemonExecutionEvaluator import se.eelde.buildOptimization.evaluators.FileWatcherEvaluator import se.eelde.buildOptimization.evaluators.StartParameterEvaluator +import java.io.File open class BuildOptimizationTask : DefaultTask() { - internal lateinit var buildOptimizationOutputter: BuildOptimizationOutputter - internal lateinit var buildOptimizationPluginExtension: BuildOptimizationPluginExtension + @Nested + lateinit var buildOptimizationPluginExtension: BuildOptimizationPluginExtension + + @OutputFile + val file: File = project.file("outputfile.txt") + + //@Input + //val inputString: Property = project.objects.property(String::class.java).convention("default value") @TaskAction @Suppress("LongMethod", "ComplexMethod") fun moduleTask() { - // output this if the task is explicity invoked? // buildOptimizationOutputter.greatInfo() var optimizationsMissing = false + var buildOptimizationOutputter = BuildOptimizationOutputter(defaultProject = (project as DefaultProject), logger = project.logger) + val fileWatcherEvaluator = FileWatcherEvaluator(project as DefaultProject) val fileSystemWatcherCheck = Check.FileSystemWatcher() when (fileWatcherEvaluator.isWatchFileSystem) { diff --git a/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt b/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt index 1a1e0e6..40554d3 100644 --- a/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt +++ b/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt @@ -1,5 +1,6 @@ package se.eelde.buildOptimization +import org.gradle.api.tasks.Input import java.nio.charset.Charset class JvmArgsParser { @@ -77,15 +78,15 @@ sealed class Memory { override fun asBytes() = -1L } - data class Kilobyte(val size: Long) : Memory() { + data class Kilobyte(@Input val size: Long) : Memory() { override fun asBytes() = size * ONE_THOUSAND } - data class Megabyte(val size: Long) : Memory() { + data class Megabyte(@Input val size: Long) : Memory() { override fun asBytes() = size * ONE_THOUSAND * ONE_THOUSAND } - data class Gigabyte(val size: Long) : Memory() { + data class Gigabyte(@Input val size: Long) : Memory() { override fun asBytes() = size * ONE_THOUSAND * ONE_THOUSAND * ONE_THOUSAND } } diff --git a/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt b/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt index c16e082..1b25f54 100644 --- a/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt +++ b/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt @@ -3,6 +3,7 @@ package se.eelde.buildOptimization.evaluators import org.gradle.StartParameter import org.gradle.api.internal.StartParameterInternal import org.gradle.api.internal.project.DefaultProject +import org.gradle.internal.watch.vfs.WatchMode class FileWatcherEvaluator(private val project: DefaultProject) { @@ -22,24 +23,14 @@ class FileWatcherEvaluator(private val project: DefaultProject) { get() { val gradleVersion = SemanticVersion.parse(project.gradle.gradleVersion) - val compatible = gradleVersion.compatibleWith(SemanticVersion.parse("6.7")) - // throw GradleException("oh noes: comparing $gradleVersion $compatible") - return if (SemanticVersion.parse("6.7").compatibleWith(gradleVersion)) { - // 6.7 - if ((startParameter as StartParameterInternal).isWatchFileSystem) { - Result.Watching - } else { - Result.NotWatching - } - } else if (SemanticVersion.parse("6.5").compatibleWith(gradleVersion)) { - // 6.5 -> 6.6 - if ((startParameter as StartParameterInternal).isWatchFileSystem) { - Result.WatchingUnstable - } else { - Result.NotWatching + when ((startParameter as StartParameterInternal).watchFileSystemMode) { + WatchMode.ENABLED -> Result.Watching + WatchMode.DEFAULT -> Result.Watching + WatchMode.DISABLED -> Result.NotWatching + null -> Result.NotApplicable } - } else { + } else { Result.NotApplicable } } diff --git a/src/test/java/se/eelde/buildOptimization/BuildOptimizationPluginTest.kt b/src/test/java/se/eelde/buildOptimization/BuildOptimizationPluginTest.kt index c6fa7ca..619dd1d 100644 --- a/src/test/java/se/eelde/buildOptimization/BuildOptimizationPluginTest.kt +++ b/src/test/java/se/eelde/buildOptimization/BuildOptimizationPluginTest.kt @@ -57,8 +57,9 @@ org.gradle.jvmargs=-Xmx1g @Suppress("UnstableApiUsage") val build = GradleRunner.create() - .withEnvironment(mapOf()) + // .withEnvironment(mapOf()) .withProjectDir(testProjectDir) + .withDebug(true) .withArguments("checkBuildOptimizations") .withPluginClasspath() .buildAndFail() From df84e567f1bcadd4ea01c35c06fe507c212082c5 Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Fri, 4 Feb 2022 13:05:40 +0100 Subject: [PATCH 4/4] Update and fix some stuff. --- .github/workflows/manual-release.yml | 19 +- .github/workflows/pull-request.yml | 17 +- build.gradle.kts | 8 +- config/detekt/detekt.yml | 681 ------------------ detekt-baseline.xml | 10 + .../BuildOptimizationPlugin.kt | 3 +- .../BuildOptimizationPluginExtension.kt | 5 +- .../BuildOptimizationTask.kt | 12 +- .../eelde/buildOptimization/JvmArgsParser.kt | 17 +- .../evaluators/DaemonExecutionEvaluator.kt | 36 +- .../evaluators/FileWatcherEvaluator.kt | 2 +- .../evaluators/SemanticVersion.kt | 3 +- .../buildOptimization/JvmArgsParserTest.kt | 14 +- .../eelde/buildOptimization/ParseDslTest.kt | 3 +- 14 files changed, 83 insertions(+), 747 deletions(-) delete mode 100644 config/detekt/detekt.yml create mode 100644 detekt-baseline.xml diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index 4f2ce12..2f1eb20 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -4,32 +4,31 @@ on: workflow_dispatch: jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 + with: + fetch-depth: '0' - name: Set up environment run: | echo "${{ secrets.GRADLE_PUBLISH_KEY }}" >> ~/.gradle/gradle.properties echo "${{ secrets.GRADLE_PUBLISH_SECRET }}" >> ~/.gradle/gradle.properties - - name: Check out java - uses: actions/setup-java@v1 + - name: Setup java + uses: actions/setup-java@v2.5.0 with: - java-version: 1.11 + distribution: 'adopt' + java-version: 11 - name: Run verifications - run: ./gradlew detekt ktLintCheck test + run: ./gradlew check - name: Upload reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v2.3.1 if: failure() with: name: Reports diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4cdad50..67e8974 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,27 +5,26 @@ on: branches: [ develop ] jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v2.4.0 + with: + fetch-depth: '0' - - name: Check out java - uses: actions/setup-java@v1 + - name: Setup java + uses: actions/setup-java@v2.5.0 with: + distribution: 'adopt' java-version: 11 - name: Run verifications - run: ./gradlew validatePlugin detekt ktLintCheck test + run: ./gradlew check - name: Upload reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v2.3.1 if: failure() with: name: Reports diff --git a/build.gradle.kts b/build.gradle.kts index 5147f63..5a3d11e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,6 @@ plugins { id("signing") // use this dependency to run plugin from plugin repository // id("se.eelde.build-optimizations") version "0.2.0" - id("org.jlleitschuh.gradle.ktlint") version "9.4.1" id("io.gitlab.arturbosch.detekt") version "1.19.0" } @@ -32,11 +31,6 @@ allprojects { detekt { autoCorrect = true buildUponDefaultConfig = true - config = files("$projectDir/config/detekt/detekt.yml") - - reports { - html.enabled = true - } } dependencies { @@ -47,7 +41,7 @@ detekt { autoCorrect = true } -// apply(plugin = "se.eelde.build-optimizations") +//apply(plugin = "se.eelde.build-optimizations") //buildOptimization { // jvmXmx = "2GB" diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml deleted file mode 100644 index 4f661bf..0000000 --- a/config/detekt/detekt.yml +++ /dev/null @@ -1,681 +0,0 @@ -build: - maxIssues: 0 - excludeCorrectable: false - weights: - # complexity: 2 - # LongParameterList: 1 - # style: 1 - # comments: 1 - -config: - validation: true - warningsAsErrors: false - # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' - excludes: '' - -processors: - active: true - exclude: - - 'DetektProgressListener' - # - 'FunctionCountProcessor' - # - 'PropertyCountProcessor' - # - 'ClassCountProcessor' - # - 'PackageCountProcessor' - # - 'KtFileCountProcessor' - -console-reports: - active: true - exclude: - - 'ProjectStatisticsReport' - - 'ComplexityReport' - - 'NotificationReport' - # - 'FindingsReport' - - 'FileBasedFindingsReport' - -output-reports: - active: true - exclude: - # - 'TxtOutputReport' - # - 'XmlOutputReport' - # - 'HtmlOutputReport' - -comments: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - AbsentOrWrongFileLicense: - active: false - licenseTemplateFile: 'license.template' - CommentOverPrivateFunction: - active: false - CommentOverPrivateProperty: - active: false - EndOfSentenceFormat: - active: false - endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' - UndocumentedPublicClass: - active: false - searchInNestedClass: true - searchInInnerClass: true - searchInInnerObject: true - searchInInnerInterface: true - UndocumentedPublicFunction: - active: false - UndocumentedPublicProperty: - active: false - -complexity: - active: true - ComplexCondition: - active: true - threshold: 4 - ComplexInterface: - active: false - threshold: 10 - includeStaticDeclarations: false - includePrivateDeclarations: false - ComplexMethod: - active: true - threshold: 15 - ignoreSingleWhenExpression: false - ignoreSimpleWhenEntries: false - ignoreNestingFunctions: false - nestingFunctions: [ run, let, apply, with, also, use, forEach, isNotNull, ifNull ] - LabeledExpression: - active: false - ignoredLabels: [ ] - LargeClass: - active: true - threshold: 600 - LongMethod: - active: true - threshold: 60 - LongParameterList: - active: true - functionThreshold: 6 - constructorThreshold: 7 - ignoreDefaultParameters: false - ignoreDataClasses: true - ignoreAnnotated: [ ] - MethodOverloading: - active: false - threshold: 6 - NestedBlockDepth: - active: true - threshold: 4 - ReplaceSafeCallChainWithRun: - active: false - StringLiteralDuplication: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - threshold: 3 - ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' - TooManyFunctions: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - thresholdInFiles: 11 - thresholdInClasses: 11 - thresholdInInterfaces: 11 - thresholdInObjects: 11 - thresholdInEnums: 11 - ignoreDeprecated: false - ignorePrivate: false - ignoreOverridden: false - -coroutines: - active: true - GlobalCoroutineUsage: - active: false - RedundantSuspendModifier: - active: false - SuspendFunWithFlowReturnType: - active: false - -empty-blocks: - active: true - EmptyCatchBlock: - active: true - allowedExceptionNameRegex: '_|(ignore|expected).*' - EmptyClassBlock: - active: true - EmptyDefaultConstructor: - active: true - EmptyDoWhileBlock: - active: true - EmptyElseBlock: - active: true - EmptyFinallyBlock: - active: true - EmptyForBlock: - active: true - EmptyFunctionBlock: - active: true - ignoreOverridden: false - EmptyIfBlock: - active: true - EmptyInitBlock: - active: true - EmptyKtFile: - active: true - EmptySecondaryConstructor: - active: true - EmptyTryBlock: - active: true - EmptyWhenBlock: - active: true - EmptyWhileBlock: - active: true - -exceptions: - active: true - ExceptionRaisedInUnexpectedLocation: - active: false - methodNames: [ toString, hashCode, equals, finalize ] - InstanceOfCheckForException: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - NotImplementedDeclaration: - active: false - PrintStackTrace: - active: false - RethrowCaughtException: - active: false - ReturnFromFinally: - active: false - ignoreLabeled: false - SwallowedException: - active: false - ignoredExceptionTypes: - - InterruptedException - - NumberFormatException - - ParseException - - MalformedURLException - allowedExceptionNameRegex: '_|(ignore|expected).*' - ThrowingExceptionFromFinally: - active: false - ThrowingExceptionInMain: - active: false - ThrowingExceptionsWithoutMessageOrCause: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - exceptions: - - IllegalArgumentException - - IllegalStateException - - IOException - ThrowingNewInstanceOfSameException: - active: false - TooGenericExceptionCaught: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable - allowedExceptionNameRegex: '_|(ignore|expected).*' - TooGenericExceptionThrown: - active: true - exceptionNames: - - Error - - Exception - - Throwable - - RuntimeException - -formatting: - active: true - android: true - autoCorrect: true - AnnotationOnSeparateLine: - active: false - autoCorrect: true - AnnotationSpacing: - active: false - autoCorrect: true - ArgumentListWrapping: - active: false - autoCorrect: true - ChainWrapping: - active: true - autoCorrect: true - CommentSpacing: - active: true - autoCorrect: true - EnumEntryNameCase: - active: false - autoCorrect: true - Filename: - active: true - FinalNewline: - active: true - autoCorrect: true - insertFinalNewLine: true - ImportOrdering: - active: false - autoCorrect: true - layout: 'idea' - Indentation: - active: false - autoCorrect: true - indentSize: 4 - continuationIndentSize: 4 - MaximumLineLength: - active: false - maxLineLength: 120 - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: true - autoCorrect: true - NoBlankLineBeforeRbrace: - active: true - autoCorrect: true - NoConsecutiveBlankLines: - active: true - autoCorrect: true - NoEmptyClassBody: - active: true - autoCorrect: true - NoEmptyFirstLineInMethodBlock: - active: false - autoCorrect: true - NoLineBreakAfterElse: - active: true - autoCorrect: true - NoLineBreakBeforeAssignment: - active: true - autoCorrect: true - NoMultipleSpaces: - active: true - autoCorrect: true - NoSemicolons: - active: true - autoCorrect: true - NoTrailingSpaces: - active: true - autoCorrect: true - NoUnitReturn: - active: true - autoCorrect: true - NoUnusedImports: - active: true - autoCorrect: true - NoWildcardImports: - active: true - PackageName: - active: true - autoCorrect: true - ParameterListWrapping: - active: true - autoCorrect: true - indentSize: 4 - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundComma: - active: true - autoCorrect: true - SpacingAroundCurly: - active: true - autoCorrect: true - SpacingAroundDot: - active: true - autoCorrect: true - SpacingAroundDoubleColon: - active: false - autoCorrect: true - SpacingAroundKeyword: - active: true - autoCorrect: true - SpacingAroundOperators: - active: true - autoCorrect: true - SpacingAroundParens: - active: true - autoCorrect: true - SpacingAroundRangeOperator: - active: true - autoCorrect: true - SpacingBetweenDeclarationsWithAnnotations: - active: false - autoCorrect: true - SpacingBetweenDeclarationsWithComments: - active: false - autoCorrect: true - StringTemplate: - active: true - autoCorrect: true - -naming: - active: true - ClassNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - classPattern: '[A-Z][a-zA-Z0-9]*' - ConstructorParameterNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - parameterPattern: '[a-z][A-Za-z0-9]*' - privateParameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true - EnumNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' - ForbiddenClassName: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - forbiddenName: [ ] - FunctionMaxLength: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - maximumFunctionNameLength: 30 - FunctionMinLength: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - minimumFunctionNameLength: 3 - FunctionNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' - excludeClassPattern: '$^' - ignoreOverridden: true - ignoreAnnotated: [ 'Composable' ] - FunctionParameterNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - parameterPattern: '[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true - InvalidPackageDeclaration: - active: false - rootPackage: '' - MatchingDeclarationName: - active: true - mustBeFirst: true - MemberNameEqualsClassName: - active: true - ignoreOverridden: true - NonBooleanPropertyPrefixedWithIs: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - ObjectPropertyNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - constantPattern: '[A-Za-z][_A-Za-z0-9]*' - propertyPattern: '[A-Za-z][_A-Za-z0-9]*' - privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' - PackageNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' - TopLevelPropertyNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - constantPattern: '[A-Z][_A-Z0-9]*' - propertyPattern: '[A-Za-z][_A-Za-z0-9]*' - privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' - VariableMaxLength: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - maximumVariableNameLength: 64 - VariableMinLength: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - minimumVariableNameLength: 1 - VariableNaming: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - variablePattern: '[a-z][A-Za-z0-9]*' - privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' - excludeClassPattern: '$^' - ignoreOverridden: true - -performance: - active: true - ArrayPrimitive: - active: true - ForEachOnRange: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - SpreadOperator: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - UnnecessaryTemporaryInstantiation: - active: true - -potential-bugs: - active: true - Deprecation: - active: false - DuplicateCaseInWhenExpression: - active: true - EqualsAlwaysReturnsTrueOrFalse: - active: true - EqualsWithHashCodeExist: - active: true - ExplicitGarbageCollectionCall: - active: true - HasPlatformType: - active: false - IgnoredReturnValue: - active: false - restrictToAnnotatedMethods: true - returnValueAnnotations: [ '*.CheckReturnValue', '*.CheckResult' ] - ImplicitDefaultLocale: - active: false - ImplicitUnitReturnType: - active: false - allowExplicitReturnType: true - InvalidRange: - active: true - IteratorHasNextCallsNextMethod: - active: true - IteratorNotThrowingNoSuchElementException: - active: true - LateinitUsage: - active: false - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - excludeAnnotatedProperties: [ ] - ignoreOnClassesPattern: '' - MapGetWithNotNullAssertionOperator: - active: false - MissingWhenCase: - active: true - NullableToStringCall: - active: false - RedundantElseInWhen: - active: true - UnconditionalJumpStatementInLoop: - active: false - UnnecessaryNotNullOperator: - active: false - UnnecessarySafeCall: - active: false - UnreachableCode: - active: true - UnsafeCallOnNullableType: - active: true - UnsafeCast: - active: false - UselessPostfixExpression: - active: false - WrongEqualsTypeParameter: - active: true - -style: - active: true - ClassOrdering: - active: false - CollapsibleIfStatements: - active: false - DataClassContainsFunctions: - active: false - conversionFunctionPrefix: 'to' - DataClassShouldBeImmutable: - active: false - EqualsNullCall: - active: true - EqualsOnSignatureLine: - active: false - ExplicitCollectionElementAccessMethod: - active: false - ExplicitItLambdaParameter: - active: false - ExpressionBodySyntax: - active: false - includeLineWrapping: false - ForbiddenComment: - active: true - values: [ 'TODO:', 'FIXME:', 'STOPSHIP:' ] - allowedPatterns: '' - ForbiddenImport: - active: false - imports: [ ] - forbiddenPatterns: '' - ForbiddenMethodCall: - active: false - methods: [ 'kotlin.io.println', 'kotlin.io.print' ] - ForbiddenPublicDataClass: - active: false - ignorePackages: [ '*.internal', '*.internal.*' ] - ForbiddenVoid: - active: false - ignoreOverridden: false - ignoreUsageInGenerics: false - FunctionOnlyReturningConstant: - active: true - ignoreOverridableFunction: true - excludedFunctions: 'describeContents' - excludeAnnotatedFunction: [ 'dagger.Provides' ] - LibraryCodeMustSpecifyReturnType: - active: true - LibraryEntitiesShouldNotBePublic: - active: false - LoopWithTooManyJumpStatements: - active: true - maxJumpCount: 1 - MagicNumber: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - ignoreNumbers: [ '-1', '0', '1', '2' ] - ignoreHashCodeFunction: true - ignorePropertyDeclaration: false - ignoreLocalVariableDeclaration: false - ignoreConstantDeclaration: true - ignoreCompanionObjectPropertyDeclaration: true - ignoreAnnotation: false - ignoreNamedArgument: true - ignoreEnums: false - ignoreRanges: false - MandatoryBracesIfStatements: - active: false - MandatoryBracesLoops: - active: false - MaxLineLength: - active: false - maxLineLength: 120 - excludePackageStatements: true - excludeImportStatements: true - excludeCommentStatements: false - MayBeConst: - active: true - ModifierOrder: - active: true - NestedClassesVisibility: - active: false - NewLineAtEndOfFile: - active: true - NoTabs: - active: false - OptionalAbstractKeyword: - active: true - OptionalUnit: - active: false - OptionalWhenBraces: - active: false - PreferToOverPairSyntax: - active: false - ProtectedMemberInFinalClass: - active: true - RedundantExplicitType: - active: false - RedundantVisibilityModifierRule: - active: false - ReturnCount: - active: true - max: 2 - excludedFunctions: 'equals' - excludeLabeled: false - excludeReturnFromLambda: true - excludeGuardClauses: false - SafeCast: - active: true - SerialVersionUIDInSerializableClass: - active: false - SpacingBetweenPackageAndImports: - active: false - ThrowsCount: - active: true - max: 2 - TrailingWhitespace: - active: false - UnderscoresInNumericLiterals: - active: false - acceptableDecimalLength: 5 - UnnecessaryAbstractClass: - active: true - excludeAnnotatedClasses: [ 'dagger.Module' ] - UnnecessaryAnnotationUseSiteTarget: - active: false - UnnecessaryApply: - active: false - UnnecessaryInheritance: - active: true - UnnecessaryLet: - active: false - UnnecessaryParentheses: - active: false - UntilInsteadOfRangeTo: - active: false - UnusedImports: - active: false - UnusedPrivateClass: - active: true - UnusedPrivateMember: - active: false - allowedNames: '(_|ignored|expected|serialVersionUID)' - UseArrayLiteralsInAnnotations: - active: false - UseCheckNotNull: - active: false - UseCheckOrError: - active: false - UseDataClass: - active: false - excludeAnnotatedClasses: [ ] - allowVars: false - UseEmptyCounterpart: - active: false - UseIfInsteadOfWhen: - active: false - UseRequire: - active: false - UseRequireNotNull: - active: false - UselessCallOnNotNull: - active: true - UtilityClassWithPublicConstructor: - active: true - VarCouldBeVal: - active: false - WildcardImport: - active: true - excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] - excludeImports: [ 'java.util.*', 'kotlinx.android.synthetic.*' ] diff --git a/detekt-baseline.xml b/detekt-baseline.xml new file mode 100644 index 0000000..86752fe --- /dev/null +++ b/detekt-baseline.xml @@ -0,0 +1,10 @@ + + + + + MaxLineLength:SemanticVersion.kt$SemanticVersion.Companion$"""^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.?(?<patch>0|[1-9]\d*)?(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?${'$'}""".toRegex() + MaxLineLength:SemanticVersionTest.kt$SemanticVersionTest$"""^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.?(?<patch>0|[1-9]\d*)?(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?${'$'}""".toRegex() + MaximumLineLength:se.eelde.buildOptimization.evaluators.SemanticVersion.kt:19 + MaximumLineLength:se.eelde.buildOptimization.evaluators.SemanticVersionTest.kt:14 + + diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt index 1554b04..16d65cf 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPlugin.kt @@ -42,7 +42,8 @@ class BuildOptimizationPlugin : Plugin { // project.tasks.register("applyBuildOptimizations", BuildOptimizationTask::class.java) { task -> // task.buildOptimizationOutputter = buildOptimizationOutputter -// task.buildOptimizationPluginExtension = buildOptimizationPluginExtension as BuildOptimizationPluginExtension +// task.buildOptimizationPluginExtension = +// buildOptimizationPluginExtension as BuildOptimizationPluginExtension // } } } diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt index 1f3aca0..6011238 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationPluginExtension.kt @@ -40,12 +40,15 @@ open class BuildOptimizationPluginExtension { "k", "K" -> Memory.Kilobyte(matchResult.groupValues[sizeGroupPosition].toLong()) "m", "M" -> Memory.Megabyte(matchResult.groupValues[sizeGroupPosition].toLong()) "g", "G" -> Memory.Gigabyte(matchResult.groupValues[sizeGroupPosition].toLong()) - else -> throw IllegalArgumentException("Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}") + else -> throw IllegalArgumentException( + "Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}" + ) } @Input @Optional var jvmXmx: String? = null + @Input @Optional var jvmXms: String? = null diff --git a/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt b/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt index afa971e..3b0e09e 100644 --- a/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt +++ b/src/main/java/se/eelde/buildOptimization/BuildOptimizationTask.kt @@ -3,8 +3,9 @@ package se.eelde.buildOptimization import org.gradle.api.DefaultTask import org.gradle.api.GradleException import org.gradle.api.internal.project.DefaultProject -import org.gradle.api.provider.Property -import org.gradle.api.tasks.* +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction import se.eelde.buildOptimization.evaluators.DaemonExecutionEvaluator import se.eelde.buildOptimization.evaluators.FileWatcherEvaluator import se.eelde.buildOptimization.evaluators.StartParameterEvaluator @@ -18,8 +19,8 @@ open class BuildOptimizationTask : DefaultTask() { @OutputFile val file: File = project.file("outputfile.txt") - //@Input - //val inputString: Property = project.objects.property(String::class.java).convention("default value") + // @Input + // val inputString: Property = project.objects.property(String::class.java).convention("default value") @TaskAction @Suppress("LongMethod", "ComplexMethod") @@ -29,7 +30,8 @@ open class BuildOptimizationTask : DefaultTask() { var optimizationsMissing = false - var buildOptimizationOutputter = BuildOptimizationOutputter(defaultProject = (project as DefaultProject), logger = project.logger) + var buildOptimizationOutputter = + BuildOptimizationOutputter(defaultProject = (project as DefaultProject), logger = project.logger) val fileWatcherEvaluator = FileWatcherEvaluator(project as DefaultProject) val fileSystemWatcherCheck = Check.FileSystemWatcher() diff --git a/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt b/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt index 40554d3..8f56bb0 100644 --- a/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt +++ b/src/main/java/se/eelde/buildOptimization/JvmArgsParser.kt @@ -4,12 +4,9 @@ import org.gradle.api.tasks.Input import java.nio.charset.Charset class JvmArgsParser { - private val xmxRegExp = - """.*-Xmx(\d*)([kKmMgG]).*""".toRegex() - private val xmsRegExp = - """.*-Xms(\d*)([kKmMgG]).*""".toRegex() - private val fileEncodingRegexp = - """.*-Dfile.encoding=([^\s.]*).*""".toRegex() + private val xmxRegExp = """.*-Xmx(\d*)([kKmMgG]).*""".toRegex() + private val xmsRegExp = """.*-Xms(\d*)([kKmMgG]).*""".toRegex() + private val fileEncodingRegexp = """.*-Dfile.encoding=([^\s.]*).*""".toRegex() fun parseJvmXmsMemory(jvmArgs: String): Memory { val matches = xmsRegExp.matchEntire(jvmArgs) @@ -20,7 +17,9 @@ class JvmArgsParser { "k", "K" -> Memory.Kilobyte(matchResult.groupValues[sizeGroupPosition].toLong()) "m", "M" -> Memory.Megabyte(matchResult.groupValues[sizeGroupPosition].toLong()) "g", "G" -> Memory.Gigabyte(matchResult.groupValues[sizeGroupPosition].toLong()) - else -> throw IllegalArgumentException("Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}") + else -> throw IllegalArgumentException( + "Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}" + ) } } } @@ -37,7 +36,9 @@ class JvmArgsParser { "k", "K" -> Memory.Kilobyte(matchResult.groupValues[sizeGroupPosition].toLong()) "m", "M" -> Memory.Megabyte(matchResult.groupValues[sizeGroupPosition].toLong()) "g", "G" -> Memory.Gigabyte(matchResult.groupValues[sizeGroupPosition].toLong()) - else -> throw IllegalArgumentException("Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}") + else -> throw IllegalArgumentException( + "Unable to parse ${matchResult.groupValues[sizeQuantifierGroupPosition]}" + ) } } } diff --git a/src/main/java/se/eelde/buildOptimization/evaluators/DaemonExecutionEvaluator.kt b/src/main/java/se/eelde/buildOptimization/evaluators/DaemonExecutionEvaluator.kt index bf0e920..00f3258 100644 --- a/src/main/java/se/eelde/buildOptimization/evaluators/DaemonExecutionEvaluator.kt +++ b/src/main/java/se/eelde/buildOptimization/evaluators/DaemonExecutionEvaluator.kt @@ -1,10 +1,8 @@ package se.eelde.buildOptimization.evaluators import org.gradle.api.internal.project.DefaultProject -import org.gradle.launcher.daemon.context.DaemonContext import org.gradle.launcher.daemon.server.health.DaemonMemoryStatus import org.gradle.launcher.daemon.server.scaninfo.DaemonScanInfo -import org.gradle.launcher.daemon.server.stats.DaemonRunningStats class DaemonExecutionEvaluator(private val project: DefaultProject) { private val daemonScanInfo: DaemonScanInfo? @@ -25,23 +23,23 @@ class DaemonExecutionEvaluator(private val project: DefaultProject) { return null } - private val daemonContext: DaemonContext? - get() { - try { - return project.services.get(DaemonContext::class.java) - } catch (ignored: Throwable) { - } - return null - } - - private val daemonRunningStats: DaemonRunningStats? - get() { - try { - return project.services.get(DaemonRunningStats::class.java) - } catch (ignored: Throwable) { - } - return null - } +// private val daemonContext: DaemonContext? +// get() { +// try { +// return project.services.get(DaemonContext::class.java) +// } catch (ignored: Throwable) { +// } +// return null +// } +// +// private val daemonRunningStats: DaemonRunningStats? +// get() { +// try { +// return project.services.get(DaemonRunningStats::class.java) +// } catch (ignored: Throwable) { +// } +// return null +// } val isSingleUse: Boolean get() { diff --git a/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt b/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt index 1b25f54..e6fe7f3 100644 --- a/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt +++ b/src/main/java/se/eelde/buildOptimization/evaluators/FileWatcherEvaluator.kt @@ -30,7 +30,7 @@ class FileWatcherEvaluator(private val project: DefaultProject) { WatchMode.DISABLED -> Result.NotWatching null -> Result.NotApplicable } - } else { + } else { Result.NotApplicable } } diff --git a/src/main/java/se/eelde/buildOptimization/evaluators/SemanticVersion.kt b/src/main/java/se/eelde/buildOptimization/evaluators/SemanticVersion.kt index 60dd494..a04a912 100644 --- a/src/main/java/se/eelde/buildOptimization/evaluators/SemanticVersion.kt +++ b/src/main/java/se/eelde/buildOptimization/evaluators/SemanticVersion.kt @@ -11,8 +11,7 @@ data class SemanticVersion( val buildMetadata: String? = null ) { fun compatibleWith(version: SemanticVersion): Boolean { - return major == version.major && - minor <= version.minor + return major == version.major && minor <= version.minor } companion object { diff --git a/src/test/java/se/eelde/buildOptimization/JvmArgsParserTest.kt b/src/test/java/se/eelde/buildOptimization/JvmArgsParserTest.kt index 76615d2..aaa89d1 100644 --- a/src/test/java/se/eelde/buildOptimization/JvmArgsParserTest.kt +++ b/src/test/java/se/eelde/buildOptimization/JvmArgsParserTest.kt @@ -20,7 +20,11 @@ class JvmArgsParserTest { assertThat(jvmArgParser.parseJvmXmxMemory("-Xmx2000m -Xms500m")).isEqualTo(Memory.Megabyte(2000)) assertThat(jvmArgParser.parseJvmXmsMemory("-Xmx2000m -Xms500m")).isEqualTo(Memory.Megabyte(500)) assertThat(jvmArgParser.parseJvmXmxMemory("a -Xmx2000m a")).isEqualTo(Memory.Megabyte(2000)) - assertThat(jvmArgParser.parseJvmXmxMemory("-Xmx2000m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=CRLF")).isEqualTo( + assertThat( + jvmArgParser.parseJvmXmxMemory( + "-Xmx2000m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=CRLF" + ) + ).isEqualTo( Memory.Megabyte(2000) ) } @@ -48,6 +52,12 @@ class JvmArgsParserTest { val jvmArgParser = JvmArgsParser() assertThat(jvmArgParser.parseFileEncoding("-Dfile.encoding=UTF-8")).isEqualTo(Charsets.UTF_8) assertThat(jvmArgParser.parseFileEncoding("a -Dfile.encoding=UTF-8 a")).isEqualTo(Charsets.UTF_8) - assertThat(jvmArgParser.parseFileEncoding("-Xmx2000m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8")).isEqualTo(Charsets.UTF_8) + assertThat( + jvmArgParser.parseFileEncoding( + "-Xmx2000m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" + ) + ).isEqualTo( + Charsets.UTF_8 + ) } } diff --git a/src/test/java/se/eelde/buildOptimization/ParseDslTest.kt b/src/test/java/se/eelde/buildOptimization/ParseDslTest.kt index 9eb3a61..a9ba7c9 100644 --- a/src/test/java/se/eelde/buildOptimization/ParseDslTest.kt +++ b/src/test/java/se/eelde/buildOptimization/ParseDslTest.kt @@ -39,7 +39,8 @@ internal class ParseDslTest { val project = ProjectBuilder.builder().withProjectDir(testProjectDir).build() (project as DefaultProject).evaluate() - val buildOptimizationPlugin = project.plugins.getPlugin(BuildOptimizationPlugin::class.java) as BuildOptimizationPlugin + val buildOptimizationPlugin = + project.plugins.getPlugin(BuildOptimizationPlugin::class.java) as BuildOptimizationPlugin val buildOptimizationPluginExtension = buildOptimizationPlugin.buildOptimizationPluginExtension!! assertThat(buildOptimizationPluginExtension.jvmXmx).isEqualTo("4GB")