1
+ #tool nuget : ? package= NUnit . ConsoleRunner & version = 3.4 .0
2
+
3
+ // Cake Addins
4
+ #addin nuget: ? package = Cake . FileHelpers & version = 2.0 .0
5
+
6
+ //////////////////////////////////////////////////////////////////////
7
+ // ARGUMENTS
8
+ //////////////////////////////////////////////////////////////////////
9
+
10
+ var target = Argument( "target", " Default") ;
11
+ var configuration = Argument( "configuration" , "Release" ) ;
12
+
13
+ var VERSION = "2.2.10" ;
14
+ var NUGET_SUFIX = "" ;
15
+
16
+ //////////////////////////////////////////////////////////////////////
17
+ // PREPARATION
18
+ //////////////////////////////////////////////////////////////////////
19
+
20
+ var solutionPath = "./MapboxJavaCore.sln" ;
21
+ var artifacts = new [ ] {
22
+ new Artifact {
23
+ AssemblyInfoPath = "./Naxam.Mapbox.MapboxJavaCore/Properties/AssemblyInfo.cs" ,
24
+ NuspecPath = "./mapboxjavacore.nuspec" ,
25
+ DownloadUrl = "http://central.maven.org/maven2/com/mapbox/mapboxsdk/mapbox-java-core/{0}/mapbox-java-core-{0}.jar" ,
26
+ JarPath = "./Naxam.Mapbox.MapboxJavaCore/Jars/mapbox-java-core.jar"
27
+ }
28
+ } ;
29
+
30
+ //////////////////////////////////////////////////////////////////////
31
+ // TASKS
32
+ //////////////////////////////////////////////////////////////////////
33
+
34
+ Task ( "Downloads" )
35
+ . Does ( ( ) =>
36
+ {
37
+ foreach ( var artifact in artifacts ) {
38
+ var downloadUrl = string . Format ( artifact . DownloadUrl , VERSION ) ;
39
+ var jarPath = string . Format ( artifact . JarPath , VERSION ) ;
40
+
41
+ DownloadFile ( downloadUrl , jarPath ) ;
42
+ }
43
+ } ) ;
44
+
45
+ Task( "Clean" )
46
+ . Does ( ( ) =>
47
+ {
48
+ CleanDirectory ( "./packages" ) ;
49
+
50
+ var nugetPackages = GetFiles ( "./*.nupkg" ) ;
51
+
52
+ foreach ( var package in nugetPackages )
53
+ {
54
+ DeleteFile ( package ) ;
55
+ }
56
+ } ) ;
57
+
58
+ Task( "Restore-NuGet-Packages" )
59
+ . IsDependentOn ( "Clean" )
60
+ . Does ( ( ) =>
61
+ {
62
+ NuGetRestore ( solutionPath ) ;
63
+ } ) ;
64
+
65
+ Task( "Build" )
66
+ . IsDependentOn ( "Downloads" )
67
+ . IsDependentOn ( "Restore-NuGet-Packages" )
68
+ . Does ( ( ) =>
69
+ {
70
+ MSBuild ( solutionPath , settings => settings . SetConfiguration ( configuration ) ) ;
71
+ } ) ;
72
+
73
+ Task( "UpdateVersion" )
74
+ . Does ( ( ) =>
75
+ {
76
+ foreach ( var artifact in artifacts ) {
77
+ ReplaceRegexInFiles ( artifact . AssemblyInfoPath , "\\ [assembly\\ : AssemblyVersion([^\\ ]]+)\\ ]" , string . Format ( "[assembly: AssemblyVersion(\" {0}\" )]" , VERSION ) ) ;
78
+ }
79
+ } ) ;
80
+
81
+ Task( "Pack" )
82
+ . IsDependentOn ( "UpdateVersion" )
83
+ . IsDependentOn ( "Build" )
84
+ . Does ( ( ) =>
85
+ {
86
+ foreach ( var artifact in artifacts ) {
87
+ NuGetPack ( artifact . NuspecPath , new NuGetPackSettings {
88
+ Version = VERSION + NUGET_SUFIX ,
89
+ // Dependencies = new []{
90
+ // new NuSpecDependency {
91
+ // Id = "Xamarin.Android.Support.v7.AppCompat",
92
+ // Version = "25.4.0"
93
+ // },
94
+ // new NuSpecDependency {
95
+ // Id = "Square.OkHttp3",
96
+ // Version = "3.8.1"
97
+ // }
98
+ // },
99
+ ReleaseNotes = new [ ] {
100
+ $ "Mapbox-Java-Core SDK - DataCollector v{ VERSION } "
101
+ }
102
+ } ) ;
103
+ }
104
+ } ) ;
105
+
106
+ //////////////////////////////////////////////////////////////////////
107
+ // TASK TARGETS
108
+ //////////////////////////////////////////////////////////////////////
109
+
110
+ Task( "Default" )
111
+ . IsDependentOn ( "Pack" ) ;
112
+
113
+ //////////////////////////////////////////////////////////////////////
114
+ // EXECUTION
115
+ //////////////////////////////////////////////////////////////////////
116
+
117
+ RunTarget( target ) ;
118
+
119
+ class Artifact {
120
+ public string AssemblyInfoPath { get ; set ; }
121
+
122
+ public string SolutionPath { get ; set ; }
123
+
124
+ public string DownloadUrl { get ; set ; }
125
+
126
+ public string JarPath { get ; set ; }
127
+
128
+ public string NuspecPath { get ; set ; }
129
+ }
0 commit comments