2023-02-02 22:34:48 +00:00
|
|
|
package javaentities
|
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// type JavaVersion struct {
|
|
|
|
// Component string
|
|
|
|
// Type string
|
|
|
|
// Name string
|
|
|
|
// Major int
|
|
|
|
// Minor int
|
|
|
|
// Patch int
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// type JavaMetas struct {
|
|
|
|
// JavaVersions []JavaMeta `json:"javaVersions"`
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// func (jm JavaMetas) FindSpecificJavaOsByMajor(version JavaVersion) (SpecificJavaVersion, error) {
|
|
|
|
// for _, v := range jm.JavaVersions {
|
|
|
|
// if version.Major == v.Version.Major {
|
|
|
|
// jv, err := v.getOsJava()
|
|
|
|
// if err != nil {
|
|
|
|
// continue
|
|
|
|
// }
|
|
|
|
// return jv, nil
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return SpecificJavaVersion{}, errors.New("cant find os url")
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// func (jm JavaMetas) FindSpecificJava(MajorVersion string)
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// type JavaMeta struct {
|
|
|
|
// Version struct {
|
|
|
|
// Major int `json:"major"`
|
|
|
|
// Minor int `json:"minor"`
|
|
|
|
// Patch int `json:"patch"`
|
|
|
|
// } `json:"version"`
|
|
|
|
// Name string
|
|
|
|
// Specifics `json:"specifics"`
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// type SpecificJavaVersion struct {
|
|
|
|
// Os string `json:"os"`
|
|
|
|
// Arch string `json:"arch"`
|
|
|
|
// URL string `json:"URL"`
|
|
|
|
// Sha1 string `json:"SHA1"`
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// type Specifics []SpecificJavaVersion
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// func (s Specifics) getOsJava() (SpecificJavaVersion, error) {
|
|
|
|
// for _, v := range s {
|
|
|
|
// if v.Os == runtime.GOOS {
|
|
|
|
// return v, nil
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return SpecificJavaVersion{}, errors.New("not java for current os")
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// func (v *JavaVersion) CheckNotExists(launcherPath string) bool {
|
|
|
|
// javaBinPath := path.Join(launcherPath, ".redist", "java", v.GetString())
|
|
|
|
// _, err := os.Stat(javaBinPath)
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// return err != nil
|
|
|
|
// }
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// func (v *JavaVersion) GetString() string {
|
|
|
|
// var stringBuilder strings.Builder
|
|
|
|
// stringBuilder.WriteString(strconv.Itoa(v.Major))
|
|
|
|
// stringBuilder.WriteRune('.')
|
|
|
|
// stringBuilder.WriteString(strconv.Itoa(v.Minor))
|
|
|
|
// stringBuilder.WriteRune('.')
|
|
|
|
// stringBuilder.WriteString(strconv.Itoa(v.Patch))
|
2023-02-02 22:34:48 +00:00
|
|
|
|
2023-02-04 17:47:49 +00:00
|
|
|
// return stringBuilder.String()
|
|
|
|
// }
|