I am trying to use maven-source-plugin to create a source.jar for my kotlin project, but seems the maven-source-plugin not work well for kotlin project.

when i run "mvn source:jar", the output message always says:

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

here is the maven-source-plugin configuration in my pom file of the project:

    <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>

my question is: how to attach kotlin source files using maven-source-plugin?

谢谢~~

推荐答案

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

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

Kotlin相关问答推荐

KTOR';S函数`staticResources`在Kotlin本机目标上不可用

数据流弹性模板失败,出现错误&未知非复合转换urn";

合并状态流

有没有办法在 jetpack compose 中将 TextField 密码点图标增加得更大?

如何在数据类中删除空格 (String)?

Kotlin 可空泛型

如何在 kotlin 中创建自定义迭代器并添加到现有类?

使用 Discord4j 交叉发布 Discord 消息

Kotlin 条件格式字符串

为 Gradle 子项目配置 Kotlin 扩展

Kotlin - 创建指定长度的随机整数的 ArrayList?

使用 Kotlin 协程时 Room dao 类出错

Kotlin 使用迭代索引过滤 lambda 数组

无法从 XML 访问 NavHostFragment

Kotlin 是如何编译的?

如何在顶级函数中使用 koin 注入依赖项

添加抽象的私有getter和公共setter的正确方法是什么?

空对象引用上的 TransitionSet ArrayList.size()

Kotlin 警告:Conditional branch result of type ... is implicity cast of Any?

Android Jetpack Compose 中的文本渐变