Gradle

Buildkite Packages provides registry support for Gradle-based Java packages (using the Maven Publish Plugin).

Once your Java registry has been created, you can publish/upload packages (generated from your application's build) to this registry by configuring your build.gradle file with the Gradle snippet presented on your Java registry's details page.

To view and copy the required build.gradle configurations:

  1. Select Packages in the global navigation to access the Registries page.
  2. Select your Java registry on this page.
  3. Select Publish a Java Package and in the resulting dialog's Using Gradle with maven-publish plugin section, use the copy icon at the top-right of the code box to copy the Gradle code snippet and paste it into the appropriate area/s of your build.gradle file.

These build.gradle file configurations contain the:

  • Maven coordinates for your package (which you will need to manually configure yourself)
  • URL for your specific Java registry in Buildkite
  • API write token (generated by Buildkite Packages) required to publish the package to this registry.

Publish a package

The following steps describe the process above:

  1. Copy the following Gradle snippet, paste it into your gradle.build file, and modify accordingly:

    // You require these plugins
    // "java": To publish java libraries
    // "maven-publish": To publish to Maven repositories
    ["java", "maven-publish"].each {
        apply plugin : it
    }
    
    // Download standard plugins, e.g., maven-publish  from GradlePluginPortal
    repositories {
      gradlePluginPortal()
    }
    
    // Define Maven repository to publish to
    publishing {
      publications {
        maven(MavenPublication) {
    
          // MODIFY: Define your Maven coordinates of your package
          groupId = "com.name.domain.my"
          artifactId = "my-java-package-name"
          version = "my-java-package-version"
    
          // Tell gradle to publish project's jar archive
          from components.java
        }
      }
    
      repositories {
        maven {
          // Define the Buildkite repository to publish to
          url "https://buildkitepackages.com/{org.slug}/{registry.name}/maven2/"
          authentication {
            header(HttpHeaderAuthentication)
          }
          credentials(HttpHeaderCredentials) {
            name = "Authorization"
            value = "Bearer registry-write-token"
          }
        }
      }
    }
    

    where:

    • registry-write-token is the Buildkite Packages-generated API token required to publish/upload packages to your Java registry.
    • com.name.domain.my is the domain name of your Java package (in typical right-to-left order).

    • my-java-package-name is the name of your Java package.

    • my-java-package-version is the version number of your Java package.

    • {org.slug} can be obtained from the end of your Buildkite URL, after accessing Pipelines in the global navigation of your organization in Buildkite.
    • {registry.name} is the name of your Java registry.
  2. Publish your package:

    gradle publish
    

Access a package's details

A Java package's details can be accessed from this registry using the Packages section of your Java registry page.

To access your Java package's details page:

  1. Select Packages in the global navigation to access the Registries page.
  2. Select your Java registry on this page.
  3. On your Java registry page, select the package within the Packages section. The package's details page is displayed.

The package's details page provides the following information in the following sections:

  • Installation (tab): the installation instructions.
  • Contents (tab, where available): a list of directories and files contained within the package.
  • Details (tab): a list of checksum values for this package—MD5, SHA1, SHA256, and SHA512.
  • About this version: a brief (metadata) description about the package.
  • Details: details about:

    • the name of the package (typically the file name excluding any version details and extension).
    • the package version.
    • the registry the package is located in.
    • the package's visibility (based on its registry's visibility)—whether the package is Private and requires authentication to access, or is publicly accessible.
    • the distribution name / version.
    • additional optional metadata contained within the package, such as a homepage, licenses, etc.

  • Last pushed: the date when the last package was uploaded to the registry.

  • Total files: the total number of files (and directories) within the package.

  • Dependencies: the number of dependency packages required by this package.

  • Package size: the storage size (in bytes) of this package.

  • Downloads: the number of times this package has been downloaded.

Downloading a package

A Java package can be downloaded from the package's details page.

To download a package:

  1. Access the package's details.
  2. Select Download.

Installing a package

A Java package can be installed using code snippet details provided on the package's details page.

To install a package:

  1. Access the package's details.
  2. Ensure the Installation > Installation instructions section is displayed.
  3. Copy the code snippet, paste this into the build.gradle Gradle file, and execute this modified script file to install this package.

This code snippet is based on this format:

repositories {
  maven {
    url "https://buildkitepackages.com/{org.slug}/{registry.name}/maven2/"
    authentication {
      header(HttpHeaderAuthentication)
    }
    credentials(HttpHeaderCredentials) {
      name = "Authorization"
      value = "Bearer registry-read-token"
    }
  }
}

dependencies {
  compile "com.name.domain.my:my-java-package-name:my-java-package-version"
}

where:

  • {org.slug} is the org slug.
  • {registry.name} is the name of your Java registry.
  • registry-read-token is the Buildkite Packages-generated API token required to download packages to your Java registry. Both the authentication and credentials sections are not required for registries that are publicly accessible.
  • com.name.domain.my is the domain name of your Java package (in typical right-to-left order).

  • my-java-package-name is the name of your Java package.

  • my-java-package-version is the version number of your Java package.