Change source directory in profile maven

前端 未结 2 943
感动是毒
感动是毒 2020-12-03 02:36

I want to use a different source directory for a specific maven profile, however, when I try to specify it in the profile definition I get this error:

Unreco         


        
相关标签:
2条回答
  • 2020-12-03 03:08

    See Maven model, it is not allowed to define a sourceDirectory within a profile. The only thing you can do is specify the sourceDirectory within the plugin configuration, assuming it is available.

    0 讨论(0)
  • 2020-12-03 03:21

    According to the documentation, you can change only few <build> parameters in the profile and <sourceDirectory> is not one of them.

    I'd configure the main <build> to take sources from path defined by some property (eg. src.dir), set this property to src/main/java and override it in the custom profile:

    <project>
        ...
        <properties>
            <src.dir>src/main/java</src.dir>
        </properties>
        <build>
            <sourceDirectory>${src.dir}</sourceDirectory>
            ...
        </build>
        <profiles>
            <profile>
                <id>development</id>
                <properties>
                    <src.dir>${project.build.directory}/new-src</src.dir>
                </properties>
            </profile>
        </profiles>
    </project>
    
    0 讨论(0)
提交回复
热议问题