Skip to content

Commit

Permalink
Added new annotation processor
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schnell committed Apr 1, 2024
1 parent eb926a4 commit 052a234
Show file tree
Hide file tree
Showing 25 changed files with 832 additions and 48 deletions.
88 changes: 44 additions & 44 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Java Maven Build

on:
push:
branches:
branches:
- '**'
paths-ignore:
- '**/README.md'
Expand All @@ -18,46 +18,46 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: maven

- name: Show versions
run: java -version && ./mvnw -version && gpg --version

- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.OSS_SONATYPE_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.OSS_SONATYPE_GPG_PASSPHRASE }}

- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSS_SONATYPE_USERNAME: michael-schnell
OSS_SONATYPE_TOKEN: ${{ secrets.OSS_SONATYPE_TOKEN }}
OSS_SONATYPE_GPG_PASSPHRASE: ${{ secrets.OSS_SONATYPE_GPG_PASSPHRASE }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw clean deploy jacoco:report sonar:sonar -U -B -P sonatype-oss-release --file pom.xml -s settings.xml
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
cache: maven

- name: Show versions
run: java -version && ./mvnw -version && gpg --version

- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.OSS_SONATYPE_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.OSS_SONATYPE_GPG_PASSPHRASE }}

- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSS_SONATYPE_USERNAME: michael-schnell
OSS_SONATYPE_TOKEN: ${{ secrets.OSS_SONATYPE_TOKEN }}
OSS_SONATYPE_GPG_PASSPHRASE: ${{ secrets.OSS_SONATYPE_GPG_PASSPHRASE }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw clean deploy jacoco:report sonar:sonar -U -B -P sonatype-oss-release --file pom.xml -s settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.fuin.esc.api;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Request to generate a class that implements {@link SerializedDataTypesRegistrationRequest}.
* Should only be placed on an interface as it will be used for the implementation with "implements".
*/
@Documented
@Target(ElementType.TYPE)
@Inherited
@Retention(RetentionPolicy.SOURCE)
public @interface GenerateSerializedDataTypesRegistrationRequest {

/**
* Name of the class to generate. In case it's not set, the class will be named
* like annotated interface with an "Impl" extension.
*
* @return Simple class name.
*/
String name() default "";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.fuin.esc.api;

import java.util.Set;

/**
* Returns classes that are annotated with {@link HasSerializedDataTypeConstant} and should be
* included in the applications {@link SerializedDataTypeRegistry}.
*/
public interface SerializedDataTypesRegistrationRequest {

/**
* Returns the class to type mappings that should be registered.
*
* @return Set of mappings.
*/
Set<SerializedDataType2ClassMapping> getMappingsToRegister();

}
145 changes: 145 additions & 0 deletions apt/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>org.fuin.esc</groupId>
<artifactId>esc-parent</artifactId>
<version>0.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>esc-apt</artifactId>
<packaging>jar</packaging>
<description>Generation of source code with APT (Annotation Processing Tool)</description>

<dependencies>

<!-- compile -->

<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
</dependency>

<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.1.1</version>
<optional>true</optional>
</dependency>

<!-- test -->

<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.toolisticon.cute</groupId>
<artifactId>cute</artifactId>
<version>1.4.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.google.auto.common</pattern>
<shadedPattern>org.fuin.esc.apt.auto.common</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<includes>
<include>**/*</include>
</includes>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.fuin.esc.apt</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jdeps-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>com.tngtech.archunit:archunit-junit5</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>com.google.auto.service:auto-service</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.fuin.esc:esc-api</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>com.tngtech.archunit:archunit-junit5-api</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>org.junit.jupiter:junit-jupiter-api</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
</configuration>
</plugin>

</plugins>

</build>

</project>
Loading

0 comments on commit 052a234

Please sign in to comment.