-
Notifications
You must be signed in to change notification settings - Fork 40
/
identify.go
51 lines (40 loc) · 1.21 KB
/
identify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package java
import (
"github.com/spf13/afero"
"github.com/spf13/cast"
"github.com/zeabur/zbpack/internal/utils"
"github.com/zeabur/zbpack/pkg/plan"
"github.com/zeabur/zbpack/pkg/types"
)
type identify struct{}
// NewIdentifier returns a new Java identifier.
func NewIdentifier() plan.Identifier {
return &identify{}
}
func (i *identify) PlanType() types.PlanType {
return types.PlanTypeJava
}
func (i *identify) Match(fs afero.Fs) bool {
return utils.HasFile(
fs, "pom.xml", "pom.yml", "pom.yaml", "build.gradle",
"build.gradle.kts",
)
}
func (i *identify) PlanMeta(options plan.NewPlannerOptions) types.PlanMeta {
projectType := DetermineProjectType(options.Source)
framework := DetermineFramework(projectType, options.Source)
jdkVersion := DetermineJDKVersion(projectType, options.Source)
targetExt := DetermineTargetExt(options.Source)
planMeta := types.PlanMeta{
"type": string(projectType),
"framework": string(framework),
"targetExt": targetExt,
"jdk": jdkVersion,
}
javaArgs := plan.Cast(options.Config.Get("javaArgs"), cast.ToStringE)
if args, err := javaArgs.Take(); err == nil {
planMeta["javaArgs"] = args
}
return planMeta
}
var _ plan.Identifier = (*identify)(nil)