如何将Gradle项目发布到Azure工件?

niknxzdl  于 2023-01-31  发布在  其他
关注(0)|答案(1)|浏览(141)

我正在尝试使用以下命令将jar发布到Azure Artifacts:./gradlew publish。我没有遇到任何错误。Gradle让它看起来很成功,甚至stacktrace看起来都像发布命令成功了。但是当我打开Azure工件提要时,没有任何东西连接到提要。我还尝试了./gradlew publishAllPublicationsToMyFeedRepository,结果相同。请将评论视为我尝试让它工作的多次尝试组合:
build.gradle:

plugins { 
        id 'java-library' apply true
        id "net.linguica.maven-settings" version "0.5" apply true
        id 'maven-publish' apply true
    }
    dependencies {
        testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
    }
    test {
        useJUnitPlatform()
    }
    jar {
        manifest {
            attributes('Main-Class': 'com.myapp.LanguageApp.SayHello')
        }
    }
    repositories {
        mavenCentral()
        mavenLocal()
        // maven {
        //     credentials {
        //      // I replaced the username with a PAT name, and password with PAT token
        //             username "username"
        //             password "password"
        //     }
        //     url 'https://pkgs.dev.azure.com/username/azure-artifacts/_packaging/MyFeed/maven/v1'
        //     name 'MyFeed'
        //     authentication {
        //         basic(BasicAuthentication)
        //     }
        // }
    }
    publishing {
        publications {}
        repositories {
            maven {
                url 'https://pkgs.dev.azure.com/username/azure-artifacts/_packaging/MyFeed/maven/v1'
                name 'MyFeed'
                // authentication {
                //     basic(BasicAuthentication)
                // }
                credentials {
                // I replaced the username with a PAT name, and password with PAT token
                    username "username"
                    password "password"
                }
            }
        }
    }

settings.gradle:

rootProject.name = 'gradle-project'

~/. m2/设置.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>MyFeed</id>
      /// yes, I replaced the username with a PAT name, and password with PAT token
      <username>username</username>
      <password>password</password>
    </server>
  </servers>
</settings>
wpx232ag

wpx232ag1#

所以我会回答我自己的问题。我在build.gradle中遗漏了组和版本。所以gradle实际上成功地发布了我的工件,它只需要组和版本来识别特定的工件。

group: thegroup
version: theversion

相关问题