Simplify kotlin compiler configuration

This commit is contained in:
Andreas Dangel 2024-02-23 10:50:58 +01:00
parent 44e299945d
commit 7069e6146c
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
8 changed files with 160 additions and 167 deletions

View File

@ -19,19 +19,6 @@
</resource>
</resources>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kotlin-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
@ -41,26 +28,17 @@
</delimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -68,7 +46,7 @@
<executions>
<execution>
<id>attach-javadocs</id>
<!-- disable -->
<!-- disable this execution, as we are using dokka-maven-plugin here -->
<phase>none</phase>
</execution>
</executions>
@ -76,15 +54,6 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -54,6 +54,24 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-javacc-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/javacc</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
@ -97,35 +115,6 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-javacc-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/javacc</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-kotlin-test-sources</id>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/test/kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>

View File

@ -17,58 +17,15 @@
</parent>
<build>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
<!-- Adding kotlin files to test resources, so that checkstyle verifies the license header -->
<testResource>
<directory>${project.basedir}/src/main/kotlin</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-kotlin-sources</id>
<!-- This is needed because otherwise that directory is -->
<!-- added as a test resource by the <testResources> above -->
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/main/kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- The kotlin plugin has to run before the java plugin-->
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kotlin-compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -88,15 +45,6 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -29,6 +29,23 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-javacc-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/javacc</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
@ -59,24 +76,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-javacc-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/javacc</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>

View File

@ -28,10 +28,6 @@
<testResource>
<directory>../pmd-scala-common/src/test/resources</directory>
</testResource>
<!-- Adding kotlin files to test resources, so that checkstyle verifies the license header -->
<testResource>
<directory>../pmd-scala-common/src/test/kotlin</directory>
</testResource>
</testResources>
<pluginManagement>
@ -46,6 +42,35 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-kotlin-source-dir</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/../pmd-scala-common/src/main/kotlin</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-kotlin-test-source-dir</id>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/../pmd-scala-common/src/test/kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
@ -57,8 +82,8 @@
</goals>
<configuration>
<sourceDirs>
<sourceDir>../pmd-scala-common/src/main/kotlin</sourceDir>
<sourceDir>../pmd-scala-common/src/main/java</sourceDir>
<sourceDir>${project.basedir}/../pmd-scala-common/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/../pmd-scala-common/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
@ -69,8 +94,8 @@
</goals>
<configuration>
<sourceDirs>
<sourceDir>../pmd-scala-common/src/test/kotlin</sourceDir>
<sourceDir>../pmd-scala-common/src/test/java</sourceDir>
<sourceDir>${project.basedir}/../pmd-scala-common/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/../pmd-scala-common/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>

View File

@ -18,8 +18,16 @@
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>

View File

@ -18,8 +18,16 @@
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>

81
pom.xml
View File

@ -122,18 +122,11 @@
<antlr4.outputDirectory>${project.build.directory}/generated-sources/antlr4</antlr4.outputDirectory>
<antlr4.ant.wrapper>${project.basedir}/../antlr4-wrapper.xml</antlr4.ant.wrapper>
<dokka.skip>false</dokka.skip>
</properties>
<build>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
<!-- Adding kotlin files to test resources, so that checkstyle verifies the license header -->
<testResource>
<directory>${project.basedir}/src/test/kotlin</directory>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
@ -197,19 +190,60 @@
<version>3.2.0</version>
</plugin>
<!-- adds kotlin source directories for checkstyle header checks -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-kotlin-source-dir</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/main/kotlin</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-kotlin-test-source-dir</id>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/test/kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Kotlin compiler for test-compile -->
<!-- The kotlin plugin has to run before the java plugin-->
<!-- The kotlin plugin has to run before the maven-compiler-plugin -->
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kotlin-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>kotlin-test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<phase>process-test-sources</phase>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
@ -319,11 +353,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
@ -361,6 +390,23 @@
</offlineLinks>
</configuration>
</plugin>
<plugin>
<!-- When using kotlin/dokka, you need to disable maven-javadoc-plugin@attach-javadocs -->
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka.version}</version>
<configuration>
<skip>${dokka.skip}</skip>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
@ -391,7 +437,8 @@
<suppressionsLocation>/net/sourceforge/pmd/pmd-checkstyle-suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<excludeGeneratedSources>true</excludeGeneratedSources>
<resourceIncludes>**/*.properties,**/*.less,**/*.kt</resourceIncludes>
<includes>**/.java,**/*.kt</includes>
<resourceIncludes>**/*.properties,**/*.less</resourceIncludes>
</configuration>
</plugin>
<plugin>