Skip to content

Commit

Permalink
Merge pull request #13 from blackducksoftware/ek-ext-properties
Browse files Browse the repository at this point in the history
Ek ext properties
  • Loading branch information
ekerwin committed Mar 13, 2020
2 parents baf863d + 8734e2c commit 1d3f630
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
tasks.withType(GroovyCompile) { options.encoding = 'UTF-8' }

group = 'com.synopsys.integration'
version = '1.4.1-SNAPSHOT'
version = '1.4.1'
description = 'A common plugin for all integration libraries and solutions to use.'

sourceCompatibility = 1.8
Expand Down
39 changes: 18 additions & 21 deletions src/main/groovy/com/synopsys/integration/Common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public abstract class Common implements Plugin<Project> {
public static final String PROPERTY_SYNOPSYS_OVERRIDE_INTEGRATION_LICENSE = 'synopsysOverrideIntegrationLicense'
public static final String PROPERTY_SYNOPSYS_OVERRIDE_INTEGRATION_GIT_IGNORE = 'synopsysOverrideIntegrationGitIgnore'
public static final String PROPERTY_SYNOPSYS_OVERRIDE_INTEGRATION_README = 'synopsysOverrideIntegrationReadme'
public static final String PROPERTY_BUILDSCRIPT_DEPENDENCY = 'buildscriptDependencyURL'

public static final String PROPERTY_BUILDSCRIPT_DEPENDENCY = 'buildscriptDependency'

public static final String PROPERTY_ARTIFACTORY_DEPLOYER_USERNAME = 'artifactoryDeployerUsername'
public static final String PROPERTY_ARTIFACTORY_DEPLOYER_PASSWORD = 'artifactoryDeployerPassword'
Expand Down Expand Up @@ -121,7 +120,7 @@ public abstract class Common implements Plugin<Project> {

project.repositories {
mavenLocal()
maven { url "${project.ext.downloadArtifactoryUrl}/${project.ext.artifactoryReleaseRepo}" }
maven { url "${project.ext[PROPERTY_DOWNLOAD_ARTIFACTORY_URL]}/${project.ext[PROPERTY_ARTIFACTORY_RELEASE_REPO]}" }
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
Expand Down Expand Up @@ -163,8 +162,8 @@ public abstract class Common implements Plugin<Project> {
Task javadocTask = project.tasks.getByName('javadoc')
JavaPluginConvention javaPluginConvention = project.convention.getPlugin(JavaPluginConvention.class)

javaPluginConvention.sourceCompatibility = project.ext.javaSourceCompatibility
javaPluginConvention.targetCompatibility = project.ext.javaTargetCompatibility
javaPluginConvention.sourceCompatibility = project.ext[PROPERTY_JAVA_SOURCE_COMPATIBILITY]
javaPluginConvention.targetCompatibility = project.ext[PROPERTY_JAVA_TARGET_COMPATIBILITY]

Task sourcesJarTask = project.tasks.findByName('sourcesJar')
if (sourcesJarTask == null) {
Expand Down Expand Up @@ -222,7 +221,7 @@ public abstract class Common implements Plugin<Project> {
BuildFileUtility buildFileUtility = new BuildFileUtility()
File buildFile = project.getBuildFile()

String buildscriptDependencyLocation = project.ext.buildscriptDependency
String buildscriptDependencyLocation = project.ext[PROPERTY_BUILDSCRIPT_DEPENDENCY]

project.tasks.create('jaloja') {
doLast {
Expand Down Expand Up @@ -277,13 +276,12 @@ public abstract class Common implements Plugin<Project> {
}
}


public void configureForSonarQube(Project project) {
SonarQubeExtension sonarQubeExtension = project.extensions.getByName('sonarqube')
sonarQubeExtension.properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'black-duck-software'
property 'sonar.login', project.ext.sonarQubeLogin
property 'sonar.login', project.ext[PROPERTY_SONAR_QUBE_LOGIN]
}
}

Expand All @@ -297,11 +295,11 @@ public abstract class Common implements Plugin<Project> {
}

def allTestTags = ''
if (project.ext.junitPlatformDefaultTestTags) {
allTestTags += project.ext.junitPlatformDefaultTestTags
if (project.ext[PROPERTY_JUNIT_PLATFORM_DEFAULT_TEST_TAGS]) {
allTestTags += project.ext[PROPERTY_JUNIT_PLATFORM_DEFAULT_TEST_TAGS]
}
if (project.ext.junitPlatformCustomTestTags) {
allTestTags += ',' + project.ext.junitPlatformCustomTestTags
if (project.ext[PROPERTY_JUNIT_PLATFORM_CUSTOM_TEST_TAGS]) {
allTestTags += ',' + project.ext[PROPERTY_JUNIT_PLATFORM_CUSTOM_TEST_TAGS]
}
def testTags = allTestTags.split("\\s*,\\s*")

Expand All @@ -311,23 +309,23 @@ public abstract class Common implements Plugin<Project> {
excludeTags testTags
}
description += " NOTE: This excludes those tests with ${descriptionSuffix})."
testLogging.showStandardStreams = Boolean.valueOf(project.ext.junitShowStandardStreams)
testLogging.showStandardStreams = Boolean.valueOf(project.ext[PROPERTY_JUNIT_SHOW_STANDARD_STREAMS])
}

testTags.each { testTag ->
project.tasks.create('test' + testTag.capitalize(), Test) {
useJUnitPlatform { includeTags testTag }
group = 'verification'
description = "Runs all the tests with @Tag(\"${testTag}\")."
testLogging.showStandardStreams = Boolean.valueOf(project.ext.junitShowStandardStreams)
testLogging.showStandardStreams = Boolean.valueOf(project.ext[PROPERTY_JUNIT_SHOW_STANDARD_STREAMS])
}
}

project.tasks.create('testAll', Test) {
useJUnitPlatform()
group = 'verification'
description = "Runs all the tests (ignores tags)."
testLogging.showStandardStreams = Boolean.valueOf(project.ext.junitShowStandardStreams)
testLogging.showStandardStreams = Boolean.valueOf(project.ext[PROPERTY_JUNIT_SHOW_STANDARD_STREAMS])
}
}

Expand All @@ -337,19 +335,19 @@ public abstract class Common implements Plugin<Project> {

public void configureDefaultsForArtifactory(Project project, String artifactoryRepo, Closure defaultsClosure) {
ArtifactoryPluginConvention artifactoryPluginConvention = project.convention.plugins.get('artifactory')
artifactoryPluginConvention.contextUrl = project.ext.deployArtifactoryUrl
artifactoryPluginConvention.contextUrl = project.ext[PROPERTY_DEPLOY_ARTIFACTORY_URL]
artifactoryPluginConvention.publish {
repository { repoKey = artifactoryRepo }
username = project.ext.artifactoryDeployerUsername
password = project.ext.artifactoryDeployerPassword
username = project.ext[PROPERTY_ARTIFACTORY_DEPLOYER_USERNAME]
password = project.ext[PROPERTY_ARTIFACTORY_DEPLOYER_PASSWORD]
}

if (defaultsClosure != null) {
artifactoryPluginConvention.publisherConfig.defaults(defaultsClosure)
}

project.tasks.getByName('artifactoryPublish').dependsOn {
println "artifactoryPublish will attempt uploading ${project.name}:${project.version} to ${project.ext.deployArtifactoryUrl}/${project.ext.artifactoryRepo}"
println "artifactoryPublish will attempt uploading ${project.name}:${project.version} to ${project.ext[PROPERTY_DEPLOY_ARTIFACTORY_URL]}/${project.ext[PROPERTY_ARTIFACTORY_REPO]}"
}
}

Expand Down Expand Up @@ -394,8 +392,7 @@ public abstract class Common implements Plugin<Project> {
void installFile(String downloadUrl, File projectFile) {
def downloadedFile = new URL(downloadUrl)

projectFile.withOutputStream { out -> downloadedFile.withInputStream { from -> out << from }
}
projectFile.withOutputStream { out -> downloadedFile.withInputStream { from -> out << from } }
}

}
8 changes: 4 additions & 4 deletions src/main/groovy/com/synopsys/integration/LibraryPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public class LibraryPlugin extends SimplePlugin {
}

private void configureForMavenCentralUpload(Project project) {
String sonatypeUsername = project.ext.sonatypeUsername
String sonatypePassword = project.ext.sonatypePassword
String sonatypeUsername = project.ext[PROPERTY_SONATYPE_USERNAME]
String sonatypePassword = project.ext[PROPERTY_SONATYPE_PASSWORD]
NexusStagingExtension nexusStagingExtension = project.extensions.getByName('nexusStaging')

if (null == nexusStagingExtension.packageGroup || nexusStagingExtension.packageGroup.trim().equals("")) {
Expand Down Expand Up @@ -142,9 +142,9 @@ public class LibraryPlugin extends SimplePlugin {
}

private void configureForArtifactoryUpload(Project project) {
String artifactoryRepo = project.ext.artifactorySnapshotRepo
String artifactoryRepo = project.ext[PROPERTY_ARTIFACTORY_SNAPSHOT_REPO]
if (!project.isSnapshot) {
artifactoryRepo = project.ext.artifactoryReleaseRepo
artifactoryRepo = project.ext[PROPERTY_ARTIFACTORY_RELEASE_REPO]
}

configureDefaultsForArtifactory(project, artifactoryRepo, { publications('mavenJava') })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SimplePlugin extends Common {

super.apply(project)

if (Boolean.valueOf(project.ext[Common.PROPERTY_JAVA_USE_AUTO_MODULE_NAME]) && project.ext.moduleName) {
if (Boolean.valueOf(project.ext[PROPERTY_JAVA_USE_AUTO_MODULE_NAME]) && project.ext.moduleName) {
def moduleName = project.ext.moduleName
project.tasks.getByName('jar') {
inputs.property("moduleName", moduleName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SolutionPlugin extends Common {
}

private void configureForArtifactoryUpload(Project project) {
String artifactoryRepo = project.ext.artifactoryRepo
String artifactoryRepo = project.ext[PROPERTY_ARTIFACTORY_REPO]
configureDefaultsForArtifactory(project, artifactoryRepo)
}

Expand Down

0 comments on commit 1d3f630

Please sign in to comment.