Skip to content

Commit

Permalink
feat: move "constants" to a separate object
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrMilchmann committed Mar 6, 2023
1 parent 8bf43c3 commit 61fa439
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 26 deletions.
18 changes: 11 additions & 7 deletions api/gradle-ecj.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
public final class io/github/themrmilchmann/gradle/ecj/ECJConstants {
public static final field INSTANCE Lio/github/themrmilchmann/gradle/ecj/ECJConstants;
public final fun getDEFAULT_DEPENDENCY_ARTIFACT ()Ljava/lang/String;
public final fun getDEFAULT_DEPENDENCY_GROUP ()Ljava/lang/String;
public final fun getDEFAULT_DEPENDENCY_VERSION ()Ljava/lang/String;
public final fun getECJ_CONFIGURATION_NAME ()Ljava/lang/String;
public final fun getMAIN ()Ljava/lang/String;
public final fun getPREFERRED_JAVA_VERSION ()I
public final fun getREQUIRED_JAVA_VERSION ()I
}

public abstract class io/github/themrmilchmann/gradle/ecj/ECJExtension {
public fun <init> (Lorg/gradle/api/model/ObjectFactory;)V
public final fun getCompilerArtifactId ()Lorg/gradle/api/provider/Property;
Expand All @@ -6,13 +17,6 @@ public abstract class io/github/themrmilchmann/gradle/ecj/ECJExtension {
}

public final class io/github/themrmilchmann/gradle/ecj/plugins/ECJPlugin : org/gradle/api/Plugin {
public static final field DEFAULT_DEPENDENCY_ARTIFACT Ljava/lang/String;
public static final field DEFAULT_DEPENDENCY_GROUP Ljava/lang/String;
public static final field DEFAULT_DEPENDENCY_VERSION Ljava/lang/String;
public static final field ECJ_CONFIGURATION_NAME Ljava/lang/String;
public static final field MAIN Ljava/lang/String;
public static final field PREFERRED_JAVA_VERSION I
public static final field REQUIRED_JAVA_VERSION I
public fun <init> ()V
public synthetic fun apply (Ljava/lang/Object;)V
public fun apply (Lorg/gradle/api/Project;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2022-2023 Leon Linhart
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.github.themrmilchmann.gradle.ecj

@Suppress("MayBeConstant")
public object ECJConstants {

public val ECJ_CONFIGURATION_NAME: String = "ecj"

public val DEFAULT_DEPENDENCY_GROUP: String = "org.eclipse.jdt"
public val DEFAULT_DEPENDENCY_ARTIFACT: String = "ecj"
public val DEFAULT_DEPENDENCY_VERSION: String = "3.32.0"

public val MAIN: String = "org.eclipse.jdt.internal.compiler.batch.Main"

/* The version for which a toolchain is requested if the project's toolchain is not compatible. */
public val PREFERRED_JAVA_VERSION: Int = 17

/* The version required to run ECJ. */
public val REQUIRED_JAVA_VERSION: Int = 11

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
*/
package io.github.themrmilchmann.gradle.ecj

import io.github.themrmilchmann.gradle.ecj.plugins.ECJPlugin
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import javax.inject.Inject

public abstract class ECJExtension @Inject constructor(objects: ObjectFactory) {

public val compilerGroupId: Property<String> = objects.property(String::class.java).convention(ECJPlugin.DEFAULT_DEPENDENCY_GROUP)
public val compilerArtifactId: Property<String> = objects.property(String::class.java).convention(ECJPlugin.DEFAULT_DEPENDENCY_ARTIFACT)
public val compilerVersion: Property<String> = objects.property(String::class.java).convention(ECJPlugin.DEFAULT_DEPENDENCY_VERSION)
public val compilerGroupId: Property<String> = objects.property(String::class.java).convention(ECJConstants.DEFAULT_DEPENDENCY_GROUP)
public val compilerArtifactId: Property<String> = objects.property(String::class.java).convention(ECJConstants.DEFAULT_DEPENDENCY_ARTIFACT)
public val compilerVersion: Property<String> = objects.property(String::class.java).convention(ECJConstants.DEFAULT_DEPENDENCY_VERSION)

init {
compilerGroupId.finalizeValueOnRead()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
*/
package io.github.themrmilchmann.gradle.ecj.plugins

import io.github.themrmilchmann.gradle.ecj.ECJConstants.ECJ_CONFIGURATION_NAME
import io.github.themrmilchmann.gradle.ecj.ECJConstants.MAIN
import io.github.themrmilchmann.gradle.ecj.ECJConstants.PREFERRED_JAVA_VERSION
import io.github.themrmilchmann.gradle.ecj.ECJConstants.REQUIRED_JAVA_VERSION
import io.github.themrmilchmann.gradle.ecj.ECJExtension
import io.github.themrmilchmann.gradle.ecj.internal.utils.*
import org.gradle.api.*
Expand All @@ -34,21 +38,7 @@ import org.gradle.util.GradleVersion

public class ECJPlugin : Plugin<Project> {

internal companion object {

const val ECJ_CONFIGURATION_NAME = "ecj"

const val DEFAULT_DEPENDENCY_GROUP = "org.eclipse.jdt"
const val DEFAULT_DEPENDENCY_ARTIFACT = "ecj"
const val DEFAULT_DEPENDENCY_VERSION = "3.32.0"

const val MAIN = "org.eclipse.jdt.internal.compiler.batch.Main"

/* The version for which a toolchain is requested if the project's toolchain is not compatible. */
const val PREFERRED_JAVA_VERSION = 17

/* The version required to run ECJ. */
const val REQUIRED_JAVA_VERSION = 11
private companion object {

private val GRADLE_8_0 = GradleVersion.version("8.0")

Expand Down

0 comments on commit 61fa439

Please sign in to comment.