Hub Gradle Plugin


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.

Gradle

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:

  • Black Duck Hub 3.1 or higher
  • Java SE 7


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:

  • Your Gradle instance is up-to-date and fully patched.
  • You know the host name and port for the Hub server.
  • You have a user account with administrator privileges on the Hub system that you can use for the integration.
  • You have connectivity to the internet. The machine that hosts your Gradle server must be able to connect to the Hub server.

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.

build.gradle
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:

init.gradle
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: 

build.gradle
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. 

Properties

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

  • Resolved an issues wherein setting the Hub project name may cause a failure.

Changes in Release 5.0.1

  • Hub 4.0 compatibility.

Changes in Release 5.0.0

  • The Hub Gradle plugin can now be invoked using the --init-script parameter.
  • Properties values can now be overridden on the command line using the -P and -D switches.

Changes in Release 4.0.0

  • Provides the ability to generate a BDIO file.
  • Can now upload the BDIO file to the Hub server.
  • The new buildBom command replaces the previous configuration commands.
  • Addressed a mapping error occurring in Hub versions 3.5 and higher.

Changes in Release 3.4.1 

  • Resolves StringUtlils class not found from package org/apache/commons/lang

Changes in Release 3.4.0

  • Now, blackDuckHubProjectName.txt and blackDuckProjectVersionName.txt files are created with the output.

Changes in Release 3.3.0

  • Excludes certain modules from dependency gathering. Use excludedModules as a comma-separated list of module names to exclude from the output.
  • Now catches an exception instead of GradleException for all failures.
  • Now, the deployHubOutput property hubTimeout defaults to a reasonable value (120 seconds).

Changes in Release 3.2.0

  • Resolved an issue which allows the hubProjectName configuration property to contain spaces and / characters.
  • Support for the includedConfiguration task property to define which configurations should be used to retrieve the list of dependencies.

Changes in Release 3.1.0

  • When deployHubOutput fails, build still returns as successful.
  • Ability to add a Gradle task to expose the Risk report.

Changes in Release 2.0.7

  • Added support for subprojects and removed duplicate components. 



©2023 Synopsys, Inc. All Rights Reserved