Maven의 DistributionManagement 조직 전체를 지정하는 방법은 무엇입니까?
중앙 넥서스 저장소에 배포 할 수 있도록 많은 (약 50 개 이상의) maven2 프로젝트를 구성하는 방법을 알아 내려고합니다. mvn deploy
목표를 사용할 때 다음과 같이 distributionManagement 태그에 대상을 지정해야합니다.
<distributionManagement>
<repository>
<id>nexus-site</id>
<url>http://central_nexus/server</url>
</repository>
</distributionManagement>
이제 모든 단일 pom.xml (50 개 이상)이이 블록을 반복해서 포함하는 것을 원하지 않습니다. 내 첫 번째 settings.xml
파일 은 파일이지만 (설계 상) 거기에서 정의하는 것이 불가능한 것 같습니다. 그래서, 첫 번째 질문은 왜 그럴까요? 가능하다면 모든 개발자에게 배포 할 수있는 maven2 배포의 settings.xml에서 지정할 수 있습니다.
내가 찾은 유일한 해결책은 이러한 설정을 포함하는 조직 전체의 master-pom 프로젝트를 만들고 다른 모든 pom.xml이 <parent>
태그 를 통해이 master-pom에 종속되도록하는 것 입니다. 그러나 이것은 다중 모듈 빌드에서 다소 이상하게 보입니다.
- master configuration POM (pm)
- Project 1 parent pom (p1 with module 1 and module 2 as modules)
- Project 1 module pom (with pm as parent)
- Project 2 module pom (with pm as parent)
일반적으로 모든 문서에서 모듈 poms가 부모 pom을 사용해야한다고 읽었습니다. 그러나 Inheritance v. Aggregation에 대한 maven 웹 사이트를 읽은 후 실제로 가능하다고 기록되었습니다.
내가 찾은 한 가지 문제는 maven 사이트 생성과 관련 하여이 설정에 문제가있는 것 같습니다 (직접 역 참조가 없으면 모듈이 올바르게 연결되지 않음)
그렇다면 이것이 유효한 접근 방식입니까? 문제에 대한 다른 더 분명하고 간단한 해결책이 있습니까?
이를위한 가장 좋은 해결책은 조직의 모든 프로젝트에 대해 일반적으로 간단한 상위 pom 파일 프로젝트 ( 'pom'패키징 포함)를 만드는 것입니다.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your.company</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<distributionManagement>
<repository>
<id>nexus-site</id>
<url>http://central_nexus/server</url>
</repository>
</distributionManagement>
</project>
이는 모든 사람이 아티팩트에 액세스 할 수 있도록 로컬 넥서스에 구축, 출시 및 배포 할 수 있습니다.
이제 사용하려는 모든 프로젝트에 대해 다음 섹션을 포함하십시오.
<parent>
<groupId>your.company</groupId>
<artifactId>company-parent</artifactId>
<version>1.0.0</version>
</parent>
이 솔루션을 사용하면 회사의 모든 프로젝트에 다른 공통 사항을 쉽게 추가 할 수 있습니다. 예를 들어 JUnit 사용을 특정 버전으로 표준화하려는 경우 여기가 완벽한 장소입니다.
If you have projects that use multi-module structures that have their own parent, Maven also supports chaining inheritance so it is perfectly acceptable to make your project's parent pom file refer to your company's parent pom and have the project's child modules not even aware of your company's parent.
I see from your example project structure that you are attempting to put your parent project at the same level as your aggregator pom. If your project needs its own parent, the best approach I have found is to include the parent at the same level as the rest of the modules and have your aggregator pom.xml file at the root of where all your modules' directories exist.
- pom.xml (aggregator)
- project-parent
- project-module1
- project-module2
What you do with this structure is include your parent module in the aggregator and build everything with a mvn install
from the root directory.
We use this exact solution at my organization and it has stood the test of time and worked quite well for us.
There's no need for a parent POM.
You can omit the distributionManagement part entirely in your poms and set it either on your build server or in settings.xml.
To do it on the build server, just pass to the mvn
command:
-DaltSnapshotDeploymentRepository=snapshots::default::https://YOUR_NEXUS_URL/snapshots
-DaltReleaseDeploymentRepository=releases::default::https://YOUR_NEXUS_URL/releases
See https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html for details which options can be set.
It's also possible to set this in your settings.xml
.
Just create a profile there which is enabled and contains the property.
Example settings.xml:
<settings>
[...]
<profiles>
<profile>
<id>nexus</id>
<properties>
<altSnapshotDeploymentRepository>snapshots::default::https://YOUR_NEXUS_URL/snapshots</altSnapshotDeploymentRepository>
<altReleaseDeploymentRepository>releases::default::https://YOUR_NEXUS_URL/releases</altReleaseDeploymentRepository>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Make sure that credentials for "snapshots" and "releases" are in the <servers>
section of your settings.xml
The properties altSnapshotDeploymentRepository and altReleaseDeploymentRepository are introduced with maven-release-plugin version 2.8. Older versions will fail with the error message
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
To fix this, you can enforce a newer version of the plug-in:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8</version>
</plugin>
</plugins>
</pluginManagement>
</build>
'program story' 카테고리의 다른 글
파생 클래스 생성자에서 기본 클래스 멤버 변수를 어떻게 초기화 할 수 있습니까? (0) | 2020.08.15 |
---|---|
Application.ThreadException과 AppDomain.CurrentDomain.UnhandledException의 차이점은 무엇입니까? (0) | 2020.08.15 |
WebDriverException : 알 수없는 오류 : Chrome 브라우저를 시작하는 동안 DevToolsActivePort 파일이 존재하지 않습니다. (0) | 2020.08.15 |
google.load로 인해 내 페이지가 비어있는 이유는 무엇입니까? (0) | 2020.08.15 |
Activity.finish ()는 Android에서 어떻게 작동합니까? (0) | 2020.08.15 |