@@ -5,12 +5,12 @@ import groovy.xml.XmlUtil
55import groovy.xml.StreamingMarkupBuilder
66
77plugins {
8- id ' com.ullink.msbuild' version ' 2.14 '
9- id ' com.ullink.nuget' version ' 2.12 '
10- id ' com.ullink.nunit' version ' 1.4 '
11- id ' com.ullink.opencover' version ' 1.2 '
12- id ' net.researchgate.release' version ' 2.3.4 '
13- id ' com.github.jlouns.cpe' version ' 0.4.1 '
8+ id ' com.ullink.msbuild' version ' 2.16 '
9+ id ' com.ullink.nuget' version ' 2.15 '
10+ id ' com.ullink.nunit' version ' 1.10 '
11+ id ' com.ullink.opencover' version ' 1.7 '
12+ id ' net.researchgate.release' version ' 2.6.0 '
13+ id ' com.github.jlouns.cpe' version ' 0.5.0 '
1414 id " co.riiid.gradle" version " 0.4.2"
1515}
1616
@@ -50,41 +50,43 @@ nunit {
5050}
5151nunit. dependsOn msbuild
5252
53- task updateNuspecFile << {
54- def specFile = file(' CallfireApiClient.nuspec' )
55- def spec = new XmlSlurper (). parse(specFile)
56-
57- project. version = patchVersion(spec. metadata. version. text)
58- spec. metadata. version = project. version
59- spec. metadata. releaseNotes = file(' Changelog.txt' ). text
60- // cleanup previous lib/ and src/ files since they depend on build configuration
61- spec. files. file. findAll { it. @target == ' lib' || it. @target == ' src' }. each { it. replaceNode {} }
62-
63- def isWindowsOs = Os . isFamily(Os . FAMILY_WINDOWS )
64- def monoInstallation = " $System . env . MONO_HOME "
65- def pdbToMdbConverter
66- if (isWindowsOs) {
67- if (monoInstallation != ' null' ) {
68- pdbToMdbConverter = " $System . env . MONO_HOME " + " \\ bin\\ pdb2mdb.bat"
69- exec { commandLine = [pdbToMdbConverter, " $assemblyBinDebugDir /${ archivesBaseName} .dll" ] }
70- }
71- }
53+ task updateNuspecFile {
54+ doLast {
55+ def specFile = file(' CallfireApiClient.nuspec' )
56+ def spec = new XmlSlurper (). parse(specFile)
7257
73- spec. files. appendNode {
74- file(src : " src/**/*.cs" , target : ' src' ) {}
75- file(src : " $assemblyBinDebugDir /${ archivesBaseName} .dll" , target : ' lib' ) {}
76- file(src : " $assemblyBinReleaseDir /${ archivesBaseName} .dll.config" , target : ' lib' ) {}
77- file(src : " $assemblyBinReleaseDir /${ archivesBaseName} .xml" , target : ' lib' ) {}
58+ project. version = patchVersion(spec. metadata. version. text)
59+ spec. metadata. version = project. version
60+ spec. metadata. releaseNotes = file(' Changelog.txt' ). text
61+ // cleanup previous lib/ and src/ files since they depend on build configuration
62+ spec. files. file. findAll { it. @target == ' lib' || it. @target == ' src' }. each { it. replaceNode {} }
63+
64+ def isWindowsOs = Os . isFamily(Os . FAMILY_WINDOWS )
65+ def monoInstallation = " $System . env . MONO_HOME "
66+ def pdbToMdbConverter
7867 if (isWindowsOs) {
79- file(src : " $assemblyBinDebugDir /${ archivesBaseName} .pdb" , target : ' lib' ) {}
68+ if (monoInstallation != ' null' ) {
69+ pdbToMdbConverter = " $System . env . MONO_HOME " + " \\ bin\\ pdb2mdb.bat"
70+ exec { commandLine = [pdbToMdbConverter, " $assemblyBinDebugDir /${ archivesBaseName} .dll" ] }
71+ }
72+ }
73+
74+ spec. files. appendNode {
75+ file(src : " src/**/*.cs" , target : ' src' ) {}
76+ file(src : " $assemblyBinDebugDir /${ archivesBaseName} .dll" , target : ' lib' ) {}
77+ file(src : " $assemblyBinReleaseDir /${ archivesBaseName} .dll.config" , target : ' lib' ) {}
78+ file(src : " $assemblyBinReleaseDir /${ archivesBaseName} .xml" , target : ' lib' ) {}
79+ if (isWindowsOs) {
80+ file(src : " $assemblyBinDebugDir /${ archivesBaseName} .pdb" , target : ' lib' ) {}
81+ }
82+ file(src : " $assemblyBinDebugDir /${ archivesBaseName} .dll.mdb" , target : ' lib' ) {}
8083 }
81- file(src : " $assemblyBinDebugDir /${ archivesBaseName} .dll.mdb" , target : ' lib' ) {}
84+
85+ def fw = new FileWriter (' CallfireApiClient.nuspec' )
86+ XmlUtil . serialize(spec, fw)
87+ // have to close manually because on windows file remains locked
88+ fw. close()
8289 }
83-
84- def fw = new FileWriter (' CallfireApiClient.nuspec' )
85- XmlUtil . serialize(spec, fw)
86- // have to close manually because on windows file remains locked
87- fw. close()
8890}
8991updateNuspecFile. dependsOn msbuildDebug
9092
@@ -122,34 +124,36 @@ nugetPack {
122124}
123125nugetPack. dependsOn zipBinaries
124126
125- task prepareTestData () << {
126- def inFile = file(' src/CallfireApiClient.IntegrationTests/App.config' )
127- def xml = new XmlSlurper (). parse(inFile)
128-
129- def apiLogin
130- def apiPassword
131-
132- try {
133- apiLogin = " ${ testApiUsername} "
134- apiPassword = " ${ testApiPassword} "
135- println ([ msbuild. projects[' CallfireApiClient.IntegrationTests' ]. properties.TargetPath ])
136- } catch (Exception ex) {
137- println (" Api Username and/or Password are empty, you can't run integrationTests task, set them with -PtestApiUsername/-PtestApiPassword options" )
138- apiLogin = " login"
139- apiPassword = " password"
140- }
141-
142- if (apiLogin != ' null' && apiPassword != ' null' ) {
143- xml. appSettings. add. findAll { it. @key == ' testLogin' || it. @key == ' testPassword' }. each { it. replaceNode {} }
144- xml. appSettings. appendNode {
145- add(key : " testLogin" , value : apiLogin) {}
146- add(key : " testPassword" , value : apiPassword) {}
127+ task prepareTestData {
128+ doLast {
129+ def inFile = file(' src/CallfireApiClient.IntegrationTests/App.config' )
130+ def xml = new XmlSlurper (). parse(inFile)
131+
132+ def apiLogin
133+ def apiPassword
134+
135+ try {
136+ apiLogin = " ${ testApiUsername} "
137+ apiPassword = " ${ testApiPassword} "
138+ println ([ msbuild. projects[' CallfireApiClient.IntegrationTests' ]. properties.TargetPath ])
139+ } catch (Exception ex) {
140+ println (" Api Username and/or Password are empty, you can't run integrationTests task, set them with -PtestApiUsername/-PtestApiPassword options" )
141+ apiLogin = " login"
142+ apiPassword = " password"
143+ }
144+
145+ if (apiLogin != ' null' && apiPassword != ' null' ) {
146+ xml. appSettings. add. findAll { it. @key == ' testLogin' || it. @key == ' testPassword' }. each { it. replaceNode {} }
147+ xml. appSettings. appendNode {
148+ add(key : " testLogin" , value : apiLogin) {}
149+ add(key : " testPassword" , value : apiPassword) {}
150+ }
147151 }
152+ def fw = new FileWriter (' src/CallfireApiClient.IntegrationTests/App.config' )
153+ XmlUtil . serialize(xml, fw)
154+ // have to close manually because on windows file remains locked
155+ fw. close()
148156 }
149- def fw = new FileWriter (' src/CallfireApiClient.IntegrationTests/App.config' )
150- XmlUtil . serialize(xml, fw)
151- // have to close manually because on windows file remains locked
152- fw. close()
153157}
154158
155159task msbuildForIntegrationTests (type : com.ullink.Msbuild ) {
@@ -164,29 +168,33 @@ task integrationTests (type: com.ullink.gradle.nunit.NUnit) {
164168}
165169integrationTests. dependsOn msbuildForIntegrationTests
166170
167- task prepareReleaseData () << {
168- try {
169- println (" ${ gitHubOwner} " )
170- println (" ${ gitHubToken} " )
171- } catch (Exception ex) {
172- println (" GitHub Owner and/or Token are empty, you can't run github release task, set them with -PgitHubOwner/-PgitHubToken options" )
171+ task prepareReleaseData {
172+ doLast {
173+ try {
174+ println (" ${ gitHubOwner} " )
175+ println (" ${ gitHubToken} " )
176+ } catch (Exception ex) {
177+ println (" GitHub Owner and/or Token are empty, you can't run github release task, set them with -PgitHubOwner/-PgitHubToken options" )
178+ }
173179 }
174180}
175181prepareReleaseData. dependsOn nugetPack
176182
177- task configureCustomGitHubRelease () << {
178- github {
179- owner = " ${ gitHubOwner} "
180- repo = ' callfire-api-client-csharp'
181- token = " ${ gitHubToken} "
182- tagName = project. version
183- targetCommitish = ' master'
184- name = project. version
185- body = releaseDescription()
186- assets = [
187- ' build/dist/CallfireApiClient-' + project. version + ' .zip' ,
188- ' build/dist/CallfireApiClient.' + project. version + ' .nupkg'
189- ]
183+ task configureCustomGitHubRelease {
184+ doLast {
185+ github {
186+ owner = " ${ gitHubOwner} "
187+ repo = ' callfire-api-client-csharp'
188+ token = " ${ gitHubToken} "
189+ tagName = project. version
190+ targetCommitish = ' master'
191+ name = project. version
192+ body = releaseDescription()
193+ assets = [
194+ ' build/dist/CallfireApiClient-' + project. version + ' .zip' ,
195+ ' build/dist/CallfireApiClient.' + project. version + ' .nupkg'
196+ ]
197+ }
190198 }
191199}
192200configureCustomGitHubRelease. dependsOn prepareReleaseData
@@ -206,4 +214,4 @@ def releaseDescription() {
206214 String secondVersionEntry = releaseNotes. find(~/ Version.*/ )
207215 String currentReleaseChanges = releaseNotes. substring(0 , (secondVersionEntry == null ? releaseNotes. size() - 1 : releaseNotes. indexOf(secondVersionEntry))). trim()
208216 " $currentReleaseChanges "
209- }
217+ }
0 commit comments