Skip to content
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

Example in Kotlin dsl #30

Open
kittinunf opened this issue Aug 12, 2018 · 9 comments
Open

Example in Kotlin dsl #30

kittinunf opened this issue Aug 12, 2018 · 9 comments

Comments

@kittinunf
Copy link

Do you have some example on how to use version 1.0.0 with Kotlin dsl? Basically, anything like the consumer folder with Kotlin dsl should be really nice.

@StefMa
Copy link
Owner

StefMa commented Aug 12, 2018 via email

@kittinunf
Copy link
Author

kittinunf commented Aug 13, 2018

Yes, I think i did follow your document but there is an error when sync.

The error looks something like this

* What went wrong:
An exception occurred applying plugin request [id: 'guru.stefma.artifactorypublish']
> Failed to apply plugin [class 'guru.stefma.androidartifacts.AndroidArtifactsPlugin']
   > Extension of type 'LibraryExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, KtlintExtension, KotlinJvmProjectExtension, KaptExtension, DefaultArtifactPublicationSet, ReportingExtension, JUnitPlatformExtension, JacocoPluginExtension, AndroidArtifactsExtension, PublishingExtension]

CONFIGURE FAILED in 1s
Extension of type 'LibraryExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, KtlintExtension, KotlinJvmProjectExtension, KaptExtension, DefaultArtifactPublicationSet, ReportingExtension, JUnitPlatformExtension, JacocoPluginExtension, AndroidArtifactsExtension, PublishingExtension]

The example of my build.gradle.kts is (excerpt only relevant part)

plugins {
    kotlin("jvm")

    id("org.junit.platform.gradle.plugin")
    jacoco

    id("guru.stefma.artifactorypublish")
}

val artifactVersion: String by extra

version = artifactVersion
group = Publishings.groupId
configure<ArtifactoryPublishExtension> {
    artifactId = project.name
    artifactoryUrl = "foo"
    artifactoryRepo = "bar"
}

@StefMa
Copy link
Owner

StefMa commented Aug 13, 2018

You are running in an case which is not supported by this plugin currently.
The ArtifactoryPublish (which based on the AndroidArtifacts plugin) is mainly designed to work in the Android Environment.

Anyway.
In Version 1.1.0 I bring java support back to this plugin.
The only thing you have to do is to apply the java-library plugin first:

plugins {
    kotlin("jvm")

    id("org.junit.platform.gradle.plugin")
    jacoco

    `java-library`
    id("guru.stefma.artifactorypublish") apply false
}
apply(plugin = guru.stefma.artifactorypublish)

val artifactVersion: String by extra

version = artifactVersion
group = Publishings.groupId
configure<ArtifactoryPublishExtension> {
    artifactId = project.name
    artifactoryUrl = "foo"
    artifactoryRepo = "bar"
    publications = arrayOf("maven")
}

This should work for you 👆

@kittinunf
Copy link
Author

Ah, thanks that make a lot of sense because the error is only happening on non-android modules only.

I will change my build.gradle.kts to something that you suggested.

@kittinunf
Copy link
Author

kittinunf commented Aug 13, 2018

@StefMa Thanks I think it works! Just for the sake of reference, for Kotlin dsl user for Android module, it should look something like this.

plugins {
    id("com.android.library")
    kotlin("android")
    id("guru.stefma.artifactorypublish")
}

version = "0.1.0"
group = "group"

configure<ArtifactoryPublishExtension> {
    artifactId = project.name
    artifactoryUrl = "foo"
    artifactoryRepo = "bar"
    publications = arrayOf("releaseAar")
}

tasks.withType<Javadoc>().all {
    enabled = false
}

For Kotlin dsl plain jar module;

plugins {
    kotlin("jvm")
    `java-library`
    id("guru.stefma.artifactorypublish")
}

version = "0.1.0"
group = "group"

configure<ArtifactoryPublishExtension> {
    artifactId = project.name
    artifactoryUrl = "foo"
    artifactoryRepo = "bar"
    publications = arrayOf("maven")
}

tasks.withType<Javadoc>().all {
    enabled = false
}

Thanks again, for pointing me to the right direction and your 1.1.0 release. ❤️

@StefMa
Copy link
Owner

StefMa commented Aug 13, 2018

You're welcome.
Nice that it works for you 🎉

Any reasons why you have disabled all Javadoc tasks? 🤔

@kittinunf
Copy link
Author

I don't want to ... but it looks like without that it would fail with an error something like this.

javadoc: error - Illegal package name

Kinda similar to the novoda plugin 🤔? I am wondering this is the same issue novoda/bintray-release#71

@kittinunf
Copy link
Author

I am closing this!

@StefMa StefMa reopened this Aug 27, 2018
@StefMa
Copy link
Owner

StefMa commented Aug 27, 2018

Just reopened as a reminder for myself 🙃

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

No branches or pull requests

2 participants