如何上传多个机器人的档案(每味)多个、机器人、上传、档案

2023-09-06 02:16:51 作者:人间不值得

我想上传每个项目的多个工件W / maven的摇篮插件:

http://www.gradle.org/docs/current/userguide/maven_plugin.html

  53.6.4.1。每个项目中的多个工件

Maven的只能处理每个项目一个假象。这反映在Maven的POM的结构。我们认为,有很多情况下是有意义的有每个项目一个以上的神器。在这种情况下,你需要生成多个多金属氧酸盐。在这种情况下,你必须明确地声明要发布到Maven仓库每个工件。该MavenDeployer和MavenInstaller都为这提供了一个API:

例53.9。多POMS的产生

build.gradle
uploadArchives {
    库{
        mavenDeployer {
            库(URL:文件://本地主机的/ tmp / myRepo /)
            addFilter(API){神器,文件 - >
                artifact.name ==API
            }
            addFilter('服务'){神器,文件 - >
                artifact.name =='服务'
            }
            POM(API)。版本='mySpecialMavenVersion
        }
    }
}
您需要声明一个过滤器要发布的每个工件。该过滤器定义了哪些摇篮神器它接受一个布尔EX pression。每个过滤器都有一个与之关联的POM,你可以配置。要了解更多关于这看看PomFilterContainer及其相关的类。
 

真的什么,我试图做的是上传不同的档案我生成不同的口味。

下面是我的项目build.gradle文件:

 应用插件:com.android.library
应用插件:行家

集团com.test
版本0.0.1

安卓{
    compileSdkVersion 19
    buildToolsVersion21.1.1

    defaultConfig {
        的minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        推出 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
        }
    }

    lintOptions {
        abortOnError假
    }

    productFlavors {
        flavor1 {}
        flavor2 {}
    }

    packagingOptions {
        不包括META-INF /许可证
        不包括META-INF / LICENSE.TXT
        不包括META-INF /注意事项
        不包括META-INF / NOTICE.txt
    }
}

uploadArchives {
    库{
        mavenDeployer {
            库(URL:文件:// $ {System.properties ['的user.home]} /.m2/repository)

            addFilter('debugFlavor1'){神器,文件 - >
                artifact.name.contains(debugFlavor1)
            }
            addFilter('releaseFlavor1'){神器,文件 - >
                artifact.name.contains(releaseFlavor1)
            }
            addFilter('debugFlavor2'){神器,文件 - >
                artifact.name.contains(debugFlavor2)
            }
            addFilter('releaseFlavor2'){神器,文件 - >
                artifact.name.contains(releaseFlavor2)
            }

            POM(调试)的artifactId = $ {artifactId的} + - $ {味} +-debug
            POM('释放')的artifactId = $ {artifactId的} + - $ {}味
        }
    }
}


依赖{
    编译com.android.support:support-v4:21.0.2
    编译org.apache.commons:公地lang3:3.3.2
}
 
档案收集如何更快 用 档案管理机器人 ,100人同步上传

是这样的可能吗?

我要如何在每个发布的artifactId和味道?我用$ {artifactId的}和$ {}味以占位符,但我知道这是不对的。

编辑:

好吧,我想通了,如何让不同的神器针对每种口味。的关键之一是,设置:

  publishNonDefault真
 

然而,当我这样做,我没有得到的每个工件POM文件。我有需要的传递依赖被拉的,我不认为他们会被拉在没有POM。

下面是我目前的摇篮剧本,我如何才能为每个生成的聚甲醛。

 应用插件:com.android.library
应用插件:行家

集团com.test
版本0.0.1

安卓{
    compileSdkVersion 19
    buildToolsVersion21.1.1
    publishNonDefault真

    defaultConfig {
        的minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        推出 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
        }
    }

    lintOptions {
        abortOnError假
    }

    packagingOptions {
        不包括META-INF /许可证
        不包括META-INF / LICENSE.TXT
        不包括META-INF /注意事项
        不包括META-INF / NOTICE.txt
    }

    productFlavors {
        flavor1 {}
        flavor2 {}
    }
}

uploadArchives {
    库{
        mavenDeployer {
            库(URL:文件:// $ {System.properties ['的user.home]} /.m2/repository)

            addFilter('flavor1Release'){神器,文件 - >
                artifact.attributes.classifier.equals(flavor1Release)
            }
            addFilter('flavor2Release'){神器,文件 - >
                artifact.attributes.classifier.equals(flavor2Release)
            }

            POM('flavor1Release')。artifactId的= project.archivesBaseName +-flavor1
            POM('flavor2Release')的artifactId = project.archivesBaseName +-flavor2。
        }
    }
}

依赖{
    编译com.android.support:support-v4:21.0.2
    编译org.apache.commons:公地lang3:3.3.2
}
 

解决方案

//我曾尝试下面的方法,并能上传多个jar文件。 //希望这帮助了......

 进口org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact

// jarfilename1和jarfilename2是两个文件,​​获取载
//确保的artifactId和文件名是相同的


应用插件:Java的
应用插件:行家


文物{
    档案馆新DefaultPublishArtifact(jarfileName1,罐子,瓶子,空,新的Date(),新的文件(建/,jarfilename1.jar))
    档案馆新DefaultPublishArtifact(jarfileName2,罐子,瓶子,空,新的Date(),新的文件(建/,jarfilename2.jar))
}

uploadArchives {
    库{
    mavenDeployer {
        库(URL:$ archivaUrl){
        认证(用户名:$ USERNAME,密码:$密码)
        }

        // addfilter为多聚甲醛上传
        addFilter(jarfileName1){神器,文件 - >
                      artifact.name ==jarfileName1
                     }
        addFilter(jarfileName2){神器,文件 - >
                       artifact.name ==jarfileName2
                      }

        //创建聚甲醛文件和添加实体
        POM(jarfileName1)。版本=1.1.1
        POM(jarfileName1)的groupId ='what.so.ever
        POM(jarfileName1)的artifactId ='jarfilename1

        POM(jarfileName2)。版本=1.1.1
        POM(jarfileName2)的groupId ='what.so.ever
        POM(jarfileName2)的artifactId ='jarfilename2
    }
    }
}
 

I am trying to upload multiple artifacts per project w/ the maven gradle plugin:

http://www.gradle.org/docs/current/userguide/maven_plugin.html

53.6.4.1. Multiple artifacts per project

Maven can only deal with one artifact per project. This is reflected in the structure of the Maven POM. We think there are many situations where it makes sense to have more than one artifact per project. In such a case you need to generate multiple POMs. In such a case you have to explicitly declare each artifact you want to publish to a Maven repository. The MavenDeployer and the MavenInstaller both provide an API for this:

Example 53.9. Generation of multiple poms

build.gradle
uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://localhost/tmp/myRepo/")
            addFilter('api') {artifact, file ->
                artifact.name == 'api'
            }
            addFilter('service') {artifact, file ->
                artifact.name == 'service'
            }
            pom('api').version = 'mySpecialMavenVersion'
        }
    }
}
You need to declare a filter for each artifact you want to publish. This filter defines a boolean expression for which Gradle artifact it accepts. Each filter has a POM associated with it which you can configure. To learn more about this have a look at PomFilterContainer and its associated classes.

Really what I am trying to do is to upload different archives for different flavors of my build.

Here is my projects build.gradle file:

apply plugin: 'com.android.library'
apply plugin: 'maven'

group 'com.test'
version '0.0.1'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        abortOnError false
    }

    productFlavors {
        flavor1 { }
        flavor2 { }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://${System.properties['user.home']}/.m2/repository")

            addFilter('debugFlavor1') { artifact, file ->
                artifact.name.contains("debugFlavor1")
            }
            addFilter('releaseFlavor1') { artifact, file ->
                artifact.name.contains("releaseFlavor1")
            }
            addFilter('debugFlavor2') { artifact, file ->
                artifact.name.contains("debugFlavor2")
            }
            addFilter('releaseFlavor2') { artifact, file ->
                artifact.name.contains("releaseFlavor2")
            }

            pom('debug').artifactId = ${artifactId} + "-" ${flavor} + "-debug"
            pom('release').artifactId = ${artifactId} + "-" ${flavor}
        }
    }
}


dependencies {
    compile 'com.android.support:support-v4:21.0.2'
    compile 'org.apache.commons:commons-lang3:3.3.2'
}

Is something like this possible?

How do I get at the artifactId and flavor in each publish? I used ${artifactId} and ${flavor} as placeholders but I know that is not right.

EDIT:

Alright I figured out how to get a different artifact for each flavor. One of the keys was to set the:

publishNonDefault true

However when I do that I do not get a pom file for each artifact. I have transitive dependencies that need to be pulled in and I don't think they will get pulled in without a pom.

Here is my current gradle script, how do I get a pom generated for each.

apply plugin: 'com.android.library'
apply plugin: 'maven'

group 'com.test'
version '0.0.1'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.1"
    publishNonDefault true

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
    }

    productFlavors {
        flavor1 {}
        flavor2 {}
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://${System.properties['user.home']}/.m2/repository")

            addFilter('flavor1Release') { artifact, file ->
                artifact.attributes.classifier.equals("flavor1Release")
            }
            addFilter('flavor2Release') { artifact, file ->
                artifact.attributes.classifier.equals("flavor2Release")
            }

            pom('flavor1Release').artifactId = project.archivesBaseName + "-flavor1"
            pom('flavor2Release').artifactId = project.archivesBaseName + "-flavor2";
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:21.0.2'
    compile 'org.apache.commons:commons-lang3:3.3.2'
}

解决方案

// I have tried the following way and was able to upload multiple jar files. // hope this help out....

import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact

// jarfilename1 and jarfilename2 are the two files that gets upload
// make sure the artifactID and the file name are the same


apply plugin: 'java'
apply plugin: 'maven'


artifacts{
    archives new DefaultPublishArtifact("jarfileName1", "jar", "jar", null, new Date(), new File("build/", "jarfilename1.jar"))
    archives new DefaultPublishArtifact("jarfileName2", "jar", "jar", null, new Date(), new File("build/", "jarfilename2.jar"))
}

uploadArchives {
    repositories {
    mavenDeployer {
        repository(url: "$archivaUrl") {
        authentication(userName: "$userName", password: "$passWord")
        }

        // addfilter for multiple pom upload 
        addFilter("jarfileName1") {artifact, file ->
                      artifact.name == "jarfileName1"
                     }
        addFilter("jarfileName2") {artifact, file ->
                       artifact.name == "jarfileName2"
                      }

        //Creating pom files and adding the Entity
        pom("jarfileName1").version ='1.1.1'
        pom("jarfileName1").groupId ='what.so.ever'
        pom("jarfileName1").artifactId ='jarfilename1'

        pom("jarfileName2").version ='1.1.1'
        pom("jarfileName2").groupId ='what.so.ever'
        pom("jarfileName2").artifactId ='jarfilename2'
    }
    }
}