5

I'm trying to build moquette using maven, being a complete newbie to Maven tough.

I'm using the following command to build.

mvn clean install -U

And

mvn clean install -U | grep ERROR

Results in the following:

[ERROR] Failed to execute goal on project moquette-broker: Could not resolve dependencies for project org.eclipse.moquette:moquette-broker:jar:0.7-SNAPSHOT: Could not find artifact org.mapdb:mapdb:jar:1.1.0-SNAPSHOT in Paho Releases (https://repo.eclipse.org/content/repositories/paho-releases/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :moquette-broker

The full output of:

mvn clean install -e -X -U

Can be found here.

My pom.xml looks like:

<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>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <netty.version>4.0.24.Final</netty.version>
        <source.version>1.7</source.version>
        <target.version>1.7</target.version>
    </properties>

    <groupId>org.eclipse.moquette</groupId>
    <artifactId>moquette-parent</artifactId>

    <packaging>pom</packaging>
    <version>0.7-SNAPSHOT</version>
    <name>Moquette MQTT parent</name>
    <url>http://code.google.com/p/moquette-mqtt/</url>


    <modules>
        <module>parser_commons</module>
        <module>netty_parser</module>
        <module>broker</module>
        <module>distribution</module>
        <module>bundle</module>
    </modules>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </reporting>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${source.version}</source>
                    <target>${target.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

What is causing this problem and how do I fix this?

Magnilex
  • 11,584
  • 9
  • 62
  • 84
Wouter
  • 652
  • 2
  • 7
  • 27
  • Are you using the right repositories? I went to the repository listed (https://repo.eclipse.org/content/repositories/paho-releases/) and the JAR is not in there – Ascalonian Jan 20 '15 at 19:24

1 Answers1

4

According to the documentation of Moquette, a simple mvn clean install should do it:

After a git clone of the repository, cd into the cloned sources and: mvn clean package. In distribution/target directory will be produced the selfcontained tar for the broker with all dependencies and a running script.

In other words, you are doing everything right.

However, dependency org.mapdb:mapdb:jar:1.1.0-SNAPSHOT is missing (as of january 20th 2015). In other words, the installation instructions are insufficient.

By refering to the MapDB documentation, they publish nightly builds to a repository. If you add this as a repository, it will work (I just verified this myself):

<repositories>
    <repository>
        <id>sonatype-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>

You can put this definition directly in your pom file, or configure it in the settings.xml file of the maven installation, as per instructions here.

So for your pom, it will look like this:

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

    <repositories>
        <repository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <netty.version>4.0.24.Final</netty.version>
        <source.version>1.7</source.version>
        <target.version>1.7</target.version>
    </properties>

    <groupId>org.eclipse.moquette</groupId>
    <artifactId>moquette-parent</artifactId>

    <packaging>pom</packaging>
    <version>0.7-SNAPSHOT</version>
    <name>Moquette MQTT parent</name>
    <url>http://code.google.com/p/moquette-mqtt/</url>


    <modules>
        <module>parser_commons</module>
        <module>netty_parser</module>
        <module>broker</module>
        <module>distribution</module>
        <module>bundle</module>
    </modules>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </reporting>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${source.version}</source>
                    <target>${target.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

To explain this a bit more, maven checks for the needed artifacts in the repositories configured. In most cases, the artifacts exist in the "default" repositories, and no extra repositories are needed.

On the other hand, let's say you have built your own maven artifact, and host your own maven repository. You publish the artifact to that repository. Now, if other users want to use it, they would have to do a configuration similar to the one above.

And by the way, -U forces updates, which is not needed unless you really want to force maven to download/re-download the dependencies.

Magnilex
  • 11,584
  • 9
  • 62
  • 84
  • I've editted my pom.xml file to http://pastebin.com/zxD9juY5 which results in the same error. I've understood I had to include the repositories inside the 'project' tags of my pom.xml, so this file seems correct to me? Creating an empty file called '~/.m2/settings.xml' and pasting the repositories into it also results in this error. – Wouter Jan 20 '15 at 19:56
  • @Wouter I actually misread your question a bit. You need to add another repository which holds nightly builds. The dependency in question seems to not yet have made its way to the "default" maven repositories. See my updated answer. – Magnilex Jan 20 '15 at 20:21