maven-source-plugin不适用于kotlin

我正在尝试使用maven-source-plugin来为我的kotlin项目创建一个source.jar,但是似乎maven-source-plugin不适用于kotlin项目。

当我运行“mvn源:瓶”,输出消息总是说:

[INFO] No sources in project. Archive not created. 

这里是项目的pom文件中的maven-source-plugin配置:

  <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <attach>true</attach> <includes> <!-- i am trying to specify the include dir manually, but not work --> <include>${project.basedir}/src/main/kotlin/*</include> </includes> <forceCreation>true</forceCreation> </configuration> </execution> </executions> </plugin> </plugins> </build> 

我的问题是:如何使用maven-source-plugin附上kotlin源文件?

谢谢~~

默认情况下,Maven希望源文件位于src/main/java目录下。 如果使用非默认目录,则必须在build元素中指定它们:

 <build> <sourceDirectory>src/main/kotlin</sourceDirectory> <testSourceDirectory>src/test/kotlin</testSourceDirectory> </build> 

当你的项目混合了Java和Kotlin(也就是多个源代码)时,我发现使用build-helper-maven-plugin工作得很好,以确保Java和Kotlin源都包含在构建的源文件中。

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/main/kotlin</source> </sources> </configuration> </execution> </executions> </plugin>