Maven构建插件不包括我自己的类



我有以下(非常(简单的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>ro.ace.ucv</groupId>
<artifactId>message_generator</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<scala.major.version>2.10</scala.major.version>
<scala.version>${scala.major.version}.5</scala.version>
<spark.version>1.6.0</spark.version>
<spark.streaming.version>1.6.0</spark.streaming.version>
<spark.sql.version>1.6.0</spark.sql.version>
<spark.version>1.6.0</spark.version>
<junit.version>4.12</junit.version>
<scalatest.version>2.1.3</scalatest.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.message.generator.MessageGeneratorMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>

以及以下(非常(简单的项目结构:

\message_generator\src\main\scala\com\message\generator\MessageGeneratorMain.scala

运行时 mvn 清理编译程序集:单个

我得到了一个带有依赖项的 jar,但我自己的代码(3 个类,包括 Main 类(不包含在最终的 jar 中。

你必须包含Maven Scala插件才能在src/main/scala中捕获scala代码

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

最新更新