Skip to content

Commit

Permalink
updated samples to the latest java and spring as of Oct 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Zhdanov committed Oct 28, 2023
1 parent 7b8363c commit 00a632a
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 36 deletions.
2 changes: 2 additions & 0 deletions sample/multiple-custom-gradle-distributions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is an example of using custom Gradle distributions for projects with different setup - we create *'library'* and *'service'* distributions and a sample project which uses *'service'*.

**Note:** java 21 is required

## Custom Distributions

[custom distribution](custom-distribution) project configures two custom Gradle distribution - [library](custom-distribution/src/main/resources/init.d/library/library.gradle) and [service](custom-distribution/src/main/resources/init.d/service/service.gradle). Both of them use [shared setup](custom-distribution/src/main/resources/include).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}

bootRun {
main = 'com.mycompany.MyApplication'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=../../../custom-distribution/build/gradle-dist/gradle-4.10-test-multi-distributions-1.0-service.zip
distributionUrl=../../../custom-distribution/build/gradle-dist/gradle-8.4-test-multi-distributions-1.0-service.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'tech.harmonysoft.oss.custom-gradle-dist-plugin' version '1.8'
id 'tech.harmonysoft.oss.custom-gradle-dist-plugin' version '1.9'
}

gradleDist {
gradleVersion = '4.10'
gradleVersion = '8.4'
customDistributionVersion = '1.0'
customDistributionName = 'test-multi-distributions'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'multiple-custom-gradle-distributions'
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
apply plugin: 'java'
apply plugin: "java-library"

group 'org.my'
group "org.my"

$repository$

sourceCompatibility = 21

jar {
manifest {
attributes(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
repositories {
gradlePluginPortal()
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
initscript {
$repository$
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:3.1.5'
classpath 'io.spring.gradle:dependency-management-plugin:1.1.3'
}
}

Expand All @@ -13,8 +13,4 @@ allprojects {
apply plugin: io.spring.gradle.dependencymanagement.DependencyManagementPlugin

$common$

dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
}
}
2 changes: 2 additions & 0 deletions sample/single-custom-gradle-distribution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is an example of using custom Gradle distribution for projects with the same setup - we create a single custom distribution and use it everywhere.

**Note:** java 21 is required

## Custom Distribution

[custom-distribution](custom-distribution) project defines common distribution setup in the [setup.gradle](custom-distribution/src/main/resources/init.d).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
plugins {
id 'org.springframework.boot' version '2.0.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-web'
}

bootRun {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=../../../custom-distribution/build/gradle-dist/gradle-4.10-test-single-distribution-1.0.zip
distributionUrl=../../../custom-distribution/build/gradle-dist/gradle-8.4-test-single-distribution-1.0.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'tech.harmonysoft.oss.custom-gradle-dist-plugin' version '1.8'
id 'tech.harmonysoft.oss.custom-gradle-dist-plugin' version '1.9'
}

gradleDist {
gradleVersion = '4.10'
gradleVersion = '8.4'
customDistributionVersion = '1.0'
customDistributionName = 'test-single-distribution'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'single-custom-gradle-distribution'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repositories {
gradlePluginPortal()
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
initscript {
$repository$
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:3.1.5'
classpath 'io.spring.gradle:dependency-management-plugin:1.1.3'
}
}

allprojects {
apply plugin: 'java'
apply plugin: 'java-library'

group 'com.mycompany'
// There is a known Gradle bug that non-bundled plugins can't be applied by id in init scripts.
// That's why we apply them by class name
apply plugin: org.springframework.boot.gradle.plugin.SpringBootPlugin
apply plugin: io.spring.gradle.dependencymanagement.DependencyManagementPlugin

sourceCompatibility = 1.8
$repository$

repositories {
mavenCentral()
}
group 'com.mycompany'

dependencies {
testCompile 'junit:junit:4.12'
}
sourceCompatibility = 21

$repository$
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class CustomGradleDistributionPlugin : Plugin<Project> {
gradleVersion = extension.gradleVersion.get(),
pathsToExcludeFromContentExpansion = extension.skipContentExpansionFor.get()
)
project.logger.lifecycle("Prepared custom gradle distribution at $result.absolutePath")
project.logger.lifecycle("prepared custom gradle distribution at $result.absolutePath")
}

private fun copyBaseDistribution(baseDistribution: File, customDistribution: File) {
Expand Down Expand Up @@ -367,7 +367,7 @@ class CustomGradleDistributionPlugin : Plugin<Project> {
Files.copy(fileToInclude.toPath(), to)
}

project.logger.lifecycle("Added $fileToInclude.absolutePath to the custom gradle distribution")
project.logger.lifecycle("added $fileToInclude.absolutePath to the custom gradle distribution")
}

private fun applyTemplates(file: File, project: Project): File {
Expand Down

0 comments on commit 00a632a

Please sign in to comment.