Skip to content

Commit

Permalink
add logic for gradlew target comptability
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubramanianaks committed Jun 5, 2023
1 parent d5586d3 commit adaa52e
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,21 +444,34 @@ func (cc *createCmd) detectDefaults(detectedLang *config.DraftConfig, lowerLang
return
}
defer f.Close()
detectedDefaults := make([]config.BuilderVarDefault, 0)
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "sourceCompatibility") {
detectedVersion := strings.Split(line, " = ")[1] // sourceCompatibility = '1.8'
detectedVersion = strings.Trim(detectedVersion, "'")
detectedVersion = "jdk" + detectedVersion
detectedDefaults := []config.BuilderVarDefault{
{Name: "VERSION", Value: detectedVersion},
detectedVersion = detectedVersion + "-jre"
builderVarDefault := config.BuilderVarDefault{
Name: "VERSION",
Value: detectedVersion,
}
log.Info("detected version %s", detectedVersion)
log.Info("Detected %s from build.gradle for %s project", detectedVersion, lowerLang)
detectedLang.DetectedDefaults = detectedDefaults
return
detectedDefaults = append(detectedDefaults, builderVarDefault)
log.Info("Detected VERSION is %s from build.gradle for %s project", detectedVersion, lowerLang)
}

if strings.Contains(line, "targetCompatibility") {
detectedBuilderVersion := strings.Split(line, " = ")[1] // targetCompatibility = '1.8'
detectedBuilderVersion = strings.Trim(detectedBuilderVersion, "'")
detectedBuilderVersion = "jdk" + detectedBuilderVersion
detectedBuilderVar := config.BuilderVarDefault{
Name: "BUILDERVERSION",
Value: detectedBuilderVersion,
}
detectedDefaults = append(detectedDefaults, detectedBuilderVar)
log.Info("Detected BUILDER VERSION is %s from build.gradle for %s project", detectedBuilderVersion, lowerLang)
}
detectedLang.DetectedDefaults = detectedDefaults
}
}
}
Expand Down

0 comments on commit adaa52e

Please sign in to comment.