Out-of-tree build with maven. Is it possible?

后端 未结 2 1391
独厮守ぢ
独厮守ぢ 2020-12-18 06:23

I start learning packaging for several distros (currently Cygwin and Debian).

They have requirement to build system to allow out-of-tree build (syno

相关标签:
2条回答
  • 2020-12-18 06:38

    You could do like this to get it in your current working directory:

    <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.stackoverflow</groupId>
        <artifactId>Q13173063</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <name>${project.artifactId}-${project.version}</name>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <buildDir>${user.dir}</buildDir>
        </properties>
    
        <build>
            <directory>${buildDir}</directory>
        </build>
    </project>
    

    Then you can issue

    mvn -f my-app/pom.xml compile
    

    And it will give you your classes in the current working directory.

    And easily change to another output directory:

    mvn -f my-app/pom.xml -DbuildDir=/tmp/build compile
    
    0 讨论(0)
  • 2020-12-18 06:42

    It might be as simple as having a

    <build>
        <directory>/your/build/directory</directory>
    </build>
    

    in your pom.xml. /your/build/directory need not be in the source tree and can be parameterized using the usual ${...} syntax.

    Cheers,

    0 讨论(0)
提交回复
热议问题