gpt4 book ai didi

java - 将 pom.xml 与父级合并

转载 作者:行者123 更新时间:2023-12-01 09:35:55 28 4
gpt4 key购买 nike

我继承了一个maven项目,它的结构有点困惑。父文件夹中有一个 home pom.xml,子文件夹中有另一个。这种结构有点令人困惑,因为父级除了管理子级之外什么也没有。

有没有办法将两者合并?我尝试手动执行此操作但失败了。我认为我的问题在于第谷和 eclipse 插件。

这是子pom.xml:

<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>
<parent>
<groupId>my.project</groupId>
<artifactId>my.project.foo.parent</artifactId>
<version>2.4.0</version>
</parent>
<artifactId>my.project.foo</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

父级是:

<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my.project</groupId>
<artifactId>my.project.foo.parent</artifactId>
<version>2.4.0</version>
<packaging>pom</packaging>

<properties>
<tycho.version>0.24.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mars-repo.url>http://download.eclipse.org/releases/mars</mars-repo.url>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>mars</id>
<url>${mars-repo.url}</url>
<layout>p2</layout>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>my.project</groupId>
<artifactId>my</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>my.project</groupId>
<artifactId>cli</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>0.24.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
</project>

最佳答案

在父项中pom.xml改变 <packaging>pom</packaging><packaging>eclipse-plugin</packaging>
<artifactId>my.project.foo.parent</artifactId><artifactId>my.project.foo</artifactId>

然后,删除(或移动)pom.xml把所有的东西都搬进去子文件夹到父文件夹。 (如果您不删除它,它可能会覆盖父级中的 pom.xml。)

关于java - 将 pom.xml 与父级合并,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38936034/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com