gcl*_*ssn 5 intellij-idea maven kotlin
最近我开始使用Kotlin v1.2和Intellij IDEA v2017.3.
我在Kotlin中实现了一个注释处理器,当一个类用支持的注释类型注释时,它在META-INF下编写一个资源文件.
我可以看到注释处理器正在使用另一个Maven项目,该项目将实现用作依赖项.如果我运行mvn clean compile,META-INF下的文件在target/classes/META-INF中正确生成.
我的问题是,当源文件发生更改时,Intellij不会启动注释处理器.例如,如果我重命名带注释的Kotlin类.不会重新生成或更新资源文件.(我还没有看到注释处理器从Intellij工作......)
等中记载的IDE中我还启用了注释处理和配置"获得项目的classpath处理器" 在这里.
我作为Maven项目导入了这个项目,这里是我的pom.xml - 就像我说的:在使用Maven构建时它正在工作:
<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>
<groupId>org.example</groupId>
<artifactId>usage</artifactId>
<version>1</version>
<properties>
<kotlin.version>1.2.0</kotlin.version>
</properties>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
<executions>
<execution>
<id>kapt</id>
<phase>generate-sources</phase>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessors>
<annotationProcessor>org.example.MyProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<!-- Dependency containing the annotation processor -->
<dependency>
<groupId>org.example</groupId>
<artifactId>processor</artifactId>
<version>1</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
516 次 |
| 最近记录: |