/
DependencyBank.java
242 lines (208 loc) · 10.4 KB
/
DependencyBank.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.badlogic.gdx.setup;
import java.util.HashMap;
public class DependencyBank {
//Versions
static String libgdxVersion = "1.9.12";
//Temporary snapshot version, we need a more dynamic solution for pointing to the latest nightly
static String libgdxNightlyVersion = "1.9.13-SNAPSHOT";
static String roboVMVersion = "2.3.12";
static String buildToolsVersion = "29.0.3";
static String androidAPILevel = "29";
static String androidMinAPILevel = "14";
static String gwtVersion = "2.8.2";
//Repositories
static String mavenLocal = "mavenLocal()";
static String mavenCentral = "mavenCentral()";
static String jCenter = "jcenter()";
static String google = "google()";
static String gradlePlugins = "https://plugins.gradle.org/m2/";
static String libGDXSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/";
static String libGDXReleaseUrl = "https://oss.sonatype.org/content/repositories/releases/";
//Project plugins
static String gwtPluginImport = "org.wisepersist:gwt-gradle-plugin:1.0.13";
static String grettyPluginImport = "org.gretty:gretty:3.0.2";
static String androidPluginImport = "com.android.tools.build:gradle:3.5.4";
static String roboVMPluginImport = "com.mobidevelop.robovm:robovm-gradle-plugin:" + roboVMVersion;
//Extension versions
static String box2DLightsVersion = "1.5";
static String ashleyVersion = "1.7.3";
static String aiVersion = "1.8.2";
HashMap<ProjectDependency, Dependency> gdxDependencies = new HashMap<ProjectDependency, Dependency>();
public DependencyBank() {
for (ProjectDependency projectDep : ProjectDependency.values()) {
Dependency dependency = new Dependency(projectDep.name(),
projectDep.getGwtInherits(),
projectDep.getDependencies(ProjectType.CORE),
projectDep.getDependencies(ProjectType.DESKTOP),
projectDep.getDependencies(ProjectType.ANDROID),
projectDep.getDependencies(ProjectType.IOS),
projectDep.getDependencies(ProjectType.HTML));
gdxDependencies.put(projectDep, dependency);
}
}
public Dependency getDependency(ProjectDependency gdx) {
return gdxDependencies.get(gdx);
}
/**
* This enum will hold all dependencies available for libgdx, allowing the setup to pick the ones needed by default,
* and allow the option to choose extensions as the user wishes.
* <p/>
* These dependency strings can be later used in a simple gradle plugin to manipulate the users project either after/before
* project generation
*
* @see Dependency for the object that handles sub-module dependencies. If no dependency is found for a sub-module, ie
* FreeTypeFont for gwt, an exception is thrown so the user can be notified of incompatability
*/
public enum ProjectDependency {
GDX(
new String[]{"com.badlogicgames.gdx:gdx:$gdxVersion"},
new String[]{"com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"},
new String[]{"com.badlogicgames.gdx:gdx-backend-android:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"},
new String[]{"com.mobidevelop.robovm:robovm-rt:$roboVMVersion", "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion", "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"},
new String[]{"com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"},
new String[]{"com.badlogic.gdx.backends.gdx_backends_gwt"},
"Core Library for LibGDX"
),
BULLET(
new String[]{"com.badlogicgames.gdx:gdx-bullet:$gdxVersion"},
new String[]{"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"},
new String[]{"com.badlogicgames.gdx:gdx-bullet:$gdxVersion", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"},
new String[]{"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"},
null,
null,
"3D Collision Detection and Rigid Body Dynamics"
),
FREETYPE(
new String[]{"com.badlogicgames.gdx:gdx-freetype:$gdxVersion"},
new String[]{"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"},
new String[]{"com.badlogicgames.gdx:gdx-freetype:$gdxVersion", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"},
new String[]{"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"},
null,
null,
"Generate BitmapFonts from .ttf font files"
),
TOOLS(
new String[]{},
new String[]{"com.badlogicgames.gdx:gdx-tools:$gdxVersion"},
new String[]{},
new String[]{},
new String[]{},
new String[]{},
"Collection of tools, including 2D/3D particle editors, texture packers, and file processors"
),
CONTROLLERS(
new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion"},
new String[]{"com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"},
new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"},
new String[]{}, // works on iOS but never reports any controllers :)
new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion:sources"},
new String[]{"com.badlogic.gdx.controllers.controllers-gwt"},
"Controller/Gamepad API"
),
BOX2D(
new String[]{"com.badlogicgames.gdx:gdx-box2d:$gdxVersion"},
new String[]{"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"},
new String[]{"com.badlogicgames.gdx:gdx-box2d:$gdxVersion", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"},
new String[]{"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"},
new String[]{"com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"},
new String[]{"com.badlogic.gdx.physics.box2d.box2d-gwt"},
"2D Physics Library"
),
BOX2DLIGHTS(
new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"},
new String[]{},
new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"},
new String[]{},
new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"},
new String[]{"Box2DLights"},
"2D Lighting framework that utilises Box2D"
),
ASHLEY(
new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion"},
new String[]{},
new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion"},
new String[]{},
new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion:sources"},
new String[]{"com.badlogic.ashley_gwt"},
"Lightweight Entity framework"
),
AI(
new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion"},
new String[]{},
new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion"},
new String[]{},
new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"},
new String[]{"com.badlogic.gdx.ai"},
"Artificial Intelligence framework"
);
private String[] coreDependencies;
private String[] desktopDependencies;
private String[] androidDependencies;
private String[] iosDependencies;
private String[] gwtDependencies;
private String[] gwtInherits;
private String description;
ProjectDependency(String[] coreDeps, String[] desktopDeps, String[] androidDeps, String[] iosDeps, String[] gwtDeps, String[] gwtInhertis, String description) {
this.coreDependencies = coreDeps;
this.desktopDependencies = desktopDeps;
this.androidDependencies = androidDeps;
this.iosDependencies = iosDeps;
this.gwtDependencies = gwtDeps;
this.gwtInherits = gwtInhertis;
this.description = description;
}
public String[] getDependencies(ProjectType type) {
switch (type) {
case CORE:
return coreDependencies;
case DESKTOP:
return desktopDependencies;
case ANDROID:
return androidDependencies;
case IOS:
return iosDependencies;
case HTML:
return gwtDependencies;
}
return null;
}
public String[] getGwtInherits() {
return gwtInherits;
}
public String getDescription() {
return description;
}
}
public enum ProjectType {
CORE("core"),
DESKTOP("desktop"),
ANDROID("android"),
IOS("ios"),
HTML("html");
private final String name;
ProjectType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String[] getPlugins(Language sourceLanguage) {
return sourceLanguage.platformPlugins[ordinal()];
}
}
}