• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.setup;
18 
19 
20 import java.util.HashMap;
21 
22 public class DependencyBank {
23 
24 	//Versions
25 	static String libgdxVersion = "1.9.3";
26 	//Temporary snapshot version, we need a more dynamic solution for pointing to the latest nightly
27 	static String libgdxNightlyVersion = "1.9.4-SNAPSHOT";
28 	static String roboVMVersion = "2.1.0";
29 	static String moeVersion = "1.1.0.final-1";
30 	static String buildToolsVersion = "23.0.1";
31 	static String androidAPILevel = "20";
32 	static String gwtVersion = "2.6.0";
33 
34 	//Repositories
35 	static String mavenLocal = "mavenLocal()";
36 	static String mavenCentral = "mavenCentral()";
37 	static String jCenter = "jcenter()";
38 	static String libGDXSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/";
39 	static String libGDXReleaseUrl = "https://oss.sonatype.org/content/repositories/releases/";
40 	static String moeLocalUrl = "uri(System.getenv(\"INTEL_MULTI_OS_ENGINE_HOME\") + \"/gradle\")";
41 
42 	//Project plugins
43 	static String gwtPluginImport = "de.richsource.gradle.plugins:gwt-gradle-plugin:0.6";
44 	static String androidPluginImport = "com.android.tools.build:gradle:1.5.0";
45 	static String roboVMPluginImport = "com.mobidevelop.robovm:robovm-gradle-plugin:" + roboVMVersion;
46 	static String moePluginImport = "com.intel.gradle:moeGradlePlugin:" + moeVersion;
47 
48 	//Extension versions
49 	static String box2DLightsVersion = "1.4";
50 	static String ashleyVersion = "1.7.0";
51 	static String aiVersion = "1.8.0";
52 
53 	HashMap<ProjectDependency, Dependency> gdxDependencies = new HashMap<ProjectDependency, Dependency>();
54 
DependencyBank()55 	public DependencyBank() {
56 		for (ProjectDependency projectDep : ProjectDependency.values()) {
57 			Dependency dependency = new Dependency(projectDep.name(),
58 					projectDep.getGwtInherits(),
59 					projectDep.getDependencies(ProjectType.CORE),
60 					projectDep.getDependencies(ProjectType.DESKTOP),
61 					projectDep.getDependencies(ProjectType.ANDROID),
62 					projectDep.getDependencies(ProjectType.IOS),
63 					projectDep.getDependencies(ProjectType.IOSMOE),
64 					projectDep.getDependencies(ProjectType.HTML));
65 			gdxDependencies.put(projectDep, dependency);
66 		}
67 	}
68 
getDependency(ProjectDependency gdx)69 	public Dependency getDependency(ProjectDependency gdx) {
70 		return gdxDependencies.get(gdx);
71 	}
72 
73 	/**
74 	 * This enum will hold all dependencies available for libgdx, allowing the setup to pick the ones needed by default,
75 	 * and allow the option to choose extensions as the user wishes.
76 	 * <p/>
77 	 * These depedency strings can be later used in a simple gradle plugin to manipulate the users project either after/before
78 	 * project generation
79 	 *
80 	 * @see Dependency for the object that handles sub-module dependencies. If no dependency is found for a sub-module, ie
81 	 * FreeTypeFont for gwt, an exception is thrown so the user can be notified of incompatability
82 	 */
83 	public enum ProjectDependency {
84 		GDX(
85 			new String[]{"com.badlogicgames.gdx:gdx:$gdxVersion"},
86 			new String[]{"com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"},
87 			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"},
88 			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"},
89 			new String[]{"com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"},
90 			new String[]{"com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"},
91 			new String[]{"com.badlogic.gdx.backends.gdx_backends_gwt"},
92 
93 			"Core Library for LibGDX"
94 		),
95 		BULLET(
96 			new String[]{"com.badlogicgames.gdx:gdx-bullet:$gdxVersion"},
97 			new String[]{"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"},
98 			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"},
99 			new String[]{"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"},
100 			new String[]{"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"},
101 			null,
102 			null,
103 
104 			"3D Collision Detection and Rigid Body Dynamics"
105 		),
106 		FREETYPE(
107 			new String[]{"com.badlogicgames.gdx:gdx-freetype:$gdxVersion"},
108 			new String[]{"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"},
109 			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"},
110 			new String[]{"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"},
111 			new String[]{"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"},
112 			null,
113 			null,
114 
115 			"Generate BitmapFonts from .ttf font files"
116 		),
117 		TOOLS(
118 			new String[]{},
119 			new String[]{"com.badlogicgames.gdx:gdx-tools:$gdxVersion"},
120 			new String[]{},
121 			new String[]{},
122 			new String[]{},
123 			new String[]{},
124 			new String[]{},
125 
126 			"Collection of tools, including 2D/3D particle editors, texture packers, and file processors"
127 		),
128 		CONTROLLERS(
129 			new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion"},
130 			new String[]{"com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"},
131 			new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"},
132 			new String[]{}, // works on iOS but never reports any controllers :)
133 			new String[]{}, // works on iOS but never reports any controllers :)
134 			new String[]{"com.badlogicgames.gdx:gdx-controllers:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx-controllers-gwt:$gdxVersion:sources"},
135 			new String[]{"com.badlogic.gdx.controllers.controllers-gwt"},
136 
137 			"Controller/Gamepad API"
138 		),
139 		BOX2D(
140 			new String[]{"com.badlogicgames.gdx:gdx-box2d:$gdxVersion"},
141 			new String[]{"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"},
142 			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"},
143 			new String[]{"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"},
144 			new String[]{"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"},
145 			new String[]{"com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"},
146 			new String[]{"com.badlogic.gdx.physics.box2d.box2d-gwt"},
147 
148 			"2D Physics Library"
149 		),
150 		BOX2DLIGHTS(
151 			new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"},
152 			new String[]{},
153 			new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"},
154 			new String[]{},
155 			new String[]{},
156 			new String[]{"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"},
157 			new String[]{"Box2DLights"},
158 
159 			"2D Lighting framework that utilises Box2D"
160 		),
161 		ASHLEY(
162 			new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion"},
163 			new String[]{},
164 			new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion"},
165 			new String[]{},
166 			new String[]{},
167 			new String[]{"com.badlogicgames.ashley:ashley:$ashleyVersion:sources"},
168 			new String[]{"com.badlogic.ashley_gwt"},
169 
170 			"Lightweight Entity framework"
171 		),
172 		AI(
173 			new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion"},
174 			new String[]{},
175 			new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion"},
176 			new String[]{},
177 			new String[]{},
178 			new String[]{"com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"},
179 			new String[]{"com.badlogic.gdx.ai"},
180 
181 			"Artificial Intelligence framework"
182 		);
183 
184 		private String[] coreDependencies;
185 		private String[] desktopDependencies;
186 		private String[] androidDependencies;
187 		private String[] iosDependencies;
188 		private String[] iosMoeDependencies;
189 		private String[] gwtDependencies;
190 		private String[] gwtInherits;
191 		private String description;
192 
ProjectDependency(String[] coreDeps, String[] desktopDeps, String[] androidDeps, String[] iosDeps, String[] iosMoeDeps, String[] gwtDeps, String[] gwtInhertis, String description)193 		ProjectDependency(String[] coreDeps, String[] desktopDeps, String[] androidDeps, String[] iosDeps, String[] iosMoeDeps, String[] gwtDeps, String[] gwtInhertis, String description) {
194 			this.coreDependencies = coreDeps;
195 			this.desktopDependencies = desktopDeps;
196 			this.androidDependencies = androidDeps;
197 			this.iosDependencies = iosDeps;
198 			this.iosMoeDependencies = iosMoeDeps;
199 			this.gwtDependencies = gwtDeps;
200 			this.gwtInherits = gwtInhertis;
201 			this.description = description;
202 		}
203 
getDependencies(ProjectType type)204 		public String[] getDependencies(ProjectType type) {
205 			switch (type) {
206 				case CORE:
207 					return coreDependencies;
208 				case DESKTOP:
209 					return desktopDependencies;
210 				case ANDROID:
211 					return androidDependencies;
212 				case IOS:
213 					return iosDependencies;
214 				case IOSMOE:
215 					return iosMoeDependencies;
216 				case HTML:
217 					return gwtDependencies;
218 			}
219 			return null;
220 		}
221 
getGwtInherits()222 		public String[] getGwtInherits() {
223 			return gwtInherits;
224 		}
225 
getDescription()226 		public String getDescription() {
227 			return description;
228 		}
229 	}
230 
231 
232 	public enum ProjectType {
233 		CORE("core", new String[]{"java"}),
234 		DESKTOP("desktop", new String[]{"java"}),
235 		ANDROID("android", new String[]{"android"}),
236 		IOS("ios", new String[]{"java", "robovm"}),
237 		IOSMOE("ios-moe", new String[] {"moe"}),
238 		HTML("html", new String[]{"gwt", "war"});
239 
240 		private final String name;
241 		private final String[] plugins;
242 
ProjectType(String name, String plugins[])243 		ProjectType(String name, String plugins[]) {
244 			this.name = name;
245 			this.plugins = plugins;
246 		}
247 
getName()248 		public String getName() {
249 			return name;
250 		}
251 
getPlugins()252 		public String[] getPlugins() {
253 			return plugins;
254 		}
255 	}
256 
257 }
258