Maven이 컴파일하고 빌드 jar에 포함 할 추가 소스 디렉토리를 추가하는 방법은 무엇입니까?
src / main / java 외에도 빌드 프로세스에 포함하려는 src / bootstrap 디렉토리를 추가합니다. 즉, maven이 소스를 컴파일하고 빌드에 포함하기를 원합니다. 어떻게!?
Build Helper Plugin을 사용할 수 있습니다 . 예 :
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>some directory</source>
...
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
참고 :이 솔루션은 Java 소스 파일을 target / classes 디렉토리로 이동하고 소스를 컴파일하지 않습니다.
다음으로 업데이트 pom.xml
-
<project>
....
<build>
<resources>
<resource>
<directory>src/main/config</directory>
</resource>
</resources>
...
</build>
...
</project>
http://maven.apache.org/guides/mini/guide-using-one-source-directory.html
<build>
<sourceDirectory>../src/main/java</sourceDirectory>
또한 참조
With recent Maven versions (3) and recent version of the maven compiler plugin (3.7.0), I notice that adding a source folder with the build-helper-maven-plugin
is not required if the folder that contains the source code to add in the build is located in the target
folder or a subfolder of it.
It seems that the compiler maven plugin compiles any java source code located inside this folder whatever the directory that contains them.
For example having some (generated or no) source code in target/a
, target/generated-source/foo
will be compiled and added in the outputDirectory : target/classes
.
You can add the directories for your build process like:
...
<resources>
<resource>
<directory>src/bootstrap</directory>
</resource>
</resources>
...
The src/main/java is the default path which is not needed to be mentioned in the pom.xml
'program story' 카테고리의 다른 글
IE의 드롭 다운 목록 너비 (0) | 2020.09.01 |
---|---|
Clojure 개발자가 피해야 할 일반적인 프로그래밍 실수 (0) | 2020.09.01 |
사용자가 언어를 선택할 때 앱의 언어를 변경하는 방법은 무엇입니까? (0) | 2020.09.01 |
Eclipse에서 작업 태그를 현재 프로젝트로 제한하는 방법은 무엇입니까? (0) | 2020.09.01 |
Razor If / Else 조건부 연산자 구문 (0) | 2020.09.01 |