Created
March 25, 2017 15:52
-
-
Save GuyPaddock/acd2222ced9e4e897891ee16b31c27b8 to your computer and use it in GitHub Desktop.
Getting Gradle to resolve path to agent dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEGIN: Dynamic agent JAR config | |
configurations { | |
runtimeAgent | |
} | |
// END: Dynamic agent JAR config | |
buildscript { | |
ext { | |
springBootVersion = '1.5.2.RELEASE' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | |
} | |
} | |
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'org.springframework.boot' | |
jar { | |
baseName = 'sample' | |
version = '0.0.1-SNAPSHOT' | |
} | |
sourceCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile('org.springframework.boot:spring-boot-starter-aop') | |
compile("org.springframework.boot:spring-boot-starter-web") | |
testCompile('org.springframework.boot:spring-boot-starter-test') | |
// BEGIN: Dynamic agent JAR config | |
runtimeAgent("org.aspectj:aspectjweaver") | |
runtimeAgent("org.springframework:spring-instrument") | |
// END: Dynamic agent JAR config | |
} | |
// BEGIN: Dynamic agent JAR config | |
test.doFirst { | |
configurations.runtimeAgent.each { | |
File jarFile -> | |
jvmArgs("-javaagent:${jarFile.absolutePath}") | |
} | |
} | |
bootRun.doFirst { | |
configurations.runtimeAgent.each { | |
File jarFile -> | |
jvmArgs("-javaagent:${jarFile.absolutePath}") | |
} | |
} | |
// END: Dynamic agent JAR config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment