[lombok] Simple maven plugin to enable lombok support
This commit is contained in:
committed by
TeamCityServer
parent
7ec709cf46
commit
3e883120dd
@@ -84,6 +84,7 @@
|
|||||||
<module>tools/kotlin-maven-noarg</module>
|
<module>tools/kotlin-maven-noarg</module>
|
||||||
<module>tools/kotlin-maven-sam-with-receiver</module>
|
<module>tools/kotlin-maven-sam-with-receiver</module>
|
||||||
<module>tools/kotlin-maven-serialization</module>
|
<module>tools/kotlin-maven-serialization</module>
|
||||||
|
<module>tools/kotlin-maven-lombok</module>
|
||||||
|
|
||||||
<module>tools/kotlin-bom</module>
|
<module>tools/kotlin-bom</module>
|
||||||
|
|
||||||
|
|||||||
Executable
+102
@@ -0,0 +1,102 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<properties>
|
||||||
|
<maven.version>3.0.5</maven.version>
|
||||||
|
<lombok.src>${basedir}/../../../plugins/lombok/lombok-compiler-plugin/src</lombok.src>
|
||||||
|
<lombok.resources>${basedir}/../../../plugins/lombok/lombok-compiler-plugin/resources</lombok.resources>
|
||||||
|
<lombok.maven.plugin.src>${basedir}/src/main/kotlin</lombok.maven.plugin.src>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-project</artifactId>
|
||||||
|
<version>1.5.255-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>kotlin-maven-lombok</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<description>Lombok plugin for Maven</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${lombok.resources}</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>${lombok.src}</source>
|
||||||
|
<source>${lombok.maven.plugin.src}</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-component-metadata</artifactId>
|
||||||
|
<version>1.7.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>process-classes</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate-metadata</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>process-test-classes</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate-test-metadata</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* 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 org.jetbrains.kotlin.lombok
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.*
|
||||||
|
import org.apache.maven.project.*
|
||||||
|
import org.codehaus.plexus.component.annotations.*
|
||||||
|
import org.codehaus.plexus.logging.*
|
||||||
|
import org.jetbrains.kotlin.maven.*
|
||||||
|
|
||||||
|
val LOMBOK_COMPILER_PLUGIN_ID = "org.jetbrains.kotlin.lombok"
|
||||||
|
|
||||||
|
@Component(role = KotlinMavenPluginExtension::class, hint = "kotlin-lombok")
|
||||||
|
class KotlinLombokMavenPluginExtension : KotlinMavenPluginExtension {
|
||||||
|
@Requirement
|
||||||
|
lateinit var logger: Logger
|
||||||
|
|
||||||
|
override fun getCompilerPluginId() = LOMBOK_COMPILER_PLUGIN_ID
|
||||||
|
|
||||||
|
override fun isApplicable(project: MavenProject, execution: MojoExecution) = true
|
||||||
|
|
||||||
|
override fun getPluginOptions(project: MavenProject, execution: MojoExecution): List<PluginOption> {
|
||||||
|
logger.debug("Loaded Maven plugin " + javaClass.name)
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -120,6 +120,7 @@
|
|||||||
<artifact>org.jetbrains.kotlin:kotlin-maven-plugin:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-maven-plugin:${project.version}</artifact>
|
||||||
<artifact>org.jetbrains.kotlin:kotlin-maven-allopen:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-maven-allopen:${project.version}</artifact>
|
||||||
<artifact>org.jetbrains.kotlin:kotlin-maven-noarg:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-maven-noarg:${project.version}</artifact>
|
||||||
|
<artifact>org.jetbrains.kotlin:kotlin-maven-lombok:${project.version}</artifact>
|
||||||
<artifact>org.jetbrains.kotlin:kotlin-maven-sam-with-receiver:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-maven-sam-with-receiver:${project.version}</artifact>
|
||||||
<artifact>org.jetbrains.kotlin:kotlin-annotation-processing-maven:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-annotation-processing-maven:${project.version}</artifact>
|
||||||
<artifact>org.jetbrains.kotlin:kotlin-script-runtime:${project.version}</artifact>
|
<artifact>org.jetbrains.kotlin:kotlin-script-runtime:${project.version}</artifact>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
config.stopBubbling = true
|
||||||
|
|
||||||
|
lombok.getter.noIsPrefix = true
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>test-lombok-simple</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>mavenCentral</id>
|
||||||
|
<url>https://repo1.maven.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||||
|
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>kotlin-lombok</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
|
||||||
|
<pluginOptions>
|
||||||
|
<option>kotlin-lombok:config=lombok.config</option>
|
||||||
|
</pluginOptions>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>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>test-compile</id>
|
||||||
|
<goals> <goal>test-compile</goal> </goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
|
||||||
|
<sourceDir>${project.basedir}/src/test/java</sourceDir>
|
||||||
|
</sourceDirs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-lombok</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<!-- Replacing default-compile as it is treated specially by maven -->
|
||||||
|
<execution>
|
||||||
|
<id>default-compile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<!-- Replacing default-testCompile as it is treated specially by maven -->
|
||||||
|
<execution>
|
||||||
|
<id>default-testCompile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>java-compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>java-test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.20</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package lab2;
|
||||||
|
|
||||||
|
public class JavaUsage {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SomePojo obj = new SomePojo();
|
||||||
|
obj.setAge(12);
|
||||||
|
boolean v = obj.getHuman();
|
||||||
|
obj.setHuman(!v);
|
||||||
|
System.out.println(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cycleUsage() {
|
||||||
|
new SomeKotlinClass().call();
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package lab2;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class ManualPojo {
|
||||||
|
|
||||||
|
public String getFoo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @NotNull
|
||||||
|
public String getBar() {
|
||||||
|
return "234";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Object someMethod() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package lab2;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SomeData {
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
private boolean human;
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package lab2;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter @Setter @ToString
|
||||||
|
public class SomePojo {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
private boolean human;
|
||||||
|
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package lab2
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
println("something")
|
||||||
|
val obj = SomePojo()
|
||||||
|
obj.name = "test"
|
||||||
|
val s: String = obj.name
|
||||||
|
obj.age = 12
|
||||||
|
val v = obj.human
|
||||||
|
obj.human = !v
|
||||||
|
println(obj)
|
||||||
|
//
|
||||||
|
// val manualPojo = ManualPojo()
|
||||||
|
//
|
||||||
|
// val foo: String? = manualPojo.getFoo()
|
||||||
|
// val res: Any? = manualPojo.someMethod()
|
||||||
|
//
|
||||||
|
val ddd = SomeData()
|
||||||
|
|
||||||
|
JavaUsage.cycleUsage()
|
||||||
|
}
|
||||||
|
|
||||||
|
class SomeKotlinClass {
|
||||||
|
fun call() {
|
||||||
|
val ddd = SomeData()
|
||||||
|
ddd.age = 12
|
||||||
|
println(ddd)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
File file = new File(basedir, "target/test-lombok-simple-1.0-SNAPSHOT.jar");
|
||||||
|
if (!file.exists() || !file.isFile()) {
|
||||||
|
throw new FileNotFoundException("Could not find generated JAR: " + file);
|
||||||
|
}
|
||||||
+2
-2
@@ -312,9 +312,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
try {
|
try {
|
||||||
KotlinMavenPluginExtension extension = container.lookup(KotlinMavenPluginExtension.class, pluginName);
|
KotlinMavenPluginExtension extension = container.lookup(KotlinMavenPluginExtension.class, pluginName);
|
||||||
loadedPlugins.put(pluginName, extension);
|
loadedPlugins.put(pluginName, extension);
|
||||||
getLog().debug("Got plugin instance" + pluginName + " of type " + extension.getClass().getName());
|
getLog().debug("Got plugin instance " + pluginName + " of type " + extension.getClass().getName());
|
||||||
} catch (ComponentLookupException e) {
|
} catch (ComponentLookupException e) {
|
||||||
getLog().debug("Unable to get plugin instance" + pluginName);
|
getLog().debug("Unable to get plugin instance " + pluginName);
|
||||||
throw new PluginNotFoundException(pluginName, e);
|
throw new PluginNotFoundException(pluginName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user