Skip to content

Commit

Permalink
Merge pull request #4 from StylianosGakis/stylianos/renamable-publica…
Browse files Browse the repository at this point in the history
…tion-name

Allow the publication name to be altered from the extension
  • Loading branch information
martinbonnin authored Mar 30, 2024
2 parents e3c02f0 + 9a67540 commit 0b27677
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/kotlin/nmcp/NmcpAggregation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class NmcpAggregation(
val username: Property<String>,
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
) {
fun project(path: String) {
project.dependencies.add(configuration.name, project.dependencies.project(mapOf("path" to path)))
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/nmcp/NmcpExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class NmcpExtension(private val project: Project) {
it.username.set(spec.username)
it.password.set(spec.password)
it.publicationType.set(spec.publicationType)
it.publicationName.set(spec.publicationName.orElse("${project.name}-${project.version}.zip"))
}

publishAllPublicationsToCentralPortal.configure {
Expand All @@ -86,6 +87,7 @@ class NmcpExtension(private val project: 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),
)
action.execute(spec)

Expand Down Expand Up @@ -141,6 +143,7 @@ class NmcpExtension(private val project: 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),
)

action.execute(aggregation)
Expand All @@ -164,6 +167,7 @@ class NmcpExtension(private val project: Project) {
it.username.set(aggregation.username)
it.password.set(aggregation.password)
it.publicationType.set(aggregation.publicationType)
it.publicationName.set(aggregation.publicationName)
}
}

Expand All @@ -180,6 +184,7 @@ class NmcpExtension(private val project: 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),
)
action.execute(spec)

Expand All @@ -199,6 +204,7 @@ class NmcpExtension(private val project: Project) {
aggregation.username.set(spec.username)
aggregation.password.set(spec.password)
aggregation.publicationType.set(spec.publicationType)
aggregation.publicationName.set(spec.publicationName)
}
}
}
5 changes: 4 additions & 1 deletion src/main/kotlin/nmcp/NmcpPublishTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ abstract class NmcpPublishTask : DefaultTask() {
@get:Optional
abstract val publicationType: Property<String>

@get:Input
abstract val publicationName: Property<String>

@TaskAction
fun taskAction() {
val username = username.get()
Expand All @@ -48,7 +51,7 @@ abstract class NmcpPublishTask : DefaultTask() {
val body = MultipartBody.Builder()
.addFormDataPart(
"bundle",
"publication.zip",
publicationName.get(),
inputFile.get().asFile.asRequestBody("application/zip".toMediaType())
)
.build()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/nmcp/NmcpSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class NmcpSpec(
val username: Property<String>,
val password: Property<String>,
val publicationType: Property<String>,
val publicationName: Property<String>,
)

0 comments on commit 0b27677

Please sign in to comment.