I have problem assembling Kotlin project with some dependencies to JAR file using Maven.
How am i assembling project to JAR:
RightPanel -> MavenProjects -> Lifecycle -> package -> run
When i running JAR file:
java -jar path.jar
I'm getting following error:
no main manifest attribute, in path.jar
I've added maven-assembly-plugin
like here:
So my plugins directory looks like this:
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals> <goal>single</goal> </goals>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<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>
</plugins>
</build>
main.class
property defined here:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.1.51</kotlin.version>
<junit.version>4.12</junit.version>
<main.class>ru.icarumbas.main.HelloKt</main.class>
</properties>
Some facts:
Hello.kt
is starter class and it has funmain(...){}
- When i unarchive JAR it has META-INF folder.
Versions:
- Platform: Mac OS
- Kotlin version: 1.1.51
- Maven version: 4.0.0
Maybe i'm missing something. I've already looked on a lot of questions alike this, and they didn't help me. So please don't mark this as duplicate and write a comment if you want to see more code. I didn't show my full pom.xml
file so write me if you want to see it full.