gpt4 book ai didi

maven - 使用gradle将features.xml部署到关系?

转载 作者:行者123 更新时间:2023-12-03 03:24:36 24 4
gpt4 key购买 nike

我正在尝试创建gradle构建文件,以将features.xml文件部署到本地nexus maven存储库中。除了直接使用maven之外,我无法找到任何有关如何执行此操作的示例。有人有使用gradle进行此操作的任何示例吗?我还附上了工作中的Maven POM。

谢谢,
- 基督教

<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>company.dept</groupId>
<artifactId>deploy-feature</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>feature.xml</name>
<distributionManagement>
<repository>
<id>nexus.repo</id>
<url>http://nexus:80/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/features.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

最佳答案

在gradle.properties中设置位置

mavenServer=http://localServer:8042
mavenRepo=/nexus/content/groups/public
mavenReleases=/nexus/content/repositories/releases/
repoUsername=admin
repoPassword=password

在build.gradle中
apply plugin: 'maven'

repositories {
maven {
url = mavenServer+mavenRepo
}
}

artifacts {
archives file('yourxmlfile')
}

uploadArchives {
repositories {
mavenDeployer {

pom.artifactId = 'yourID'

repository(url: mavenServer+mvnReleases) {
authentication(username:repoUsername, password:repoPassword)
}
}
}
}

在/.m2/目录内的settings.xml中
<settings xsd="<apache maven xsd>">
<mirrors>
<mirror>
<id>sonatype</id>
<name>local sonatype nexus</name>
<url>http://localServer/nexus/content/groups/public</url>
<mirrorOf>*, !snapshots, !releases</mirrorOf>
</mirror>
</mirrors>
</settings>

最后一点将您的Maven镜像与 可释放的 Artifact 分离

关于maven - 使用gradle将features.xml部署到关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13631260/

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