core/providers/java/maven.go
core/providers/java/maven.goBrowse 1970 files
291 tokens
1,063 bytes
Token encoding: o200k_base
Snapshot 21a254f
← Back to SKILL.md
1package java2 3import (4 "strings"5 6 "github.com/railwayapp/railpack/core/generate"7)8 9const MAVEN_CACHE_KEY = "maven"10 11func (p *JavaProvider) getMavenExe(ctx *generate.GenerateContext) string {12 if ctx.App.HasFile("mvnw") && ctx.App.HasFile(".mvn/wrapper/maven-wrapper.properties") {13 return "./mvnw"14 }15 16 return "mvn"17}18 19func (p *JavaProvider) mavenCache(ctx *generate.GenerateContext) string {20 return ctx.Caches.AddCache(MAVEN_CACHE_KEY, ".m2/repository")21}22 23func getMavenPortConfig(ctx *generate.GenerateContext) string {24 pomFile, err := ctx.App.ReadFile("pom.xml")25 26 if err != nil {27 return ""28 }29 30 if strings.Contains(pomFile, "<groupId>org.wildfly.swarm") {31 // If using the Swarm web server, set the port accordingly for any passed-in $PORT variable32 return "-Dswarm.http.port=$PORT"33 } else if strings.Contains(pomFile, "<groupId>org.springframework.boot") &&34 strings.Contains(pomFile, "<artifactId>spring-boot") {35 // If using Spring Boot, set the port accordingly for any passed-in $PORT variable36 return "-Dserver.port=$PORT"37 }38 return ""39}40