Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrimaeon committed Jan 11, 2022
2 parents c0ddd81 + e4e86b9 commit 78be93a
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: chrimaeon/github-create-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Add the processor and annotation libraries to the projects dependencies

```kotlin
dependencies {
implementation("com.cmgapps:log-tag:1.0.0")
ksp("com.cmgapps:log-tag-processor:1.0.0")
implementation("com.cmgapps:log-tag:1.1.0")
ksp("com.cmgapps:log-tag-processor:1.1.0")
}
```

also get sure to apply the KSP Gradle Plugin

```kotlin
plugins {
id("com.google.devtools.ksp") version "<latest version>"
id("com.google.devtools.ksp") version "1.1.0"
}
```

Expand All @@ -42,8 +42,8 @@ Add the processor and annotation libraries to the projects dependencies

```kotlin
dependencies {
implementation("com.cmgapps:log-tag:1.0.0")
kapt("com.cmgapps:log-tag-processor:1.0.0")
implementation("com.cmgapps:log-tag:1.1.0")
kapt("com.cmgapps:log-tag-processor:1.1.0")
}
```

Expand Down
4 changes: 2 additions & 2 deletions annotation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ publishing {
publications {
create<MavenPublication>("annotation") {
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
artifact(sourcesJar)
artifact(javadocJar)

logtagPom(project)
}
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fun DependencyHandlerScope.addLinterDependencies() {
kapt(autoService)

junit()
testImplementation("org.hamcrest:hamcrest".withVersion())
testImplementation("com.android.tools.lint:lint".withVersion())
testImplementation("com.android.tools.lint:lint-tests".withVersion())
testImplementation("com.android.tools:testutils".withVersion())
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ kapt.use.worker.api=true
kapt.incremental.apt=true
kapt.include.compile.classpath=false
group=com.cmgapps.logtag
versionName=1.0.0
versionName=1.1.0
connectionUrl=scm:git:git://github.com:chrimaeon/logtag-kapt.git
developerConnectionUrl=scm:git:git://github.com:chrimaeon/logtag-kapt.git
scmUrl=https://github.com:chrimaeon/logtag-kapt.git
projectUrl=https://github.com/chrimaeon/logtag-kapt
issuesTrackerUrl=https://github.com/chrimaeon/logtag-kapt/issues

1 change: 1 addition & 0 deletions library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is an android library providing a lint rule
15 changes: 7 additions & 8 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ plugins {
}

android {
compileSdkVersion(30)
compileSdk = 30
defaultConfig {
minSdkVersion(15)
targetSdkVersion(30)
minSdk = 15
targetSdk = 30
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -50,24 +50,23 @@ project.version = versionName
val name: String by project
val description: String by project

val annotationProject = project(":annotation")
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(annotationProject.sourceSets["main"].allSource)
from(projectDir.resolve("README.md"))
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(annotationProject.tasks["javadoc"])
from(projectDir.resolve("README.md"))
}

afterEvaluate {
publishing {
publications {
register<MavenPublication>("libraryMaven") {
from(components["release"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
artifact(sourcesJar)
artifact(javadocJar)
logtagPom(project)
}
}
Expand Down
40 changes: 40 additions & 0 deletions linter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.div

plugins {
kotlin("jvm")
Expand All @@ -24,6 +26,15 @@ plugins {
id("org.jetbrains.dokka") version "org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin".version()
}

@OptIn(ExperimentalPathApi::class)
val buildConfigDirPath = buildDir.toPath() / "generated" / "source" / "buildConfig"

sourceSets {
main {
java.srcDir(buildConfigDirPath)
}
}

tasks {
test {
useJUnitPlatform()
Expand All @@ -32,10 +43,39 @@ tasks {
}
}

val generateBuildConfig by registering {
val outputDir = buildConfigDirPath

val projectArtifactId = "log-tag"
inputs.property("projectArtifactId", projectArtifactId)

val issuesTrackerUrl: String by project
inputs.property("issuesTrackerUrl", issuesTrackerUrl)

val packageName = "com.cmgapps.lint"
inputs.property("packageName", packageName)

outputs.dir(outputDir)

doLast {
outputDir.toFile().mkdirs()
file(outputDir.resolve("BuildConfig.kt")).bufferedWriter().use {
it.write(
"""
|package $packageName
|const val ISSUES_TRACKER_URL = "$issuesTrackerUrl"
|const val PROJECT_ARTIFACT = "$projectArtifactId"
""".trimMargin()
)
}
}
}

withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
dependsOn(generateBuildConfig)
}

jar {
Expand Down
9 changes: 7 additions & 2 deletions linter/src/main/kotlin/com/cmgapps/lint/IssueRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
package com.cmgapps.lint

import com.android.tools.lint.client.api.IssueRegistry
import com.android.tools.lint.client.api.Vendor
import com.android.tools.lint.detector.api.CURRENT_API
import com.android.tools.lint.detector.api.Issue
import com.google.auto.service.AutoService

@Suppress("UnstableApiUsage")
@AutoService(IssueRegistry::class)
class IssueRegistry : IssueRegistry() {

override val api = CURRENT_API

override val issues: List<Issue> = listOf(LogTagDetector.ISSUE)
override val vendor = Vendor(
vendorName = "CMG Mobile Apps",
identifier = PROJECT_ARTIFACT,
feedbackUrl = ISSUES_TRACKER_URL,
contact = ISSUES_TRACKER_URL,
)
}
62 changes: 62 additions & 0 deletions linter/src/test/kotlin/com/cmgapps/lint/IssueRegistryShould.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2022. Christian Grach <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cmgapps.lint

import com.android.tools.lint.client.api.LintClient
import com.android.tools.lint.detector.api.CURRENT_API
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.hasProperty
import org.hamcrest.Matchers.`is`
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

internal class IssueRegistryShould {

private lateinit var registry: IssueRegistry

@Suppress("UnstableApiUsage")
@BeforeEach
fun setUp() {
LintClient.clientName = LintClient.CLIENT_UNIT_TESTS
registry = IssueRegistry()
}

@Test
fun `have API version`() {
assertThat(registry.api, `is`(CURRENT_API))
}

@Test
fun `have issues registered`() {
assertThat(registry.issues, contains(LogTagDetector.ISSUE))
}

@Test
fun `have a vendor`() {
assertThat(
registry.vendor,
allOf(
hasProperty("vendorName", `is`("CMG Mobile Apps")),
hasProperty("identifier", `is`("log-tag")),
hasProperty("feedbackUrl", `is`("https://github.com/chrimaeon/logtag-kapt/issues")),
hasProperty("contact", `is`("https://github.com/chrimaeon/logtag-kapt/issues"))
)
)
}
}
4 changes: 2 additions & 2 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ publishing {
create<MavenPublication>("processor") {

from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
artifact(sourcesJar)
artifact(javadocJar)

logtagPom(project)
}
Expand Down

0 comments on commit 78be93a

Please sign in to comment.