Skip to content

Commit

Permalink
Merge pull request #11 from GradleUp/fix-groovy-interrop
Browse files Browse the repository at this point in the history
Fix groovy interrop
  • Loading branch information
martinbonnin authored Jun 1, 2024
2 parents 32a690f + 8e8870b commit ddbc878
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 38 deletions.
15 changes: 9 additions & 6 deletions src/main/kotlin/nmcp/NmcpAggregation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package nmcp
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.provider.Property
import javax.inject.Inject

class NmcpAggregation(

abstract class NmcpAggregation @Inject constructor(
private val configuration: Configuration,
private val project: Project,
val username: Property<String>,
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
val endpoint: Property<String>,
) {
abstract val username: Property<String>
abstract val password: Property<String>
abstract val publicationType: Property<String>
abstract val publicationName: Property<String>
abstract val endpoint: Property<String>

fun project(path: String) {
project.dependencies.add(configuration.name, project.dependencies.project(mapOf("path" to path)))
}
Expand Down
28 changes: 4 additions & 24 deletions src/main/kotlin/nmcp/NmcpExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.gradle.api.publish.PublishingExtension
import org.gradle.api.tasks.bundling.Zip
import org.gradle.configurationcache.extensions.capitalized

class NmcpExtension(private val project: Project) {
open class NmcpExtension(private val project: Project) {
private var mavenPublishFound = false
private val publishAllPublicationsToCentralPortal = project.tasks.register("publishAllPublicationsToCentralPortal")

Expand Down Expand Up @@ -84,13 +84,7 @@ class NmcpExtension(private val project: Project) {
}

private fun publishInternal(publicationName: String?, action: Action<NmcpSpec>) {
val spec = NmcpSpec(
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)
val spec = project.objects.newInstance(NmcpSpec::class.java)
action.execute(spec)

project.plugins.withId("maven-publish") {
Expand Down Expand Up @@ -139,15 +133,7 @@ class NmcpExtension(private val project: Project) {
it.configureAttributes(project)
}

val aggregation = NmcpAggregation(
configuration,
project,
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)
val aggregation = project.objects.newInstance(NmcpAggregation::class.java, configuration, project)

action.execute(aggregation)

Expand Down Expand Up @@ -184,13 +170,7 @@ class NmcpExtension(private val project: Project) {
"publishAllProjectsProbablyBreakingProjectIsolation() must be called from root project"
}

val spec = NmcpSpec(
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
project.objects.property(String::class.java),
)
val spec = project.objects.newInstance(NmcpSpec::class.java)
action.execute(spec)

publishAggregation { aggregation ->
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/nmcp/NmcpPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ class NmcpPlugin: Plugin<Project> {

it.configureAttributes(target)
}
target.extensions.add("nmcp", NmcpExtension(target))
target.extensions.create("nmcp", NmcpExtension::class.java, target)
}
}
14 changes: 7 additions & 7 deletions src/main/kotlin/nmcp/NmcpSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package nmcp

import org.gradle.api.provider.Property

class NmcpSpec(
val username: Property<String>,
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
val endpoint: Property<String>,
)
abstract class NmcpSpec {
abstract val username: Property<String>
abstract val password: Property<String>
abstract val publicationType: Property<String>
abstract val publicationName: Property<String>
abstract val endpoint: Property<String>
}

0 comments on commit ddbc878

Please sign in to comment.