Mnemosyne
Mnemosyne

Reputation: 1192

Maven build does not compile

I am trying to compile a maven project but I get the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project storm-example: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java are missing or invalid -> [Help 1]

I am new to maven projects actually. The thing is I am not using the codehous.mojo plugin at all. From what I saw from different existing issues, the people who got this were using the mojo plugin in the build, but in my case i just need the maven-assembly-plugin. Do I need mojo in every maven object despite not explicitly needing it?

The following is my maven pom.xml file

    <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>com.learningstorm</groupId>
  <artifactId>storm-example</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>storm-example</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
  </dependency>

  <dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-core</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

<repositories>
  <repository>
    <id>clojars.org</id>
    <url>http://clojars.org/repo</url>
  </repository>
</repositories>


<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>3.0.0</version>
      <configuration>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
          <manifest>
            <mainClass />
          </manifest>
        </archive>
      </configuration>
      <executions>
        <execution>
          <id>make-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

</project>

Upvotes: 2

Views: 2422

Answers (1)

Aaron
Aaron

Reputation: 24802

The error is a complaint about your following tag in the maven-assembly-plugin's configuration :

<archive>
  <manifest>
    <mainClass />
  </manifest>
</archive>

Unless you want to create an executable jar (in which case you should specify the qualified name of the "main" class), you should just remove the whole <archive> tag.

It looks like you've based your work around the "Creating an Executable JAR" example of the maven-assembly-plugin's usage page while you might only need what is defined in the first basic example.

Upvotes: 4

Related Questions