Skip to content

Commit

Permalink
Fix #191 .
Browse files Browse the repository at this point in the history
Groovy 4.0.22 should be the default now, and should download correctly. This also fixes a somewhat-related bug where languages could become mismatched from their versions, and languages could also be added more than once (but versions only once).
  • Loading branch information
tommyettinger committed Aug 10, 2024
1 parent 288dabd commit ca633f2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
21 changes: 12 additions & 9 deletions src/main/java/gdx/liftoff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,12 @@ public static void setDefaultUserData() {
UserData.mainClassName = pref.getString("MainClass", prop.getProperty("mainClassNameDefault"));
UserData.platforms = splitCSV(pref.getString("Platforms", prop.getProperty("platformsDefaultNames")));

UserData.languages = splitCSV(pref.getString("Languages", prop.getProperty("languagesDefaultNames")));
UserData.languages = splitCSVSet(pref.getString("Languages", prop.getProperty("languagesDefaultNames")));
ArrayList<String> languageVersions = splitCSV(pref.getString("LanguageVersions", prop.getProperty("languagesDefaultVersions")));
UserData.languageVersions = new LinkedHashMap<>();
for (int i = 0; i < UserData.languages.size(); i++) {
UserData.languageVersions.put(UserData.languages.get(i), languageVersions.get(i));
int languageIndex = 0;
for(String language : languages){
UserData.languageVersions.put(language, languageVersions.get(languageIndex++));
}

extensions = splitCSV(pref.getString("Extensions", prop.getProperty("extensionsDefaultNames")));
Expand All @@ -531,11 +532,12 @@ public static void resetUserData() {
UserData.mainClassName = prop.getProperty("mainClassNameDefault");
UserData.platforms = splitCSV(prop.getProperty("platformsDefaultNames"));

UserData.languages = splitCSV(prop.getProperty("languagesDefaultNames"));
UserData.languages = splitCSVSet(prop.getProperty("languagesDefaultNames"));
ArrayList<String> languageVersions = splitCSV(prop.getProperty("languagesDefaultVersions"));
UserData.languageVersions = new LinkedHashMap<>();
for (int i = 0; i < UserData.languages.size(); i++) {
UserData.languageVersions.put(UserData.languages.get(i), languageVersions.get(i));
int languageIndex = 0;
for(String language : languages){
UserData.languageVersions.put(language, languageVersions.get(languageIndex++));
}

extensions = splitCSV(prop.getProperty("extensionsDefaultNames"));
Expand Down Expand Up @@ -572,11 +574,12 @@ public static void resetUserData() {
public static void setQuickProjectDefaultUserData() {
UserData.platforms = splitCSV(prop.getProperty("qp_platformsDefaultNames"));

UserData.languages = splitCSV(prop.getProperty("languagesDefaultNames"));
UserData.languages = splitCSVSet(prop.getProperty("languagesDefaultNames"));
ArrayList<String> languageVersions = splitCSV(prop.getProperty("languagesDefaultVersions"));
UserData.languageVersions = new LinkedHashMap<>();
for (int i = 0; i < UserData.languages.size(); i++) {
UserData.languageVersions.put(UserData.languages.get(i), languageVersions.get(i));
int languageIndex = 0;
for(String language : languages){
UserData.languageVersions.put(language, languageVersions.get(languageIndex++));
}

extensions = splitCSV(prop.getProperty("extensionsDefaultNames"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gdx/liftoff/ui/UserData.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class UserData {
public static String packageName;
public static String mainClassName;
public static ArrayList<String> platforms;
public static ArrayList<String> languages;
public static LinkedHashSet<String> languages;
public static LinkedHashMap<String, String> languageVersions;
public static ArrayList<String> extensions;
public static String template;
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/gdx/liftoff/ui/dialogs/LanguagesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,27 @@ private void addLanguage(Table table, String languageName, String defaultVersion
if (checkBox.isChecked()) {
UserData.languages.add(languageName);
UserData.languageVersions.put(languageName, textField.getText());
} else UserData.languages.remove(languageName);
} else {
UserData.languages.remove(languageName);
UserData.languageVersions.remove(languageName);
}
pref.putString("Languages", String.join(",", UserData.languages));
pref.putString("LanguageVersions", String.join(",", UserData.languageVersions.values()));
pref.flush();

});

onChange(textField, () -> {
UserData.languageVersions.put(languageName, textField.getText());
if (checkBox.isChecked()) {
UserData.languages.add(languageName);
UserData.languageVersions.put(languageName, textField.getText());
} else {
UserData.languages.remove(languageName);
UserData.languageVersions.remove(languageName);
}
pref.putString("Languages", String.join(",", UserData.languages));
pref.putString("LanguageVersions", String.join(",", UserData.languageVersions.values()));
pref.flush();
});

Button button = new Button(skin, "external-link");
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/gdx/liftoff/data/languages/Groovy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import gdx.liftoff.views.JvmLanguage
@Suppress("unused") // Class accessed via reflection.
class Groovy : Language {
override val id = "groovy"
override val version = "4.0.2"
override val version = "4.0.22"

override fun initiate(project: Project) {
project.rootGradle.plugins.add(id)
Expand All @@ -23,6 +23,6 @@ class Groovy : Language {
val gradleFile = project.getGradleFile(Android.ID) as AndroidGradleFile
gradleFile.srcFolders.add("'src/main/groovy'")
}
addDependency(project, "org.codehaus.groovy:groovy-all:\$groovyVersion")
addDependency(project, "org.apache.groovy:groovy-all:\$groovyVersion")
}
}
2 changes: 1 addition & 1 deletion src/main/resources/ui-data/defaults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ languagesDefaultVersions=
extensionsDefaultNames=
thirdPartyDefaultNames=
templateDefaultName=classic
groovyDefaultVersion=4.0.2
groovyDefaultVersion=4.0.22
kotlinDefaultVersion=1.9.22
scalaDefaultVersion=2.13.8
libgdxDefaultVersion=1.12.1
Expand Down

0 comments on commit ca633f2

Please sign in to comment.