Skip to content

Commit

Permalink
KSP Migration (#35)
Browse files Browse the repository at this point in the history
* Start migrating to build.gradle.kts; create ksp module

* Get ksp to running-but-failing-in-tests state

* Reimplement source code analysis for KSP

* Fix basic activity generation

* Re-add fragment, service, and stub support

* Remove kapt implementation

* Fix Robolectric warning; suppress unused warnings in stubs

* Allow source level opt-in; switch to kotlin-parcelize plugin

* Update config/ci to be closer to other juul oss repos

* Add gradlePluginPortal() for org.jetbrains.trove4j:trove4j:20160824

* Fix Kotlinter issues

* More fixes in ci and gradle scripts

* Generate params class with @AsStub instead of @FromStub

This was done to solve issues with stubs across multiple modules. KSP
was not properly carrying annotation arguments across the module
boundary (that is, even though we could see annotations on the stub
class, @Exercise.params was artificially empty).

* Update KSP to alpha 6 and small cleanups
  • Loading branch information
cedrickcooke committed Mar 25, 2021
1 parent ecf4879 commit 1255e06
Show file tree
Hide file tree
Showing 91 changed files with 1,256 additions and 1,192 deletions.
8 changes: 8 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://github.com/release-drafter/release-drafter#configuration-options

exclude-labels:
- 'skip-changelog'

change-template: '- $TITLE (#$NUMBER)'

template: $CHANGES
55 changes: 12 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# Each virtual machine has the same hardware resources available.
#
# - 2-core CPU
# - 7 GB of RAM memory
# - 14 GB of SSD disk space
#
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners

name: CI
on: push

env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}
on:
push:

jobs:
build:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04

env:
GRADLE_ARGS: >-
--stacktrace
--no-daemon
--no-parallel
--max-workers 2
-Pkotlin.incremental=false
Expand All @@ -39,8 +27,14 @@ jobs:
- name: Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle
key: grade-${{ hashFiles('**/build.gradle') }}
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-build-${{ hashFiles('**/build.gradle.kts') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: Check
run: ./gradlew $GRADLE_ARGS check jacocoTestReport
Expand All @@ -49,28 +43,3 @@ jobs:
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true

- name: Snapshot
if: github.ref == 'refs/heads/master'
run: >-
./gradlew
$GRADLE_ARGS
uploadArchives
-PVERSION_NAME=master-SNAPSHOT
- name: Keyring
if: startsWith(github.ref, 'refs/tags/')
run: echo "${{ secrets.SIGNING_SECRET_KEY_RING }}" | base64 --decode > ~/secring.gpg

- name: Publish
# https://gitpro.ttaallkk.topmunity/t5/GitHub-Actions/Run-step-only-for-new-tags/m-p/32448/highlight/true#M1138
if: startsWith(github.ref, 'refs/tags/')
# https://gitpro.ttaallkk.topmunity/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
run: >-
./gradlew
$GRADLE_ARGS
uploadArchives
-PVERSION_NAME=${GITHUB_REF/refs\/tags\//}
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}"
-Psigning.password="${{ secrets.SIGNING_PASSWORD }}"
-Psigning.secretKeyRingFile="$HOME/secring.gpg"
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish
on:
release:
types:
- published

jobs:
publish:
runs-on: ubuntu-18.04

env:
GRADLE_ARGS: >-
--no-daemon
--max-workers 2
-Pkotlin.incremental=false
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Gradle cache
uses: actions/cache@v1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-publish-${{ hashFiles('**/build.gradle.kts') }}
restore-keys: |
${{ runner.os }}-publish-
${{ runner.os }}-
- name: Check
run: ./gradlew $GRADLE_ARGS check

- name: Keyring
run: echo "${{ secrets.SIGNING_SECRET_KEY_RING }}" | base64 --decode > ~/secring.gpg

- name: Publish
env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}
run: >-
./gradlew
$GRADLE_ARGS
--no-parallel
-PVERSION_NAME=${GITHUB_REF/refs\/tags\//}
-Psigning.keyId="${{ secrets.SIGNING_KEY_ID }}"
-Psigning.password="${{ secrets.SIGNING_PASSWORD }}"
-Psigning.secretKeyRingFile="$HOME/secring.gpg"
uploadArchives
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release Drafter
# https://github.com/release-drafter/release-drafter#usage

on:
push:
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Snapshot
on:
push:
branches:
- main

jobs:
snapshot:
runs-on: ubuntu-18.04

env:
GRADLE_ARGS: >-
--no-daemon
--max-workers 2
-Pkotlin.incremental=false
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-snapshot-${{ hashFiles('**/build.gradle.kts') }}
restore-keys: |
${{ runner.os }}-snapshot-
${{ runner.os }}-
- name: Check
run: ./gradlew $GRADLE_ARGS check

- name: Snapshot
env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}
run: >-
./gradlew
$GRADLE_ARGS
--no-parallel
-PVERSION_NAME=main-SNAPSHOT
uploadArchives
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/*
/.idea
.DS_Store
/build
build/
/captures
.externalNativeBuild
.cxx
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Exercise

Exercise is an annotation processor for Kotlin Android projects.
Exercise is an kotlin symbol processor for Android projects.
Exercise makes it possible to pass intent extras easily and correctly.

# Getting started
Expand All @@ -13,13 +13,13 @@ First, add it to gradle.

```gradle
repositories {
jcenter() // or mavenCentral()
mavenCentral()
}
dependencies {
implementation "com.juul.exercise:annotations:$version"
implementation "com.juul.exercise:runtime:$version"
kapt "com.juul.exercise:compile:$version"
ksp "com.juul.exercise:compile:$version"
}
```

Expand Down Expand Up @@ -157,7 +157,7 @@ repositories {
dependencies {
implementation "com.juul.exercise:annotations:master-SNAPSHOT"
implementation "com.juul.exercise:runtime:master-SNAPSHOT"
kapt "com.juul.exercise:compile:master-SNAPSHOT"
ksp "com.juul.exercise:compile:master-SNAPSHOT"
}
```

Expand Down
1 change: 0 additions & 1 deletion annotations/.gitignore

This file was deleted.

30 changes: 30 additions & 0 deletions annotations/api/annotations.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public abstract interface annotation class com/juul/exercise/annotations/AsStub : java/lang/annotation/Annotation {
public abstract fun className ()Ljava/lang/String;
public abstract fun packageName ()Ljava/lang/String;
}

public abstract interface annotation class com/juul/exercise/annotations/Exercise : java/lang/annotation/Annotation {
public abstract fun params ()[Lcom/juul/exercise/annotations/ExerciseParameter;
}

public abstract interface annotation class com/juul/exercise/annotations/ExerciseParameter : java/lang/annotation/Annotation {
public abstract fun name ()Ljava/lang/String;
public abstract fun optional ()Z
public abstract fun parceler ()Ljava/lang/Class;
public abstract fun type ()Ljava/lang/Class;
public abstract fun typeArguments ()[Ljava/lang/Class;
}

public abstract interface annotation class com/juul/exercise/annotations/FromStub : java/lang/annotation/Annotation {
public abstract fun source ()Ljava/lang/Class;
}

public abstract interface annotation class com/juul/exercise/annotations/ResultContract : java/lang/annotation/Annotation {
public abstract fun kinds ()[Lcom/juul/exercise/annotations/ResultKind;
}

public abstract interface annotation class com/juul/exercise/annotations/ResultKind : java/lang/annotation/Annotation {
public abstract fun name ()Ljava/lang/String;
public abstract fun params ()[Lcom/juul/exercise/annotations/ExerciseParameter;
}

22 changes: 0 additions & 22 deletions annotations/build.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
kotlin("jvm")
id("org.jmailen.kotlinter")
jacoco
id("com.vanniktech.maven.publish")
}

apply(from = rootProject.file("gradle/jacoco.gradle.kts"))
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ import kotlin.reflect.KClass
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
annotation class FromStub(val source: KClass<*>)

29 changes: 0 additions & 29 deletions build.gradle

This file was deleted.

Loading

0 comments on commit 1255e06

Please sign in to comment.