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
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
fetch-depth: 0


- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'temurin'


Expand All @@ -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
17 changes: 9 additions & 8 deletions apache-axis2-2.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
apply plugin: 'java'

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

dependencies {
implementation 'org.apache.axis2:axis2-kernel:2.0.0'
implementation 'org.apache.axis2:axis2-transport-http:2.0.0'
implementation 'jakarta.servlet:jakarta.servlet-api:6.0.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 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')
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
}

Expand All @@ -30,7 +31,7 @@ jar {
}

verifyInstrumentation {
passes ('org.apache.axis2:axis2-transport-http:[2.0.0,)') {
compile( 'jakarta.servlet:jakarta.servlet-api:6.0.0')
passesOnly ('org.apache.axis2:axis2-transport-http:[2.0.0,)') {
implementation('jakarta.servlet:jakarta.servlet-api:6.0.0')
}
}
13 changes: 6 additions & 7 deletions apache-axis2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.axis2/axis2
implementation 'org.apache.axis2:axis2-kernel:1.4.1'


// 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 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')
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
}

Expand All @@ -25,6 +24,6 @@ jar {
}

verifyInstrumentation {
passes 'org.apache.axis2:axis2-kernel:[1.4.1,1.5)'
passes 'org.apache.axis2:axis2-transport-http:[1.5,2.0.0)'
passesOnly 'org.apache.axis2:axis2-kernel:[1.4,1.5)'
passesOnly 'org.apache.axis2:axis2-transport-http:[1.5,2.0.0)'
}
255 changes: 113 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:4.0'
}
}

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,62 @@ 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'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

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.6.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading