Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added necessary build.gradle file changes for Gradle 7+ #30

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ subprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/release" }
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-milestone" }
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
6 changes: 3 additions & 3 deletions chapter02/chapter02.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ subprojects {

/*Task that copies all the dependencies under build/libs */
task copyDependencies(type: Copy) {
from configurations.compile
from configurations.implementation
into 'build/libs'
}

dependencies {
compile spring.context, misc.slf4jJcl, misc.logback
testCompile testing.junit
implementation spring.context, misc.slf4jJcl, misc.logback
testImplementation testing.junit
}
}

2 changes: 1 addition & 1 deletion chapter02/hello-world/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch2.HelloWorldSpringDI",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ private MessageSupportFactory() {
props.load(this.getClass().getResourceAsStream("/msf.properties"));
String rendererClass = props.getProperty("renderer.class");
String providerClass = props.getProperty("provider.class");
renderer = (MessageRenderer) Class.forName(rendererClass).newInstance();
provider = (MessageProvider) Class.forName(providerClass).newInstance();
renderer = (MessageRenderer) Class.forName(rendererClass).getDeclaredConstructor().newInstance();
provider = (MessageProvider) Class.forName(providerClass).getDeclaredConstructor().newInstance();
} catch (Exception ex) {
ex.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion chapter03/bean-aliases/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch3.xml.BeanNameAliasing",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
2 changes: 1 addition & 1 deletion chapter03/bean-autowiring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch3.xml.Target",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
2 changes: 1 addition & 1 deletion chapter03/bean-inheritance/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch3.xml.InheritanceDemo",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
2 changes: 1 addition & 1 deletion chapter03/bean-instantiation-mode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch3.NonSingletonDemo",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
4 changes: 2 additions & 2 deletions chapter03/cdl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.CDLDemo",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
8 changes: 4 additions & 4 deletions chapter03/chapter03.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ subprojects {

/*Task that copies all the dependencies under build/libs */
task copyDependencies(type: Copy) {
from configurations.compile
from configurations.implementation
into 'build/libs'
}

dependencies {
compile spring.context, misc.slf4jJcl, misc.logback
testCompile testing.junit
implementation spring.context, misc.slf4jJcl, misc.logback
testImplementation testing.junit
}
}
}
8 changes: 7 additions & 1 deletion chapter03/collections/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
dependencies {
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
implementation 'javax.annotation:javax.annotation-api:1.3.2'

}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.annotated.CollectionInjection",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
8 changes: 4 additions & 4 deletions chapter03/constructor-injection/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
dependencies {
compile project(':chapter02:hello-world')
compile spring.context, misc.slf4jJcl, misc.logback
testCompile testing.junit
implementation project(':chapter02:hello-world')
implementation spring.context, misc.slf4jJcl, misc.logback
testImplementation testing.junit
}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.annotated.ConstructorConfusion",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
10 changes: 5 additions & 5 deletions chapter03/dependency-pull/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
dependencies {
compile project(':chapter02:hello-world')
compile spring.context, misc.slf4jJcl, misc.logback
testCompile testing.junit
implementation project(':chapter02:hello-world')
implementation spring.context, misc.slf4jJcl, misc.logback
testImplementation testing.junit
}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.DependencyPull",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
2 changes: 1 addition & 1 deletion chapter03/field-injection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.annotated.FieldInjection",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
4 changes: 2 additions & 2 deletions chapter03/injection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.xml.InjectRef",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
4 changes: 2 additions & 2 deletions chapter03/method-injection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.LookupDemo",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
4 changes: 2 additions & 2 deletions chapter03/method-replacement/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.MethodReplacementDemo",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
4 changes: 2 additions & 2 deletions chapter03/nesting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.HierarchicalAppContextUsage",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
10 changes: 5 additions & 5 deletions chapter03/setter-injection/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
dependencies {
compile project(':chapter02:hello-world')
compile spring.context, misc.slf4jJcl, misc.logback
testCompile testing.junit
implementation project(':chapter02:hello-world')
implementation spring.context, misc.slf4jJcl, misc.logback
testImplementation testing.junit
}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.DeclareSpringComponents",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
2 changes: 1 addition & 1 deletion chapter03/simple-types/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch3.annotated.InjectSimpleSpel",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
2 changes: 1 addition & 1 deletion chapter04/application-context-aware/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch4.DestructiveBeanWithInterface",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void setFilePath(String filePath) {
this.filePath = filePath;
}

public static void main(String... args) throws Exception {
public static void main(String... args) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:spring/app-context-annotation.xml");
ctx.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public class ShutdownHookBean implements ApplicationContextAware {
private ApplicationContext ctx;

/** @Implements {@link ApplicationContextAware#setApplicationContext(ApplicationContext)} }*/
public void setApplicationContext(ApplicationContext ctx)
throws BeansException {
public void setApplicationContext(ApplicationContext ctx) throws BeansException {

if (ctx instanceof GenericApplicationContext) {
((GenericApplicationContext) ctx).registerShutdownHook();
Expand Down
2 changes: 1 addition & 1 deletion chapter04/bean-init-method/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jar {
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch4.Singer",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
"Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
)
}
}
2 changes: 1 addition & 1 deletion chapter04/bean-name-aware/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jar {
attributes( "Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch4.NamedSingerDemo",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}

12 changes: 6 additions & 6 deletions chapter04/boot-simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/release" }
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-milestone" }
}

Expand All @@ -17,14 +17,14 @@ buildscript {
apply plugin: 'org.springframework.boot'

dependencies {
compile boot.starter
implementation boot.starter
}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch4.Application",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
10 changes: 5 additions & 5 deletions chapter04/boot-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/release" }
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-milestone" }
}

Expand All @@ -17,14 +17,14 @@ buildscript {
apply plugin: 'org.springframework.boot'

dependencies {
compile boot.starterWeb
implementation boot.starterWeb
}

jar {
manifest {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch4.WebApplication",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
8 changes: 4 additions & 4 deletions chapter04/chapter04.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ subprojects {

/*Task that copies all the dependencies under build/libs */
task copyDependencies(type: Copy) {
from configurations.compile
from configurations.implementation
into 'build/libs'
}

dependencies {
//we specify these dependencies for all submodules, except the boot module, that defines its own
if (!project.name.contains("boot")) {
compile spring.context,misc.slf4jJcl, misc.logback
implementation spring.context,misc.slf4jJcl, misc.logback
}
testCompile testing.junit
testImplementation testing.junit
}
}
}
4 changes: 2 additions & 2 deletions chapter04/disposable-bean/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ jar {
attributes("Created-By" : "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class" : "com.apress.prospring5.ch4.DestructiveBeanWithInterface",
"Class-Path" : configurations.compile.collect { it.getName() }.join(' '))
"Class-Path" : configurations.runtimeClasspath.files.collect { it.getName() }.join(' '))
}
}
}
Loading