Skip to content

Commit

Permalink
Merge branch 'release/0.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Jul 9, 2024
2 parents 1aee5e9 + bf3ad9b commit ead2212
Show file tree
Hide file tree
Showing 116 changed files with 5,203 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
max_line_length = 160
max_line_length = 200

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Please use one of the following templates:

https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/issues/new/choose
https://github.com/toolisticon/kotlin-code-generation/issues/new/choose
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ updates:
open-pull-requests-limit: 10
default-labels:
- "Type: dependencies"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
default-labels:
- "Type: dependencies"
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

# Publish release
- name: Deploy a new release version to Maven Central
run: ./mvnw clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname="${{ secrets.GPG_KEYNAME }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -ntp
run: ./mvnw clean deploy -B -ntp -DskipTests -DskipItest -DskipExamples -Prelease -Dgpg.keyname="${{ secrets.GPG_KEYNAME }}" -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}"
env:
OSS_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
OSS_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Create Release Notes Markdown
uses: docker://decathlon/release-notes-generator-action:3.1.5
env:
Expand All @@ -23,7 +24,7 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create a Draft Release Notes on GitHub
id: create_release
uses: actions/create-release@v1
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ build/

### DEV
_tmp/
.repository/
2 changes: 2 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
21 changes: 3 additions & 18 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
5 changes: 5 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

This product includes software developed by ZacSweers (https://github.com/ZacSweers).
`dev.zacsweers.kctfork:core:<latest-version>` is published under the MPL-2 license which is considered to be
compatible with the APACHE LICENSE.

89 changes: 63 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,79 @@
# BASE_ARTIFACT_ID

Template repository for usage in organizations: toolisticon, holunda-io, holixon...
# kotlin-code-generation

[![incubating](https://img.shields.io/badge/lifecycle-INCUBATING-orange.svg)](https://github.com/holisticon#open-source-lifecycle)
[![Build Status](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/workflows/Development%20branches/badge.svg)](https://github.com/GITHUB_ORGANIZATION/GITHUB_REPOSITORY/actions)
[![Build Status](https://github.com/toolisticon/kotlin-code-generation/workflows/Development%20branches/badge.svg)](https://github.com/toolisticon/kotlin-code-generation/actions)
[![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-RED.svg)](https://holisticon.de/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID/badge.svg)](https://maven-badges.herokuapp.com/maven-central/BASE_GROUP_ID/BASE_ARTIFACT_ID)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.kotlin.generation/kotlin-code-generation/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.kotlin.generation/kotlin-code-generation)

This repository is a **template repository** designed to be a template for the next project.
**Usage:**

## How to use
```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.toolisticon.kotlin.generation</groupId>
<artifactId>kotlin-code-generation-bom</artifactId>
<version>LATEST_VERSION</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
```

* create a new repo on github (can be in any organization). Choose this project as template repository. Copy all branches, so the `master`exists in your repo (for the github actions)
* on the command line: clone your new repo locally
* in the `setup.sh` script: set your organization, repository and base package
* run the `setup.sh` script, all placeholders are filled with your information
* delete the setup-script
* Update the `README.md`
* in the `developers` section of the `pom.xml`: mention yourself ... it is your project.
## Documentation

## Things to change after usage of template
* see [kotlin-poet](https://square.github.io/kotlinpoet/)

To change the following values, modify the placeholders in `setup.sh` and run it.
This is a one-time operation, you can safely delete the `setup.sh` file afterwards.
## Features

Of course, you can also edit manually .... and do not forget to change this `README.md` with YOUR project specific information :-).
* KotlinAnnotationSpec
* KotlinAnnotationSpecBuilder
* KotlinFileSpec
* KotlinFileSpecBuilder
* KotlinFunSpec
* KotlinFunSpecBuilder
* KotlinParameterSpec
* KotlinParameterSpecBuilder
* KotlinPropertySpec
* KotlinPropertySpecBuilder

### Maven pom.xml

* Maven coordinates: `groupId`, `artifactId` and `version`
* Main description: `name`, `url`, `description`
* SCM: `connection`, `url`, `developerConnection`

### Issue Template
## Roadmap

* correct the URL to repo
### Specs to support

### Issue Labels
* com/squareup/kotlinpoet/TypeAliasSpec
* com/squareup/kotlinpoet/TypeSpec

* Check the release-notes.yml for details, but create the following labels: Type: dependencies, Type: bug, Type: documentation, Type: question, Type: enhancement
### Builders to implement

* com/squareup/kotlinpoet/AnnotationSpec$Builder
* Taggable.Builder<Builder>
* com/squareup/kotlinpoet/CodeBlock$Builder
* None
* com/squareup/kotlinpoet/FileSpec$Builder
* Annotatable.Builder<Builder>
* Taggable.Builder<Builder>
* TypeSpecHolder.Builder<Builder>
* com/squareup/kotlinpoet/FunSpec$Builder
* Annotatable.Builder<Builder>
* ContextReceivable.Builder<Builder>
* Documentable.Builder<Builder>
* Taggable.Builder<Builder>
* OriginatingElementsHolder.Builder<Builder>
* com/squareup/kotlinpoet/ParameterSpec$Builder
* Annotatable.Builder<Builder>
* Documentable.Builder<Builder>
* Taggable.Builder<Builder>
* com/squareup/kotlinpoet/PropertySpec$Builder
* Annotatable.Builder<Builder>
* ContextReceivable.Builder<Builder>
* Documentable.Builder<Builder>
* OriginatingElementsHolder.Builder<Builder>
* Taggable.Builder<Builder>
* com/squareup/kotlinpoet/TypeAliasSpec$Builder
* Annotatable.Builder<Builder>
* Documentable.Builder<Builder>
* Taggable.Builder<Builder>
8 changes: 8 additions & 0 deletions _itest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Kotlin Code Generation Integration tests

The repository provides both, the generation module and the test module.
As the test module depends on the generation module, we cannot provide tests using the test module inside that module.

This additional module is used to define and run all nontrivial integration tests, where we "eat our own dog food"
and use the generation tools and builders to created code and then compile and assert it is working correctly using
the test module.
85 changes: 85 additions & 0 deletions _itest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.toolisticon.kotlin.generation._</groupId>
<artifactId>kotlin-code-generation-parent</artifactId>
<version>0.0.1</version>
<relativePath>../_mvn/parent/pom.xml</relativePath>
</parent>

<groupId>io.toolisticon.kotlin.generation.itest</groupId>
<artifactId>kotlin-code-generation-itest</artifactId>
<name>test: ${project.artifactId}</name>
<description>Integration Tests applied on specs, builders and compilation tests.</description>

<properties>
<!-- itest is excluded from install/deploy/release -->
<maven.install.skip>true</maven.install.skip>
<gpg.skip>true</gpg.skip>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.toolisticon.kotlin.generation</groupId>
<artifactId>kotlin-code-generation-bom</artifactId>
<version>${project.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- KOTLIN -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
</dependency>
<!-- /KOTLIN -->

<dependency>
<groupId>io.toolisticon.kotlin.generation</groupId>
<artifactId>kotlin-code-generation</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.toolisticon.kotlin.generation</groupId>
<artifactId>kotlin-code-generation-test</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-serialization-core-jvm</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi</arg>
<arg>-opt-in=com.squareup.kotlinpoet.ExperimentalKotlinPoetApi</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
</project>
5 changes: 5 additions & 0 deletions _itest/src/main/kotlin/KotlinCodeGenerationITest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.toolisticon.kotlin.generation.itest

object KotlinCodeGenerationITest {
const val ROOT_PACKAGE = "io.toolisticon.kotlin.generation.itest.created"
}
21 changes: 21 additions & 0 deletions _itest/src/main/kotlin/MyCustomAnnotationSpec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.toolisticon.kotlin.generation.itest

import com.squareup.kotlinpoet.ClassName
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildAnnotationClass
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFile
import io.toolisticon.kotlin.generation.itest.KotlinCodeGenerationITest.ROOT_PACKAGE

object MyCustomAnnotationSpec {
val name = ClassName(ROOT_PACKAGE, "MyCustomAnnotation")

val spec = buildAnnotationClass(name) {
mustBeDocumented()
retention(AnnotationRetention.RUNTIME)
target(AnnotationTarget.CLASS)
addConstructorProperty("value", String::class)
}

val file = buildFile(name) {
addType(spec)
}
}
File renamed without changes.
43 changes: 43 additions & 0 deletions _itest/src/test/kotlin/HelloWorldExampleTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.toolisticon.kotlin.generation.itest

import com.squareup.kotlinpoet.ClassName
import com.tschuchort.compiletesting.KotlinCompilation
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildClass
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFile
import io.toolisticon.kotlin.generation.KotlinCodeGeneration.buildFun
import io.toolisticon.kotlin.generation.test.KotlinCodeGenerationTest
import io.toolisticon.kotlin.generation.test.model.KotlinCompilationCommand
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class HelloWorldExampleTest {

@Test
fun `hello world from kotlin poet talk`() {
val name = ClassName("foo.bar", "HelloWorld")

val type = buildClass(name) {
addFunction(
buildFun("helloWorld") {
builder {
returns(String::class)
addCode("return %S", "Hello World!")
}
})
addKdoc("%L", "Simple hello world class")
}

val file = buildFile(name) {
addType(type)
}
println(file.code)

assertThat(file.packageName).isEqualTo("foo.bar")

val result = KotlinCodeGenerationTest.compile(cmd = KotlinCompilationCommand(fileSpec = file))

println(result)

KotlinCodeGenerationTest.assertThat(result).hasExitCode(KotlinCompilation.ExitCode.OK)
}
}
11 changes: 11 additions & 0 deletions _itest/src/test/kotlin/KotlinAnnotationSpecTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.toolisticon.kotlin.generation.itest

import org.junit.jupiter.api.Test

internal class KotlinAnnotationSpecTest {

@Test
fun `generate annotation spec`() {

}
}
15 changes: 15 additions & 0 deletions _itest/src/test/kotlin/KotlinClassBuilderTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.toolisticon.kotlin.generation.itest

import com.squareup.kotlinpoet.TypeSpec
import org.junit.jupiter.api.Test

internal class KotlinClassBuilderTest {

@Test
fun `kotlin poet only generation`() {
val builder = TypeSpec.classBuilder("Bar")
.addKdoc("%L","hello world")

println(builder.build())
}
}
Loading

0 comments on commit ead2212

Please sign in to comment.