GH-1055 Fix discrepancies in AWS gradle sample and docs

Resolves #1055
This commit is contained in:
Oleg Zhurakousky
2023-09-25 13:28:15 +02:00
parent afb419d701
commit 3c4d10e56b

View File

@@ -277,26 +277,68 @@ dependencies {
As pointed out in <<Notes on JAR Layout>>, you will need a shaded jar in order to upload it As pointed out in <<Notes on JAR Layout>>, you will need a shaded jar in order to upload it
to AWS Lambda. You can use the https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow/[Gradle Shadow Plugin] for that: to AWS Lambda. You can use the https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow/[Gradle Shadow Plugin] for that:
You can use the Spring Boot Gradle Plugin and Spring Boot Thin Gradle Plugin to generate
the <<thin-jar>>.
Below is a complete gradle file
[source,groovy] [source,groovy]
---- ----
buildscript { plugins {
dependencies { id 'java'
classpath "com.github.jengelman.gradle.plugins:shadow:${shadowPluginVersion}" id 'org.springframework.boot' version '3.2.0-M2'
id 'io.spring.dependency-management' version '1.1.3'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'maven-publish'
id 'org.springframework.boot.experimental.thin-launcher' version "1.0.31.RELEASE"
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "2023.0.0-M1")
}
assemble.dependsOn = [thinJar, shadowJar]
publishing {
publications {
maven(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
} }
} }
apply plugin: 'com.github.johnrengelman.shadow'
assemble.dependsOn = [shadowJar] shadowJar.mustRunAfter thinJar
import com.github.jengelman.gradle.plugins.shadow.transformers.* import com.github.jengelman.gradle.plugins.shadow.transformers.*
shadowJar { shadowJar {
classifier = 'aws' archiveClassifier = 'aws'
dependencies { manifest {
exclude( inheritFrom(project.tasks.thinJar.manifest)
dependency("org.springframework.cloud:spring-cloud-function-web:${springCloudFunctionVersion}")) }
} // Required for Spring
// Required for Spring
mergeServiceFiles() mergeServiceFiles()
append 'META-INF/spring.handlers' append 'META-INF/spring.handlers'
append 'META-INF/spring.schemas' append 'META-INF/spring.schemas'
@@ -309,22 +351,22 @@ shadowJar {
} }
} }
---- dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.cloud:spring-cloud-function-adapter-aws'
implementation 'org.springframework.cloud:spring-cloud-function-context'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
You can use the Spring Boot Gradle Plugin and Spring Boot Thin Gradle Plugin to generate dependencyManagement {
the <<thin-jar>>. imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
[source,groovy]
----
buildscript {
dependencies {
classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
} }
} }
apply plugin: 'org.springframework.boot'
apply plugin: 'org.springframework.boot.experimental.thin-launcher' tasks.named('test') {
assemble.dependsOn = [thinJar] useJUnitPlatform()
}
---- ----
You can find the entire sample `build.gradle` file for deploying Spring Cloud Function You can find the entire sample `build.gradle` file for deploying Spring Cloud Function