Skip to content

Commit

Permalink
Move react app to root and legacy app entrypoint to /welcome
Browse files Browse the repository at this point in the history
  • Loading branch information
dsellarsnr committed Oct 11, 2024
1 parent a5386a8 commit 93d2386
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ logs/
/client/node_modules
.idea/

src/main/resources/static/resources/react/
src/main/resources/static/assets
src/main/resources/static/index.html

.kotlin/*

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ NEW_RELIC_LICENSE_KEY=12345 ./gradlew bootRun
```
Substitute 12345 with your New Relic license key.

You can then access petclinic here: http://localhost:8080/
You can then access petclinic here:
- react: http://localhost:8081
- legacy app: http://localhost:8081/welcome

The main page will have some links that exercise auto and manual instrumentation in different modes.

Expand Down
23 changes: 12 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ dependencies {
}

bootRun {
dependsOn 'downloadNewRelicAgent','buildFrontEnd','build'
mustRunAfter 'downloadNewRelicAgent','buildFrontEnd','build'
dependsOn 'downloadNewRelicAgent', 'buildFrontEnd', 'build'
mustRunAfter 'downloadNewRelicAgent', 'buildFrontEnd', 'build'

jvmArgs = ["-javaagent:${projectDir}/newrelic/newrelic-v${newrelic_version}.jar"]
}

tasks.register('buildFrontEnd', DefaultTask){
tasks.register('buildFrontEnd', DefaultTask) {
group 'New Relic'
doFirst {
exec {
Expand All @@ -75,12 +75,13 @@ tasks.register('buildFrontEnd', DefaultTask){
commandLine cmd, 'run', 'build'
}

delete 'src/main/resources/static/resources/react'
mkdir 'src/main/resources/static/resources/react'
delete 'src/main/resources/static/assets'
delete 'src/main/resources/static/index.html'
mkdir 'src/main/resources/static/assets'

copy {
from "client/dist"
into "src/main/resources/static/resources/react"
into "src/main/resources/static"
}
}

Expand All @@ -91,20 +92,20 @@ tasks.register('buildFrontEnd', DefaultTask){
def newRelicAgentId = System.getenv('NEW_RELIC_AGENT_ID')
def newRelicApplicationId = System.getenv('NEW_RELIC_APPLICATION_ID')

if(newRelicTrustKey == null && newRelicAccountId != null){
if (newRelicTrustKey == null && newRelicAccountId != null) {
newRelicTrustKey = newRelicAccountId
}

if(newRelicAgentId == null && newRelicApplicationId != null){
if (newRelicAgentId == null && newRelicApplicationId != null) {
newRelicAgentId = newRelicApplicationId
}

if(newRelicLicenseKey == null || newRelicAccountId == null || newRelicTrustKey == null || newRelicAgentId == null || newRelicApplicationId == null){
if (newRelicLicenseKey == null || newRelicAccountId == null || newRelicTrustKey == null || newRelicAgentId == null || newRelicApplicationId == null) {
throw new GradleException('NEW_RELIC_* ENVIRONMENT VARIABLES NOT SET')
}

def templateJavaScript = file("$rootDir/browserMonitoringTemplate.js");
def indexFile = file("$rootDir/src/main/resources/static/resources/react/index.html")
def indexFile = file("$rootDir/src/main/resources/static/index.html")

def indexFileContents = indexFile.getText()
def templateContents = templateJavaScript.getText()
Expand All @@ -129,7 +130,7 @@ tasks.register('downloadNewRelicAgent', DefaultTask) {
def agentExists = file("newrelic/newrelic-v${newrelic_version}.jar").exists()
def agentDoesNotExist = !agentExists

if(agentDoesNotExist){
if (agentDoesNotExist) {
println "Downloading New Relic Java Agent v${newrelic_version}..."
} else {
println "Found Local Java Agent v${newrelic_version}; Skipping Task (delete " +
Expand Down
2 changes: 1 addition & 1 deletion client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tsconfigPaths from 'vite-tsconfig-paths';

// https://vitejs.dev/config/
export default defineConfig({
base: "http://localhost:8081/resources/react/",
base: "",
build: {
sourcemap: true,
},
Expand Down
Empty file modified entrypoint.sh
100644 → 100755
Empty file.
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Controller
class WelcomeController {

@GetMapping("/")
@GetMapping("/welcome")
public String welcome() {
return "welcome";
}
Expand Down

0 comments on commit 93d2386

Please sign in to comment.