tschuchortdev / kotlin-compile-testing

A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Mozilla Public License 2.0
662 stars 63 forks source link

new release with KSP support #52

Closed yigit closed 4 years ago

yigit commented 4 years ago

Hi, I want to pull this into AndroidX. Is it possible to ship a release w/ the KSP artifact?

Lmk if I can help w/ that.

Thanks!

tschuchortdev commented 4 years ago

Sure, I will try to do it today.

Lmk if I can help w/ that.

If you know how to automate it, that would be very helpful. Right now I have to do it manually on the Sonatype Nexus website which is unresponsive like 80% of the time.

tschuchortdev commented 4 years ago

I tried releasing it in the usual way but that doesn't seem to work:

Do you have an idea how to solve these problems? Perhaps it would be better not to use a Gradle composite build or somehow configure it differently. How much work would that entail?

yigit commented 4 years ago

hmm, 2) should work. It is OK to depend on 1.3.72 from 1.4-M1. Dependency should be included in the maven pom which will make gradle pull the main artifact as well.

1) Maybe i messed it up but I think I've tried installLocal to see if artifacts are built. I'll double check.

I'll see if I can make the whole gradle maven-publish plugin work though they have all new Publishing plugin so maybe the old one doesn't support composite builds properly. Anyways, I'm hopeful I'll be able to figure it out.

Will give it a try and let you know how it goes.

tschuchortdev commented 4 years ago

It is OK to depend on 1.3.72 from 1.4-M1

Why is that not problematic?

Dependency should be included in the maven pom which will make gradle pull the main artifact as well.

So it is not necessary to depend on both explicitly as a user?

though they have all new Publishing plugin

Can you link it? When I last checked I only found https://github.com/vanniktech/gradle-maven-publish-plugin which is not maintained very well.

I think the problem with composite build might be that the included build is a subdirectory of the main build, but perhaps they have to be sibling directories. I will try moving the core library into a submodule of the project (this has to be done in the future anyway), maybe it will work then.

yigit commented 4 years ago

It is OK to depend on 1.3.72 from 1.4-M1

Why is that not problematic?

1.4 compiler can parse 1.3 code, it is just that 1.3 compiler cannot parse 1.4. Basically you cannot depend on anything that was compiled with a newer version. That being said, afaik, it is a limitation until 1.4 ships but I'm not 100% sure on that.

Dependency should be included in the maven pom which will make gradle pull the main artifact as well.

So it is not necessary to depend on both explicitly as a user?

No, it is not necessary. I've verified this locally with my new setup. I can update the readme to remove it.

though they have all new Publishing plugin

Can you link it? When I last checked I only found https://github.com/vanniktech/gradle-maven-publish-plugin which is not maintained very well.

I was referring to the publish plugin in gradle, i didn't notice you were using a 3rd party plugin. This is the "new" stuff i was referring to: https://docs.gradle.org/current/userguide/publishing_maven.html

I think the problem with composite build might be that the included build is a subdirectory of the main build, but perhaps they have to be sibling directories. I will try moving the core library into a submodule of the project (this has to be done in the future anyway), maybe it will work then.

I've fixed and locally verified it. (I just forgot to specify an ARTIFACT_ID for KSP).

You still need to run publish twice in both folders.

This is what I've done:

cd <checkout>
./gradlew installArchives #installs main module
cd ksp
./gradlew installArchives #installs the ksp module

Here is the pom generated for the KSP module: https://gist.github.com/yigit/ee9f2fa0a236083ee7e30cfbbf037e39

After publishing artifacts locally, this is how my test gradle file looks like:

repositories {
    maven("https://dl.bintray.com/kotlin/kotlin-eap")
    mavenCentral()
    mavenLocal()
    maven("https://dl.bintray.com/kotlin/kotlin-eap")
    google()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    testImplementation("com.github.tschuchortdev:kotlin-compile-testing-ksp:1.2.8")
    testImplementation("junit:junit:4.12")
    testImplementation("org.jetbrains.kotlin:kotlin-symbol-processing-api:1.4-M1-dev-experimental-20200626")
}
tschuchortdev commented 4 years ago

Your changes in #53 seem to have worked. I have just released com.github.tschuchortdev:kotlin-compile-testing-ksp:1.2.9. Let me know if it works, then I'll update the README and upload the release to Github as well.

yigit commented 4 years ago

yep, looks good; thanks!