-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
97 lines (82 loc) · 3.46 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
buildscript {
apply from: 'https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-repositories.gradle', to: buildscript
apply from: 'https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-cgp-version.gradle'
dependencies {
classpath "com.blackduck.integration:common-gradle-plugin:${managedCgpVersion}"
}
}
ext.dotNetExec = project.hasProperty('dotNetExec') ? project.getProperty('dotNetExec') : 'dotnet6'
group 'com.blackduck.integration'
version = '2.0.0-SNAPSHOT'
apply plugin: 'com.blackduck.integration.solution'
apply plugin: 'distribution'
project.tasks.create(name: 'buildSolutions') {
group 'dotnet build'
description 'Build executable for all defined operating systems'
}
project.tasks.create(name: 'testUnit', type: Exec){
group 'dotnet test'
description 'Run all Unit Tests defined inside detect-nuget-inspector-tests and generate test result'
def buildCommand = [dotNetExec, 'test', 'detect-nuget-inspector/detect-nuget-inspector.sln','--logger:junit']
doFirst {
logger.lifecycle("Running Unit Tests")
}
doLast {
logger.lifecycle("Output of unit tests located at ${buildDir}/detect-nuget-inspector/detect-nuget-inspector-tests/TestResults/TestResults.xml")
}
commandLine buildCommand
}
/*
The lines below will, for each configured solution
* Create the build task
* Create the distribution (zip) task
* Set up dependencies to the build and distribution tasks
* Add artifact to publishing
*/
HashMap<String, String> dotNetSolutions = ['mac': 'osx-x64', 'windows': 'win-x64', 'linux': 'linux-x64']
dotNetSolutions.each { os, buildCmd ->
logger.lifecycle("Creating tasks for dotnet solution::" + os)
String buildTaskName = "${os}BuildSolution"
String buildOutputDir = "${buildDir}/tmp/${os}-build"
project.tasks.create(name: buildTaskName, type: Exec) {
group 'dotnet build'
description "Create executable for ${os} in directory : ${buildOutputDir}"
def buildCommand = [dotNetExec, 'publish', 'detect-nuget-inspector/detect-nuget-inspector.sln', '-r', "${buildCmd}", '-o', buildOutputDir, '--force']
doFirst {
logger.lifecycle("Running ${dotNetExec} for OS '${os}':: " + buildCommand.toString())
}
doLast {
logger.lifecycle("Output of ${dotNetExec} for OS '${os}' located at:: " + buildOutputDir)
}
commandLine buildCommand
}
project.tasks.findByName('buildSolutions').dependsOn buildTaskName
distributions {
"${os}" {
distributionBaseName = "${project.name}-${os}"
contents {
into("/")
from { buildOutputDir }
}
}
}
String distributionTaskName = os + 'DistZip'
project.tasks.findByName(distributionTaskName).doFirst { logger.lifecycle("Creating distribution zip from ${buildOutputDir} for OS '${os}'") }
project.tasks.findByName(distributionTaskName) dependsOn buildTaskName
project.tasks.findByName('distZip').dependsOn distributionTaskName
publishing {
publications {
mavenZip(MavenPublication) {
artifact(project.tasks.findByName(distributionTaskName)) {
classifier os
extension 'zip'
}
}
}
}
}
artifactory {
publish {
defaults { publications('mavenZip') }
}
}