Skip to content

Commit 10b2492

Browse files
committed
updated to use latest standard for our instrumentation repos
1 parent 0422e72 commit 10b2492

5 files changed

Lines changed: 113 additions & 146 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
3232
- name: Build with Gradle and verifyInstrumentation
3333
run: |
34-
. ./newrelic-dependencies.sh
3534
./gradlew clean build install verifyInstrumentation
3635
3736
- name: Identify Release Type

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.java-version
22
.git
3-
.github

build.gradle

Lines changed: 111 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -3,113 +3,85 @@
33

44
// Global defaults - override here or in individual modules as needed.
55
buildscript {
6-
repositories {
7-
flatDir dirs: 'template-lib'
8-
mavenLocal()
9-
mavenCentral()
10-
gradlePluginPortal()
11-
}
12-
13-
dependencies {
14-
classpath 'gradle-templates:gradle-templates:1.5'
15-
classpath 'com.newrelic.agent.java:gradle-verify-instrumentation-plugin:3.2'
16-
}
17-
}
6+
repositories {
7+
flatDir dirs: 'template-lib'
8+
mavenLocal()
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
1812

19-
plugins {
20-
id "de.undercouch.download" version "5.0.0"
13+
dependencies {
14+
classpath 'gradle-templates:gradle-templates:1.5'
15+
classpath 'com.newrelic.agent.java:gradle-verify-instrumentation-plugin:4.0'
16+
}
2117
}
2218

2319
project.ext {
24-
group = 'com.newrelic.instrumentation.labs'
25-
javaAgentVersion = '6.4.0'
20+
group = 'com.newrelic.instrumentation.labs'
21+
javaAgentVersion = project.findProperty('java.agent.version')
2622

27-
// Aligned with minimum Java major version supported by latest Java Agent
28-
javaVersion = JavaVersion.VERSION_1_8
23+
// Aligned with minimum Java major version supported by latest Java Agent
24+
javaVersion = JavaVersion.VERSION_1_8
2925

3026
}
3127

3228
apply plugin: 'java'
33-
apply plugin: 'de.undercouch.download'
34-
35-
import templates.*
36-
import de.undercouch.gradle.tasks.download.Download
37-
38-
task getAgent(type: Download) {
39-
def rootProject = projectDir.path
40-
src 'https://repo1.maven.org/maven2/com/newrelic/agent/java/newrelic-agent/'+project.javaAgentVersion+'/newrelic-agent-'+project.javaAgentVersion+'.jar'
41-
dest projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar"
42-
}
4329

44-
task extractJars(type: Copy) {
4530

46-
from zipTree(projectDir.path+"/libs/newrelic-agent-"+project.javaAgentVersion+".jar")
47-
into projectDir.path+"/libs"
48-
}
31+
import templates.ProjectTemplate
32+
import templates.TemplatesPlugin
4933

50-
task cleanUp(type: Delete) {
51-
delete projectDir.path+'/libs/META-INF', projectDir.path+'/libs/com', projectDir.path+'/libs/mozilla'
52-
delete projectDir.path+'/libs/LICENSE', projectDir.path+'/libs/Log4j-events.dtd', projectDir.path+'/libs/THIRD_PARTY_NOTICES.md'
53-
delete fileTree(projectDir.path+'/libs') {
54-
include '**/*.xsd'
55-
include '**/*.xml'
56-
include '**/*.yml'
57-
include '**/*.properties'
58-
}
59-
}
34+
tasks.register('UpdateAgentVersion') {
35+
def matchingFiles = fileTree(dir: ".", include: "**/build.gradle")
36+
def rootPath = rootDir.absolutePath
37+
def rootBuildPath = "${rootPath}/build.gradle"
38+
def agentVersionString = "com.newrelic.agent.java:newrelic-agent:" + javaAgentVersion
6039

61-
task checkForDependencies(type: Exec) {
62-
environment "JAVAAGENTVERSION", javaAgentVersion
63-
def rootProject = projectDir.path
64-
def cmdLine = rootProject+'/newrelic-dependencies.sh'
65-
workingDir rootProject
66-
commandLine cmdLine
67-
68-
}
40+
matchingFiles.each { matchingFile ->
41+
if (matchingFile.absolutePath != rootBuildPath) {
42+
if(!matchingFile.text.contains(agentVersionString)) {
6943

70-
task buildIfNeeded {
71-
dependsOn checkForDependencies
72-
dependsOn jar
73-
tasks.findByName('jar').mustRunAfter 'checkForDependencies'
44+
}
45+
}
46+
}
7447
}
7548

76-
task createModule {
77-
dependsOn checkForDependencies
78-
description = 'Generate project files for a new instrumentation module'
79-
group = 'New Relic'
80-
doLast {
49+
tasks.register('createModule') {
50+
description = 'Generate project files for a new instrumentation module'
51+
group = 'New Relic Labs'
52+
doLast {
8153

82-
def rootProject = projectDir.path
54+
def rootProject = projectDir.path
8355

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

87-
if (projectName == null) {
88-
throw new Exception("Please specify a valid module name.")
89-
} else {
90-
projectName = projectName.trim()
91-
}
59+
if (projectName == null) {
60+
throw new Exception("Please specify a valid module name.")
61+
} else {
62+
projectName = projectName.trim()
63+
}
9264

93-
if (projectGroup == null || projectGroup.trim() == '') {
94-
projectGroup = project.ext.group
95-
} else {
96-
projectGroup = projectGroup.trim()
97-
}
65+
if (projectGroup == null || projectGroup.trim() == '') {
66+
projectGroup = project.ext.group
67+
} else {
68+
projectGroup = projectGroup.trim()
69+
}
9870

99-
def projectLibDir = new File(rootProject+'/lib')
71+
def projectLibDir = new File(rootProject + '/lib')
10072

101-
def projectPath = new File(projectName)
102-
if (projectPath.exists()) {
103-
throw new Exception(projectPath.path + ' already exists.')
104-
}
73+
def projectPath = new File(projectName)
74+
if (projectPath.exists()) {
75+
throw new Exception(projectPath.path + ' already exists.')
76+
}
10577

106-
def projectJava = new File(projectPath, 'src/main/java')
107-
def projectTest = new File(projectPath, 'src/test/java')
108-
mkdir projectJava
109-
mkdir projectTest
78+
def projectJava = new File(projectPath, 'src/main/java')
79+
def projectTest = new File(projectPath, 'src/test/java')
80+
mkdir projectJava
81+
mkdir projectTest
11082

111-
ProjectTemplate.fromRoot(projectPath) {
112-
'build.gradle' '''
83+
ProjectTemplate.fromRoot(projectPath) {
84+
'build.gradle' '''
11385
// Build.gradle generated for instrumentation module PROJECT_NAME
11486
11587
apply plugin: 'java'
@@ -119,10 +91,10 @@ task createModule {
11991
// Example:
12092
// implementation 'javax.servlet:servlet-api:2.5'
12193
122-
// New Relic Java Agent dependencies
123-
implementation 'com.newrelic.agent.java:newrelic-agent:JAVA_AGENT_VERSION'
124-
implementation 'com.newrelic.agent.java:newrelic-api:JAVA_AGENT_VERSION'
125-
implementation fileTree(include: ['*.jar'], dir: '../libs')
94+
// New Relic Labs Java Agent dependencies
95+
implementation 'com.newrelic.agent.java:newrelic-agent:' + project.findProperty('java.agent.version')
96+
implementation 'com.newrelic.agent.java:newrelic-api:' + project.findProperty('java.agent.version')
97+
implementation 'com.newrelic.agent.java:agent-bridge:' + project.findProperty('java.agent.version')
12698
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
12799
}
128100
@@ -142,63 +114,59 @@ task createModule {
142114
// passes 'javax.servlet:servlet-api:[2.2,2.5]'
143115
// exclude 'javax.servlet:servlet-api:2.4.public_draft'
144116
}'''.replace('PROJECT_GROUP', projectGroup)
145-
.replace('PROJECT_NAME', projectName)
146-
.replace('PROJECT_PATH', projectPath.path)
147-
.replace('JAVA_AGENT_VERSION', project.ext.javaAgentVersion)
148-
}
149-
150-
File settings = new File('settings.gradle')
151-
settings.append("include '$projectName'\n")
152-
println "Created module in $projectPath.path."
153-
}
117+
.replace('PROJECT_NAME', projectName)
118+
.replace('PROJECT_PATH', projectPath.path)
119+
.replace('JAVA_AGENT_VERSION', project.ext.javaAgentVersion)
120+
}
121+
122+
File settings = new File('settings.gradle')
123+
settings.append("include '$projectName'\n")
124+
println "Created module in $projectPath.path."
125+
}
154126
}
155127

156128
subprojects {
157-
repositories {
158-
mavenLocal()
159-
mavenCentral()
160-
}
161-
162-
apply plugin: 'java'
163-
apply plugin: 'eclipse'
164-
apply plugin: 'idea'
165-
apply plugin: 'com.newrelic.gradle-verify-instrumentation-plugin'
166-
167-
sourceCompatibility = project.javaVersion
168-
targetCompatibility = project.javaVersion
169-
170-
dependencies {
171-
testImplementation fileTree(dir: '../lib', include: "*.jar") // + project.javaAgentVersion
172-
testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
173-
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.javaAgentVersion
174-
}
175-
176-
task install(dependsOn: buildIfNeeded, type: Copy) {
177-
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
178-
group = 'New Relic'
179-
180-
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "
181-
182-
from jar
183-
into extDir
184-
}
185-
186-
compileJava.doFirst {
187-
tasks.findByName('checkForDependencies')
188-
}
189-
190-
install.doFirst {
191-
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR")
192-
if (extDir == null) {
193-
throw new Exception("Must set NEW_RELIC_EXTENSIONS_DIR.")
194-
}
195-
196-
if (extDir.startsWith("~" + File.separator)) {
197-
extDir = System.getProperty("user.home") + extDir.substring(1);
198-
}
199-
200-
if (!file(extDir).directory) {
201-
throw new Exception(extDir + "NEW_RELIC_EXTENSIONS_DIR, set as '" + extDir + "'is not a valid directory.")
202-
}
203-
}
129+
repositories {
130+
mavenLocal()
131+
mavenCentral()
132+
}
133+
134+
apply plugin: 'java'
135+
apply plugin: 'eclipse'
136+
apply plugin: 'idea'
137+
apply plugin: 'com.newrelic.gradle-verify-instrumentation-plugin'
138+
139+
sourceCompatibility = project.javaVersion
140+
targetCompatibility = project.javaVersion
141+
142+
dependencies {
143+
testImplementation fileTree(dir: '../lib', include: "*.jar") // + project.javaAgentVersion
144+
testImplementation 'org.nanohttpd:nanohttpd:2.3.1'
145+
testImplementation 'com.newrelic.agent.java:newrelic-agent:' + project.javaAgentVersion
146+
}
147+
148+
tasks.register('install', Copy) {
149+
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
150+
group = 'New Relic Labs'
151+
152+
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "
153+
154+
from jar
155+
into extDir
156+
}
157+
158+
install.doFirst {
159+
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR")
160+
if (extDir == null) {
161+
throw new Exception("Must set NEW_RELIC_EXTENSIONS_DIR.")
162+
}
163+
164+
if (extDir.startsWith("~" + File.separator)) {
165+
extDir = System.getProperty("user.home") + extDir.substring(1);
166+
}
167+
168+
if (!file(extDir).directory) {
169+
throw new Exception(extDir + "NEW_RELIC_EXTENSIONS_DIR, set as '" + extDir + "'is not a valid directory.")
170+
}
171+
}
204172
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java.agent.version=8.4.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)