-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
109 lines (94 loc) · 2.73 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
98
99
100
101
102
103
104
105
106
107
108
109
task wrapper(type: Wrapper) {
gradleVersion = '3.0'
}
// allprojects means this configuration
// will be inherited by the root project itself and subprojects
allprojects {
// Artifact Id of the projct
group 'com.serverlessbook'
// Version of the project
version '1.0'
// Gradle JAVA plugin needed for JAVA support
apply plugin: 'java'
// We will be using JAVA 8, then 1.8
sourceCompatibility = 1.8
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
classpath "jp.classmethod.aws:gradle-aws-plugin:0.31"
}
}
allprojects {
apply plugin: "jp.classmethod.aws"
aws {
region = "us-east-1"
}
}
allprojects {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
}
def deploymentBucketName = "serverless-book-mgrabau-${aws.region}"
def deploymentTime = new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
allprojects {
apply plugin: "jp.classmethod.aws.s3"
task createDeploymentBucket(type: jp.classmethod.aws.gradle.s3.CreateBucketTask) {
bucketName deploymentBucketName
ifNotExists true
}
}
configure(subprojects.findAll { it.name.startsWith("lambda-") }) {
dependencies {
compile project(':lambda')
}
apply plugin: "com.github.johnrengelman.shadow"
build.finalizedBy shadowJar
def producedJarFilePath = it.tasks.shadowJar.archivePath
def s3Key = "artifacts/${it.name}/${it.version}/${deploymentTime}.jar"
task uploadArtifactsToS3(type: jp.classmethod.aws.gradle.s3.AmazonS3FileUploadTask,
dependsOn: [build, createDeploymentBucket]) {
bucketName deploymentBucketName
file producedJarFilePath
key s3Key
}
}
apply plugin: "jp.classmethod.aws.cloudformation"
cloudFormation {
capabilityIam true
templateFile project.file('cloudformation.template')
templateBucket deploymentBucketName
templateKeyPrefix "cfn-templates"
stackName "serverless-book-mgrabau"
conventionMapping.stackParams = {
return [
DeploymentBucket: deploymentBucketName,
ProjectVersion : project.version,
DeploymentTime : deploymentTime
]
}
}
awsCfnMigrateStack.dependsOn awsCfnUploadTemplate
task deploy {
configure(subprojects.findAll { it.name.startsWith("lambda-") }) {
dependsOn it.uploadArtifactsToS3
}
finalizedBy awsCfnMigrateStackAndWaitCompleted
}