Table of Contents

Deploying with Gradle is quite similar, read the official to learn more.
If you are only deploying to a single repository, here is how to do it. Firstly, add your access token to your ~/.gradle/gradle.properties.
myDomainRepositoryUsername={token}
myDomainRepositoryPassword={secret}
Warning This should be in your GRADLE_USER_HOME, not your project gradle.properties file:
Next, add the publishing plugin, as well as the maven repository:
plugins {
  `maven-publish`
}

publishing {
  repositories {
    maven {
      name = "myDomainRepository"
      url = uri("https://repo.my-domain.com/releases")
      credentials(PasswordCredentials::class)
      authentication {
        create<BasicAuthentication>("basic")
      }
    }
  }
  publications {
    create<MavenPublication>("maven") {
      groupId = "com.example"
      artifactId = "library"
      version = "1.0.0"
      from(components["java"])
    }
  }
}
To publish to several repositories, you have to declare it for all repositories (which may or may not be the same), e.g.:
# Releases token & secret
myDomainRepositoryReleasesUsername={token}
myDomainRepositoryReleasesPassword={secret}

# Snapshots token & secret
myCoolRepositorySnapshotsUsername={token}
myCoolRepositorySnapshotsPassword={secret}
And declare multiple target in build file:
maven {
  name = "myDomainRepositoryReleases"
  url = uri("https://repo.my-domain.com/releases")
  credentials(PasswordCredentials::class)
  authentication {
    create<BasicAuthentication>("basic")
  }
}
maven {
  name = "myCoolRepositorySnapshots"
  url = uri("https://repo.my-cool.com/snapshots")
  credentials(PasswordCredentials::class)
  authentication {
    create<BasicAuthentication>("basic")
  }
}

Did you find misleading or deprecated content? Maybe you just feel this section misses important elements?

Guide

Copyright © 2023 dzikoysk with ❤ panda-lang