Skip to content

Instantly share code, notes, and snippets.

@GuyPaddock
Created March 25, 2017 15:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuyPaddock/acd2222ced9e4e897891ee16b31c27b8 to your computer and use it in GitHub Desktop.
Save GuyPaddock/acd2222ced9e4e897891ee16b31c27b8 to your computer and use it in GitHub Desktop.
Getting Gradle to resolve path to agent dependencies
// 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