在gradle中使用其他属性实现maven工件

时间:2015-12-16 14:09:04

标签: android maven gradle android-gradle build.gradle

在我的pom文件中,我有一个如下所示的工件:

 <artifactItem>
       <groupId>com.xyz</groupId>
       <artifactId>xyz.abc</artifactId>
       <version>1.0</version>
       <classifier>pqr</classifier>
       <type>js</type>
       <overWrite>true</overWrite>
       <outputDirectory>/opt/test</outputDirectory>
       <destFileName>test.js</destFileName>
 </artifactItem>

如何在我的build.gradle中实现它。我正在使用gradle 2.6。

抱歉,我无法发布原始代码,因此请添加一些不切实际的值。请回复

2 个答案:

答案 0 :(得分:0)

通过gradle你可以使用maven插件 您可以找到2.6 here的完整文档。

我不知道你是否可以设置所有属性,但你可以使用这样的脚本:

apply plugin: 'maven'
apply plugin: 'signing'

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

                pom.groupId = GROUP
                pom.artifactId = POM_ARTIFACT_ID
                pom.version = VERSION_NAME

                repository(url: "...") {
                    authentication(userName: "user", password: "pass")
                }
                snapshotRepository(url: "...") {
                    authentication(userName: "user", password: "pass")
                }

                pom.project {
                    name POM_NAME
                    packaging POM_PACKAGING
                    description POM_DESCRIPTION
                    url POM_URL

                    scm {
                        url POM_SCM_URL
                        connection POM_SCM_CONNECTION
                        developerConnection POM_SCM_DEV_CONNECTION
                    }

                    licenses {
                        license {
                            name POM_LICENCE_NAME
                            url POM_LICENCE_URL
                            distribution POM_LICENCE_DIST
                        }
                    }

                    developers {
                        developer {
                            id POM_DEVELOPER_ID
                            name POM_DEVELOPER_NAME
                        }
                    }
                }

            }
        }
    }

    signing {
        required { true }
        sign configurations.archives
    }    

    artifacts {
        archives xxxx
    }
}

答案 1 :(得分:0)

我创建了一个gradle任务

task test <<{
copy {
    from --dir---
    into --dir--
    rename { String fileName -> 
        fileName.replace("xyz.abc-$1.0-pqr","user-prefs")
      }
    }
 }

它对我有用。

相关问题