使用gradle将features.xml部署到nexus? [英] using gradle to deploy features.xml to nexus?

查看:189
本文介绍了使用gradle将features.xml部署到nexus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个gradle构建文件,以将features.xml文件部署到本地的nexus maven repo中。除了直接使用maven,我还没有找到任何关于如何做的例子。任何人都有如何用毕业这样做的例子?我正在附加工作maven 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>
<执行>
< 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>
<执行>
< execution>
< id> attach-artifacts< / id>
< phase> package< / phase>
< goals>
< goal> attach-artifact< / goal>
< / goals>
< configuration>
<工件>
< 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

 应用插件:'maven'

存储库{
maven {
url = mavenServer + mavenRepo
}
}

工件{
归档文件('yourxmlfile')
}

uploadArchives {
repositories {
mavenDeployer {

pom.artifactId ='yourID'

repository(url:mavenServer + mvnReleases){
authentication(username:repoUsername,password:repoPassword)
}
}
}
} $ b您的/.m2/目录中的settings.xml中的$ b



 < settings xsd =< apache maven xsd>> 
< mirrors>
< mirror>
< id> sonatype< / id>
< name> local sonatype nexus< / name>
< url> http:// localServer / nexus / content / groups / public< / url>
< mirrorOf> *,!snapshothots,!releases< / mirrorOf>
< / mirror>
< / mirrors>
< / settings>

最后一位将您的maven镜像与可释放的工件 >

I am trying to create a gradle build file to deploy a features.xml file into a local nexus maven repo. I haven't been able to find any example on how to do this except using maven directly. Anyone have any example of how to do this with gradle? I am attaching the working maven POM as well.

Thanks, --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>

解决方案

Setup locations in gradle.properties

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

In 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)
      }
    }
  }
}

in your settings.xml inside your /.m2/ directory

<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>

this last bit separates your maven mirror from your releasable artifacts

这篇关于使用gradle将features.xml部署到nexus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆