Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:

- name: Build with Gradle and verifyInstrumentation
run: |
. ./newrelic-dependencies.sh
./gradlew clean build install verifyInstrumentation

- name: Identify Release Type
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
build
bin
.DS_Store
.idea
252 changes: 110 additions & 142 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,85 @@

// Global defaults - override here or in individual modules as needed.
buildscript {
repositories {
flatDir dirs: 'template-lib'
mavenLocal()
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath 'gradle-templates:gradle-templates:1.5'
classpath 'com.newrelic.agent.java:gradle-verify-instrumentation-plugin:3.2'
}
}
repositories {
flatDir dirs: 'template-lib'
mavenLocal()
mavenCentral()
gradlePluginPortal()
}

plugins {
id "de.undercouch.download" version "5.0.0"
dependencies {
classpath 'gradle-templates:gradle-templates:1.5'
classpath 'com.newrelic.agent.java:gradle-verify-instrumentation-plugin:3.2'
}
}

project.ext {
group = 'com.newrelic.instrumentation.labs'
javaAgentVersion = '6.4.0'
group = 'com.newrelic.instrumentation.labs'
javaAgentVersion = project.findProperty('java.agent.version')

// Aligned with minimum Java major version supported by latest Java Agent
javaVersion = JavaVersion.VERSION_1_8
// Aligned with minimum Java major version supported by latest Java Agent
javaVersion = JavaVersion.VERSION_1_8

}

apply plugin: 'java'
apply plugin: 'de.undercouch.download'

import templates.*
import de.undercouch.gradle.tasks.download.Download

task getAgent(type: Download) {
def rootProject = projectDir.path
src 'https://repo1.maven.org/maven2/com/newrelic/agent/java/newrelic-agent/'+project.javaAgentVersion+'/newrelic-agent-'+project.javaAgentVersion+'.jar'
dest projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar"
}

task extractJars(type: Copy) {

from zipTree(projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar")
into projectDir.path+"/libs"
}
import templates.ProjectTemplate
import templates.TemplatesPlugin

task cleanUp(type: Delete) {
delete projectDir.path+'/libs/META-INF', projectDir.path+'/libs/com', projectDir.path+'/libs/mozilla'
delete projectDir.path+'/libs/LICENSE', projectDir.path+'/libs/Log4j-events.dtd', projectDir.path+'/libs/THIRD_PARTY_NOTICES.md'
delete fileTree(projectDir.path+'/libs') {
include '**/*.xsd'
include '**/*.xml'
include '**/*.yml'
include '**/*.properties'
}
}
tasks.register('UpdateAgentVersion') {
def matchingFiles = fileTree(dir: ".", include: "**/build.gradle")
def rootPath = rootDir.absolutePath
def rootBuildPath = "${rootPath}/build.gradle"
def agentVersionString = "com.newrelic.agent.java:newrelic-agent:" + javaAgentVersion

task checkForDependencies(type: Exec) {
environment "JAVAAGENTVERSION", javaAgentVersion
def rootProject = projectDir.path
def cmdLine = rootProject+'/newrelic-dependencies.sh'
workingDir rootProject
commandLine cmdLine

}
matchingFiles.each { matchingFile ->
if (matchingFile.absolutePath != rootBuildPath) {
if(!matchingFile.text.contains(agentVersionString)) {

task buildIfNeeded {
dependsOn checkForDependencies
dependsOn jar
tasks.findByName('jar').mustRunAfter 'checkForDependencies'
}
}
}
}

task createModule {
dependsOn checkForDependencies
description = 'Generate project files for a new instrumentation module'
group = 'New Relic Labs'
doLast {
tasks.register('createModule') {
description = 'Generate project files for a new instrumentation module'
group = 'New Relic Labs'
doLast {

def rootProject = projectDir.path
def rootProject = projectDir.path

String projectGroup = TemplatesPlugin.prompt('Instrumentation Module Group (default: ' + project.ext.group + ') (Hit return to use default):\n')
String projectName = TemplatesPlugin.prompt('Instrumentation Module Name:\n')
String projectGroup = TemplatesPlugin.prompt('Instrumentation Module Group (default: ' + project.ext.group + ') (Hit return to use default):\n')
String projectName = TemplatesPlugin.prompt('Instrumentation Module Name:\n')

if (projectName == null) {
throw new Exception("Please specify a valid module name.")
} else {
projectName = projectName.trim()
}
if (projectName == null) {
throw new Exception("Please specify a valid module name.")
} else {
projectName = projectName.trim()
}

if (projectGroup == null || projectGroup.trim() == '') {
projectGroup = project.ext.group
} else {
projectGroup = projectGroup.trim()
}
if (projectGroup == null || projectGroup.trim() == '') {
projectGroup = project.ext.group
} else {
projectGroup = projectGroup.trim()
}

def projectLibDir = new File(rootProject+'/lib')
def projectLibDir = new File(rootProject + '/lib')

def projectPath = new File(projectName)
if (projectPath.exists()) {
throw new Exception(projectPath.path + ' already exists.')
}
def projectPath = new File(projectName)
if (projectPath.exists()) {
throw new Exception(projectPath.path + ' already exists.')
}

def projectJava = new File(projectPath, 'src/main/java')
def projectTest = new File(projectPath, 'src/test/java')
mkdir projectJava
mkdir projectTest
def projectJava = new File(projectPath, 'src/main/java')
def projectTest = new File(projectPath, 'src/test/java')
mkdir projectJava
mkdir projectTest

ProjectTemplate.fromRoot(projectPath) {
'build.gradle' '''
ProjectTemplate.fromRoot(projectPath) {
'build.gradle' '''
// Build.gradle generated for instrumentation module PROJECT_NAME

apply plugin: 'java'
Expand All @@ -120,9 +92,9 @@ task createModule {
// implementation 'javax.servlet:servlet-api:2.5'

// New Relic Labs Java Agent dependencies
implementation 'com.newrelic.agent.java:newrelic-agent:JAVA_AGENT_VERSION'
implementation 'com.newrelic.agent.java:newrelic-api:JAVA_AGENT_VERSION'
implementation fileTree(include: ['*.jar'], dir: '../libs')
implementation 'com.newrelic.agent.java:newrelic-agent:' + project.findProperty('java.agent.version')
implementation 'com.newrelic.agent.java:newrelic-api:' + project.findProperty('java.agent.version')
implementation 'com.newrelic.agent.java:agent-bridge:' + project.findProperty('java.agent.version')
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
}

Expand All @@ -142,63 +114,59 @@ task createModule {
// passes 'javax.servlet:servlet-api:[2.2,2.5]'
// exclude 'javax.servlet:servlet-api:2.4.public_draft'
}'''.replace('PROJECT_GROUP', projectGroup)
.replace('PROJECT_NAME', projectName)
.replace('PROJECT_PATH', projectPath.path)
.replace('JAVA_AGENT_VERSION', project.ext.javaAgentVersion)
}

File settings = new File('settings.gradle')
settings.append("include '$projectName'\n")
println "Created module in $projectPath.path."
}
.replace('PROJECT_NAME', projectName)
.replace('PROJECT_PATH', projectPath.path)
.replace('JAVA_AGENT_VERSION', project.ext.javaAgentVersion)
}

File settings = new File('settings.gradle')
settings.append("include '$projectName'\n")
println "Created module in $projectPath.path."
}
}

subprojects {
repositories {
mavenLocal()
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.newrelic.gradle-verify-instrumentation-plugin'

sourceCompatibility = project.javaVersion
targetCompatibility = project.javaVersion

dependencies {
testImplementation fileTree(dir: '../lib', include: "*.jar") // + project.javaAgentVersion
testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.javaAgentVersion
}

task install(dependsOn: buildIfNeeded, type: Copy) {
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
group = 'New Relic Labs'

def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "

from jar
into extDir
}

compileJava.doFirst {
tasks.findByName('checkForDependencies')
}

install.doFirst {
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR")
if (extDir == null) {
throw new Exception("Must set NEW_RELIC_EXTENSIONS_DIR.")
}

if (extDir.startsWith("~" + File.separator)) {
extDir = System.getProperty("user.home") + extDir.substring(1);
}

if (!file(extDir).directory) {
throw new Exception(extDir + "NEW_RELIC_EXTENSIONS_DIR, set as '" + extDir + "'is not a valid directory.")
}
}
repositories {
mavenLocal()
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.newrelic.gradle-verify-instrumentation-plugin'

sourceCompatibility = project.javaVersion
targetCompatibility = project.javaVersion

dependencies {
testImplementation fileTree(dir: '../lib', include: "*.jar") // + project.javaAgentVersion
testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.javaAgentVersion
}

tasks.register('install', Copy) {
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
group = 'New Relic Labs'

def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "

from jar
into extDir
}

install.doFirst {
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR")
if (extDir == null) {
throw new Exception("Must set NEW_RELIC_EXTENSIONS_DIR.")
}

if (extDir.startsWith("~" + File.separator)) {
extDir = System.getProperty("user.home") + extDir.substring(1);
}

if (!file(extDir).directory) {
throw new Exception(extDir + "NEW_RELIC_EXTENSIONS_DIR, set as '" + extDir + "'is not a valid directory.")
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.agent.version=8.4.0
34 changes: 16 additions & 18 deletions rxjava1-1.1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@

// Build.gradle generated for instrumentation module rxjava1-1.1

apply plugin: 'java'

dependencies {
implementation 'io.reactivex:rxjava:1.1.0'
implementation 'io.reactivex:rxjava:1.1.0'

// New Relic Labs Java Agent dependencies
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0'
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0'
implementation fileTree(include: ['*.jar'], dir: '../libs')
// New Relic Labs Java Agent dependencies
implementation 'com.newrelic.agent.java:newrelic-agent:' + project.findProperty('java.agent.version')
implementation 'com.newrelic.agent.java:newrelic-api:' + project.findProperty('java.agent.version')
implementation 'com.newrelic.agent.java:agent-bridge:' + project.findProperty('java.agent.version')

testImplementation 'junit:junit:4.12'
testImplementation 'com.newrelic.agent.java:newrelic-agent:6.4.0'
testImplementation 'com.newrelic.agent.java:newrelic-api:6.4.0'
testImplementation fileTree(include: ['*.jar'], dir: '../libs')
testImplementation 'junit:junit:4.12'
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.findProperty('java.agent.version')
testImplementation 'com.newrelic.agent.java:newrelic-api:' + project.findProperty('java.agent.version')
}

jar {
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.rxjava1-1.1'
attributes 'Implementation-Vendor': 'New Relic Labs'
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
attributes 'Implementation-Version': 1.1
}
manifest {
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.rxjava1-1.1'
attributes 'Implementation-Vendor': 'New Relic Labs'
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
attributes 'Implementation-Version': 1.1
}
}

verifyInstrumentation {
passes 'io.reactivex:rxjava:[1.1.0,)'
excludeRegex '.*RC[0-9]'
passes 'io.reactivex:rxjava:[1.1.0,)'
excludeRegex '.*RC[0-9]'
}
Loading
Loading