Installation

Distribution Bundle

You can obtain a distribution bundle containing the MapStruct binaries, source code and API documentation from GitHub.

Apache Maven

If you’re using Maven to build your project add the following to your pom.xml to use MapStruct:

...
<properties>
    <org.mapstruct.version>1.1.0.Final</org.mapstruct.version>
</properties>
...
<dependencies>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
        <version>${org.mapstruct.version}</version>
    </dependency>
</dependencies>
...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.6</source> <!-- or higher, depending on your project -->
                <target>1.6</target> <!-- or higher, depending on your project -->
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${org.mapstruct.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>

Gradle

With Gradle, you add something along the following lines to your build.gradle:

plugins {
    ...
    id 'net.ltgt.apt' version '0.8'
}
dependencies {
    ...
    compile 'org.mapstruct:mapstruct:1.1.0.Final'

    // OR use this with Java 8 and beyond
    compile 'org.mapstruct:mapstruct-jdk8:1.1.0.Final'

    apt 'org.mapstruct:mapstruct-processor:1.1.0.Final'
}

You can find a complete example in the mapstruct-examples project on GitHub.

Apache Ant

Add the javac task configured as follows to your build.xml file in order to enable MapStruct in your Ant-based project. Adjust the paths as required for your project layout.

...
<javac
    srcdir="src/main/java"
    destdir="target/classes"
    classpath="path/to/mapstruct-jdk8-1.1.0.Final.jar">
    <compilerarg line="-processorpath path/to/mapstruct-processor-1.1.0.Final.jar"/>
    <compilerarg line="-s target/generated-sources"/>
</javac>
...

You can find a complete example in the mapstruct-examples project on GitHub.