mavenjar

How to place the output jar into another folder with maven?


I'd like to place my output jar and jar-with-dependencies into another folder (not in target/ but in ../libs/).

How can I do that?


Solution

  • You can use the outputDirectory parameter of the maven-jar-plugin for this purpose:

    <project>
      ...
      <build>
        <plugins>
          ...
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
              <outputDirectory>../libs</outputDirectory>
            </configuration>
          </plugin>
          ...
        </plugins>
      </build>
      ...
    </project>
    

    But as cdegroot wrote, you should probably better not fight the maven way.