Skip to content

Add API to configure Gradle extensions #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mhalbritter opened this issue May 21, 2024 · 1 comment
Closed

Add API to configure Gradle extensions #1530

mhalbritter opened this issue May 21, 2024 · 1 comment
Assignees
Milestone

Comments

@mhalbritter
Copy link
Contributor

mhalbritter commented May 21, 2024

While looking at #1495 i noticed that there's currently no nice option to configure Gradle extensions.

This

kotlin {
	compilerOptions {
		jvmTarget = JvmTarget.JVM_1_8
		freeCompilerArgs += '-Xjsr305=strict'
	}
}

requires fiddling with GradleBuild.snippets() and manually constructing the coirrect syntax. It would be nice if GradleBuild could offer an API to to do that more nicely.

Maybe something like this?

build.extensions().customize("kotlin", (kotlin) -> kotlin.nested("compilerOptions", (compilerOptions) -> {
  compilerOptions.attributeWithType("jvmTarget", getJvmTarget(), "org.jetbrains.kotlin.gradle.dsl.JvmTarget");
  if (!CollectionUtils.isEmpty(this.settings.getCompilerArgs())) {
    compilerOptions.invoke("freeCompilerArgs.addAll", quote(this.settings.getCompilerArgs()));
  }
}));
@mhalbritter
Copy link
Contributor Author

We also need to move Invocation and Attribute to top-level types and so some deprecation dance and inheritance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant