This is what I did to weave the binary way in aspects, after which Java and Kotlin code was compiled.
I could not get aspectj-maven-plugin to weave the aspect of the binary path correctly, so instead I used the jcabi-maven-plugin . See http://plugin.jcabi.com/example-ajc.html
The assistant who worked for me:
<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>my.group.id</groupId> <artifactId>my.artifact.id</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <complianceLevel>1.6</complianceLevel> </properties> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.8.9</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> <version>3.3</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <plugin> <artifactId>kotlin-maven-plugin</artifactId> <groupId>org.jetbrains.kotlin</groupId> <version>1.0.3</version> <configuration> <sourceDirs> <sourceDir>src/main/kotlin</sourceDir> <sourceDir>src/test/kotlin</sourceDir> </sourceDirs> </configuration> <executions> <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> <plugin> <groupId>com.jcabi</groupId> <artifactId>jcabi-maven-plugin</artifactId> <version>0.14.1</version> <executions> <execution> <goals> <goal>ajc</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.5.0</version> <configuration> <mainClass>my.package.MyMainClassKt</mainClass> </configuration> </plugin> </plugins> </build>
So, this works with aspects and a few annotations defined in Java, and then using these annotations to annotate Kotlin methods and classes so that the aspects are successfully introduced into Kotlin code.
Note that if a Kotlin file has both a main method and a class defined in the same file, the Kotlin compiler creates two class files. One class with the class name and one class with "Kt" is added to its name. It is useful to know if you are trying to use exec-maven-plugin to run Kotlin code.
However, this did not reflect well on the eclipse. Perhaps IntelliJ will work better.
User0 source share