Skip to content

Commit

Permalink
Configure publishing. Rename modules to compiler and annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaGulya committed Mar 21, 2024
1 parent 09eb939 commit 54876f2
Show file tree
Hide file tree
Showing 22 changed files with 308 additions and 54 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish snapshot

on:
workflow_dispatch:
push:
branches:
- master

jobs:
publish-snapshot:
runs-on: macos-14
if: github.repository == 'IlyaGulya/anvil-utils'
timeout-minutes: 25

steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
check-latest: true

- name: Publish Release
run: ./gradlew clean publish --no-build-cache --no-daemon --stacktrace
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

jobs:
publish-release:
runs-on: ubuntu-latest
if: github.repository == 'square/anvil'
timeout-minutes: 25

steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
check-latest: true

- name: Publish Release 1.9
run: ./gradlew clean publish --no-build-cache --no-daemon --stacktrace --no-parallel
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ''

- name: Extract release notes
id: release_notes
uses: ffurrer2/extract-release-notes@v2

- name: Create release
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2
with:
body: ${{ steps.release_notes.outputs.release_notes }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Change Log

## [Unreleased]

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security

### Custom Code Generator

### Other Notes & Contributions

## [0.1.0] - 2024-03-21

- Initial release.



[Unreleased]: https://github.com/square/anvil/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/IlyaGulya/anvil-utils/releases/tag/v0.1.0
File renamed without changes.
17 changes: 17 additions & 0 deletions annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
alias(libs.plugins.kotlinx.binaryCompatibility)
id("conventions.library")
id("conventions.publish")
}

publish {
configurePom(
artifactId = "annotations",
pomName = "Anvil Utils Annotations",
pomDescription = "Utility annotations used to generate code using anvil-utils",
)
}

kotlin {
explicitApi()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.gulya.anvil.utils
package me.gulya.anvil.assisted

/**
* Allows to specify a custom key for assisted parameters. This is useful when you have multiple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.gulya.anvil.utils
package me.gulya.anvil.assisted

import kotlin.reflect.KClass

Expand Down
12 changes: 0 additions & 12 deletions anvil-utils-api/build.gradle.kts

This file was deleted.

21 changes: 21 additions & 0 deletions build-logic/conventions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
`embedded-kotlin`
`kotlin-dsl`
`java-gradle-plugin`
}

dependencies {
implementation(libs.plugin.kotlin.dokka)
implementation(libs.plugin.kotlin.jvm)
implementation(libs.plugin.mavenPublish)
implementation(files(libs::class.java.superclass.protectionDomain.codeSource.location))
}

gradlePlugin {
plugins {
register("publish") {
id = "conventions.publish"
implementationClass = "me.gulya.convention.PublishConventionPlugin"
}
}
}
11 changes: 11 additions & 0 deletions build-logic/conventions/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dependencyResolutionManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.gulya.convention

import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.kotlin.dsl.the

val Project.libs
get() = the<LibrariesForLibs>()
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package me.gulya.convention

import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.the
import javax.inject.Inject

open class PublishConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
target.extensions.create("publish", PublishExtension::class.java)

target.plugins.apply(target.libs.plugins.mavenPublish.get().pluginId)
target.plugins.apply(target.libs.plugins.kotlin.dokka.get().pluginId)

val mavenPublishing = target.extensions
.getByType(MavenPublishBaseExtension::class.java)

@Suppress("UnstableApiUsage")
mavenPublishing.pomFromGradleProperties()
mavenPublishing.signAllPublications()
mavenPublishing.publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true)

target.plugins.withId("org.jetbrains.kotlin.jvm") {
mavenPublishing.configure(
platform = KotlinJvm(
javadocJar = JavadocJar.Dokka(DOKKA_HTML),
sourcesJar = true,
),
)
}

// // Fixes issues like:
// // Task 'generateMetadataFileForMavenPublication' uses this output of task 'dokkaJavadocJar'
// // without declaring an explicit or implicit dependency.
// target.tasks.withType(GenerateModuleMetadata::class.java).configureEach {
// it.mustRunAfter(target.tasks.withType(Jar::class.java))
// }
}

companion object {
internal const val DOKKA_HTML = "dokkaHtml"
}
}

open class PublishExtension @Inject constructor(
private val target: Project,
) {
fun configurePom(
artifactId: String,
pomName: String,
pomDescription: String,
) {
target.the<PublishingExtension>()
.publications.withType(MavenPublication::class.java)
.configureEach {
this.artifactId = artifactId

pom {
name.set(pomName)
description.set(pomDescription)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
kotlin("jvm")
kotlin("kapt")
}

kotlin {
jvmToolchain(17)
compilerOptions {
optIn.add("com.squareup.anvil.annotations.ExperimentalAnvilApi")
}
}
20 changes: 9 additions & 11 deletions anvil-utils/build.gradle.kts → compiler/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.kapt)
id("conventions.library")
id("conventions.publish")
}

group = "me.gulya.anvil"
version = "0.1.0"

kotlin {
jvmToolchain(17)
compilerOptions {
optIn.add("com.squareup.anvil.annotations.ExperimentalAnvilApi")
}
publish {
configurePom(
artifactId = "compiler",
pomName = "Anvil Utils Compiler",
pomDescription = "Code generator for anvil-utils",
)
}

dependencies {
implementation(project(":anvil-utils-api"))
implementation(projects.annotations)

api(libs.anvil.compiler.api)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.squareup.kotlinpoet.*
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import me.gulya.anvil.utils.AssistedKey
import me.gulya.anvil.utils.ContributesAssistedFactory
import me.gulya.anvil.assisted.AssistedKey
import me.gulya.anvil.assisted.ContributesAssistedFactory
import me.gulya.anvil.utils.ParameterKey
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.psi.KtFile
Expand Down
Loading

0 comments on commit 54876f2

Please sign in to comment.