我正在尝试创建一个gradle构建文件,以将features.xml文件部署到本地nexus maven repo中。除了直接使用maven之外,我还没有找到任何关于如何执行此操作的示例。有没有任何关于如何使用gradle执行此操作的示例?我也附上了工作专家POM。
谢谢, --Christian
<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>
答案 0 :(得分:1)
在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镜像与您的可释放工件分开