Version: 5.0.1

Update: The individual package managers are no longer actively maintained. This functionality has been replaced by Synopsys Detect.


Hub Gradle plugin overview

The Hub Gradle plugin provides the ability to generate a Black Duck I/O formatted file containing the dependency information gathered from the Gradle project. The file is generated in either the specified folder, or defaults to the root of the project. This plugin also has the ability to upload the Black Duck I/O file up to the Hub to create a code location in the Hub. To generate the file and upload the contents to the Hub, the build.gradle file must have a section for this plugin, and execute tasks specific to this plugin. As a Hub and Gradle user, the Hub Gradle plugin enables you to configure your environment to connect to the Hub server.

Note: This documentation assumes that you have familiarity with Gradle and how to use it. For more information about Gradle, refer to: https://docs.gradle.org/current/userguide/plugins.html

Hub Gradle plugin requirements 

Software Requirements 
The installation instructions in this document assume that you have the following installed and configured on your system:


The Gradle plugin is supported on the same operating systems and browsers as Black Duck Hub. 

Network Requirements 
The Hub Gradle plugin requires internet connectivity. The machine that hosts your Gradle server must be able to connect to the Hub server. 

Installation overview 

Installation pre-requisites 

Before you install the Hub Gradle plugin, ensure that:

Hub Gradle Quick Start Guide 

This section provides a simple configuration that can be used to get the Hub Gradle plugin up and running with the fewest number of steps. The steps include:

  1. Configuring the Hub Gradle build script.
  2. Configuring the Hub Gradle plugin task.
  3. Run the Hub Gradle plugin task.

Configuring the Gradle build script 

For Hub Gradle plugin versions 4.0 and higher, you can configure your Gradle build script using the following process. 
To configure the Gradle build script:

Add the following to the top of your build.gradle file.

buildscript {
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath group: 'com.blackducksoftware.integration', name: 'hub-gradle-plugin', version: 'x.x.x'
	}
}
	apply plugin: 'com.blackducksoftware.hub' buildBom;
	hubUrl = 'http://localhost:8080'
	hubUsername = 'username'
	hubPassword = 'password'
}

Configuring the Hub Gradle plugin task 

For Hub Gradle versions 4.0.0 and higher, you can configure your Hub Gradle task using the following process. 

To configure the Hub Gradle task:

  1. Update the plugin version number from x.x.x to the version to be used.
  2. Change the properties in the buildBom task to match the Hub server and credentials to be used.

Running the Hub Gradle plugin task 

For Hub Gradle plugin versions 4.0.0 and higher, you can run your Hub Gradle plugin task using the following command.

gradle buildBom 

Invoking Hub Gradle using a script

As of Black Duck Hub Gradle plugin version 5.0.0 and higher, you can invoke the Hub Gradle plugin using a script parameter.  

Info: This eliminates the need to edit your build.gradle file.


To invoke the Hub Gradle plugin using a script parameter:

Add the following lines to the init.gradle file:

initscript {
	repositories { mavenCentral() }
	dependencies { classpath 'com.blackducksoftware.integration:hub-gradle-plugin:+' }
}
rootProject {
	apply plugin: com.blackducksoftware.integration.gradle.HubGradlePlugin
}

Then, run the command:

gradle --init-script init.gradle buildBom

build.gradle with buildscript sections 

If your build.gradle file contains a buildscript section, then the steps are similar to the previous section. This section describes the changes in this scenario. The revised steps include:

  1. Ensure the correct repositories are defined.
  2. Ensure the plugin is listed as a dependency.
  3. Apply and configure the plugin.
  4. Run the plugin.

Ensuring the Hub Gradle plugin is listed as a dependency 

In the buildscript section of the build.gradle file, verify that the dependencies section is present and includes: 

dependencies { 
	classpath group: 'com.blackducksoftware.integration', name: 'hub-gradle-plugin', version: 'x.x.x' 
} 

Applying and configuring the Hub Gradle plugin 

For Hub Gradle plugin versions 4.0 and higher, you can apply and configure your Hub Gradle plugin using the following process. 

To apply and configure your Hub Gradle plugin:

  1. Add the following to your build.gradle file after the buildscripts section.

    buildscript {
    .
    .
    .
    }
    apply plugin: 'com.blackducksoftware.hub' buildBom {
    hubUrl = 'http://localhost:8080'
    hubUsername = 'username'
    hubPassword = 'password'
    }


  2. Update the plugin version number from x.x.x to the version to be used.
  3. Change the properties in the buildBom task to match the Hub server and credentials to be used.

Gradle task properties 

Add the following task properties to your build.gradle file. 

Note: When using the Hub Gradle plugin on the command line, you can override property values by using the -P and -D switches. 


blackduck_hubIgnoreFailure = true
blackduck_hubCodeLocationName = OverrideCodeLocationName
blackduck_hubProjectName = OverrideMavenProjectName
blackduck_hubVersionName = OverrideMavenProjectVersion
blackduck_hubUrl = http://YourHubUrl:8080
blackduck_hubUsername = admin
blackduck_hubPassword = password
blackduck_hubTimeout = 120
blackduck_hubProxyHost = ProxyHost
blackduck_hubProxyPort = 3128
blackduck_hubNoProxyHosts = .*google.*
blackduck_hubProxyUsername = proxyUser
blackduck_hubProxyPassword = proxypassword
blackduck_createFlatDependencyList = false
blackduck_createHubBdio = true
blackduck_deployHubBdio = false
blackduck_checkPolicies = true

Hub Gradle Plugin Release Notes 


Changes in Release 5.0.2

Changes in Release 5.0.1

Changes in Release 5.0.0

Changes in Release 4.0.0

Changes in Release 3.4.1 

Changes in Release 3.4.0

Changes in Release 3.3.0

Changes in Release 3.2.0

Changes in Release 3.1.0

Changes in Release 2.0.7