Build script reformatting / 'Fixed' all unchecked warnings

This commit is contained in:
Anuken
2018-12-13 18:01:51 -05:00
parent 18ddc040d1
commit 0b837925a2
15 changed files with 119 additions and 124 deletions
@@ -107,8 +107,6 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
ClassEntry clas = new ClassEntry(callLocation);
classMap.put(callLocation, clas);
classes.add(clas);
Utils.messager.printMessage(Kind.NOTE, "Generating class '" + clas.name + "'.");
}
ClassEntry entry = classMap.get(callLocation);
@@ -45,6 +45,7 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
Set<TypeElement> elements = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Serialize.class));
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
classBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "\"unchecked\"").build());
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
for(TypeElement elem : elements){
+42 -41
View File
@@ -1,26 +1,26 @@
buildscript {
repositories {
buildscript{
repositories{
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0'
dependencies{
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.5'
classpath "com.badlogicgames.gdx:gdx-tools:1.9.9"
}
}
allprojects {
allprojects{
apply plugin: "idea"
version = 'release'
ext {
ext{
versionNumber = '4'
versionModifier = 'alpha'
if (!project.hasProperty("versionType")) versionType = 'official'
if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry'
gdxVersion = '1.9.9'
roboVMVersion = '2.3.0'
@@ -43,7 +43,7 @@ allprojects {
generateLocales = {
def output = 'en\n'
def bundles = new File(project(':core').projectDir, 'assets/bundles/')
bundles.listFiles().each { other ->
bundles.listFiles().each{ other ->
if(other.name == "bundle.properties") return
output += other.name.substring("bundle".length() + 1, other.name.lastIndexOf('.')) + "\n"
}
@@ -56,9 +56,9 @@ allprojects {
try{
pfile.createNewFile()
}catch (Exception ignored){}
}catch(Exception ignored){}
if(pfile.exists()) {
if(pfile.exists()){
props.load(new FileInputStream(pfile))
@@ -74,19 +74,19 @@ allprojects {
}
}
repositories {
repositories{
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url 'https://jitpack.io' }
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/releases/" }
maven{ url 'https://jitpack.io' }
}
}
project(":desktop") {
project(":desktop"){
apply plugin: "java"
dependencies {
dependencies{
compile project(":core")
compile project(":kryonet")
if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug")
@@ -99,14 +99,14 @@ project(":desktop") {
}
}
project(":ios") {
project(":ios"){
apply plugin: "java"
apply plugin: "robovm"
task copyGen{
doLast {
copy {
from("../core/build/classes/java/main/io/anuke/mindustry/gen/") {
doLast{
copy{
from("../core/build/classes/java/main/io/anuke/mindustry/gen/"){
include "**/*.java"
}
@@ -134,14 +134,16 @@ project(":ios") {
props['app.mainclass'] = 'io.anuke.mindustry.IOSLauncher'
props['app.executable'] = 'IOSLauncher'
props['app.name'] = 'Mindustry'
props['app.build'] = (!props.containsKey("app.build") ? 40 : props['app.build'].toInteger() + 1)+""
props['app.build'] = (!props.containsKey("app.build") ? 40 : props['app.build'].toInteger() + 1) + ""
props.store(vfile.newWriter(), null)
}
build.dependsOn(incrementConfig)
build.dependsOn(copyGen)
if(file('robovm.properties').exists()){
build.dependsOn(copyGen)
}
dependencies {
dependencies{
compile project(":core")
implementation project(":kryonet")
@@ -150,18 +152,17 @@ project(":ios") {
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
//compileOnly project(":annotations")
}
}
project(":core") {
project(":core"){
apply plugin: "java"
task finish {
task finish{
generateLocales()
}
dependencies {
dependencies{
build.finalizedBy(finish)
def comp = System.properties["release"] == null || System.properties["release"] == "false"
@@ -173,7 +174,7 @@ project(":core") {
compile "com.github.anuken:ucore:$uCoreVersion"
}
if(new File(projectDir.parent, '../GDXGifRecorder').exists() && comp) {
if(new File(projectDir.parent, '../GDXGifRecorder').exists() && comp){
compile project(":GDXGifRecorder")
}
@@ -186,16 +187,16 @@ project(":core") {
}
}
project(":server") {
project(":server"){
apply plugin: "java"
configurations {
configurations{
if(findProject(":android") != null){
compile.exclude module: android
}
}
dependencies {
dependencies{
compile project(":core")
compile project(":kryonet")
@@ -207,7 +208,7 @@ project(":server") {
project(":tests"){
apply plugin: "java"
dependencies {
dependencies{
testImplementation project(":core")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0')
@@ -215,32 +216,32 @@ project(":tests"){
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
test {
test{
useJUnitPlatform()
workingDir = new File("../core/assets")
}
}
project(":tools") {
project(":tools"){
apply plugin: "java"
dependencies {
dependencies{
compile project(":core")
}
}
project(":annotations") {
project(":annotations"){
apply plugin: "java"
dependencies {
dependencies{
compile 'com.squareup:javapoet:1.11.0'
}
}
project(":kryonet") {
project(":kryonet"){
apply plugin: "java"
dependencies {
dependencies{
compile project(":core")
compile "org.lz4:lz4-java:1.4.1"
compile 'com.github.Anuken:kryonet:53b10247b1'
+5 -1
View File
@@ -1,4 +1,8 @@
apply plugin: "java"
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.java.srcDirs = ["src/"]
compileJava{
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
@@ -95,26 +95,24 @@ public class MapEditorDialog extends Dialog implements Disposable{
t.addImageTextButton("$text.editor.import", "icon-load-map", isize, () ->
createDialog("$text.editor.import",
"$text.editor.importmap", "$text.editor.importmap.description", "icon-load-map", (Runnable) loadDialog::show,
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Runnable) () -> {
Platform.instance.showFileChooser("$text.loadimage", "Map Files", file -> {
ui.loadGraphics(() -> {
try{
DataInputStream stream = new DataInputStream(file.read());
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Runnable) () ->
Platform.instance.showFileChooser("$text.loadimage", "Map Files", file -> ui.loadGraphics(() -> {
try{
DataInputStream stream = new DataInputStream(file.read());
MapMeta meta = MapIO.readMapMeta(stream);
MapTileData data = MapIO.readTileData(stream, meta, false);
MapMeta meta = MapIO.readMapMeta(stream);
MapTileData data = MapIO.readTileData(stream, meta, false);
editor.beginEdit(data, meta.tags, false);
view.clearStack();
}catch(Exception e){
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
Log.err(e);
}
});
}, true, mapExtension);
},
"$text.editor.importimage", "$text.editor.importimage.description", "icon-file-image", (Runnable)() -> {
Platform.instance.showFileChooser("$text.loadimage", "Image Files", file -> {
editor.beginEdit(data, meta.tags, false);
view.clearStack();
}catch(Exception e){
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
Log.err(e);
}
}), true, mapExtension),
"$text.editor.importimage", "$text.editor.importimage.description", "icon-file-image", (Runnable)() ->
Platform.instance.showFileChooser("$text.loadimage", "Image Files", file ->
ui.loadGraphics(() -> {
try{
MapTileData data = MapIO.readLegacyPixmap(new Pixmap(file));
@@ -125,12 +123,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
Log.err(e);
}
});
}, true, "png");
}));
}), true, "png")
));
t.addImageTextButton("$text.editor.export", "icon-save-map", isize, () -> createDialog("$text.editor.export",
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Runnable) () -> {
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Runnable) () ->
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
FileHandle result = file;
@@ -146,8 +143,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
Log.err(e);
}
});
}, false, mapExtension);
}));
}, false, mapExtension)));
t.row();
@@ -258,7 +254,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
* 2) icon name
* 3) listener
*/
private FloatingDialog createDialog(String title, Object... arguments){
private void createDialog(String title, Object... arguments){
FloatingDialog dialog = new FloatingDialog(title);
float h = 90f;
@@ -292,8 +288,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
dialog.addCloseButton();
dialog.show();
return dialog;
}
@Override
@@ -556,9 +550,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
ImageButton button = new ImageButton("white", "clear-toggle");
button.clicked(() -> editor.setDrawBlock(block));
button.resizeImage(8 * 4f);
button.getImageCell().setActor(stack);
button.addChild(stack);
button.getImage().remove();
button.replaceImage(stack);
button.update(() -> button.setChecked(editor.getDrawBlock() == block));
group.add(button);
content.add(button).size(50f);
@@ -65,6 +65,7 @@ public class Unlocks{
save();
}
@SuppressWarnings("unchecked")
public void load(){
unlocked = Settings.getObject("unlockset", ObjectMap.class, ObjectMap::new);
}
@@ -150,6 +150,7 @@ public class Sectors{
save();
}
@SuppressWarnings("unchecked")
public void load(){
for(Sector sector : grid.values()){
sector.texture.dispose();
@@ -261,6 +261,7 @@ public class Administration{
Settings.save();
}
@SuppressWarnings("unchecked")
private void load(){
playerInfo = Settings.getObject("player-info", ObjectMap.class, ObjectMap::new);
bannedIPs = Settings.getObject("banned-ips", Array.class, Array::new);
+1 -7
View File
@@ -25,11 +25,11 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
@SuppressWarnings("unchecked")
public class Net{
private static boolean server;
private static boolean active;
private static boolean clientLoaded;
private static String lastIP;
private static Array<Object> packetQueue = new Array<>();
private static ObjectMap<Class<?>, Consumer> clientListeners = new ObjectMap<>();
private static ObjectMap<Class<?>, BiConsumer<Integer, Object>> serverListeners = new ObjectMap<>();
@@ -106,7 +106,6 @@ public class Net{
*/
public static void connect(String ip, int port, Runnable success){
try{
lastIP = ip + ":" + port;
if(!active){
clientProvider.connect(ip, port, success);
active = true;
@@ -119,11 +118,6 @@ public class Net{
}
}
/**Returns the last IP connected to.*/
public static String getLastIP() {
return lastIP;
}
/**
* Host a server at an address.
*/
@@ -310,6 +310,7 @@ public class JoinDialog extends FloatingDialog{
return UIUtils.portrait() ? 350f : 500f;
}
@SuppressWarnings("unchecked")
private void loadServers(){
servers = Settings.getObject("server-list", Array.class, Array::new);
}
@@ -101,6 +101,7 @@ public class Tile implements PosTrait, TargetTrait{
return -1;
}
@SuppressWarnings("unchecked")
public <T extends TileEntity> T entity(){
return (T) entity;
}
@@ -35,7 +35,6 @@ public class Conveyor extends Block{
private TextureRegion[][] regions = new TextureRegion[7][4];
protected float speed = 0f;
protected float carryCapacity = 8f;
protected Conveyor(String name){
super(name);
@@ -359,9 +358,9 @@ public class Conveyor extends Block{
public Array<Object> getDebugInfo(Tile tile){
ConveyorEntity entity = tile.entity();
Array<Object> arr = super.getDebugInfo(tile);
arr.addAll(Array.with(
"clogHeat", entity.clogHeat,
"sleeping", entity.isSleeping()
arr.addAll(Array.<Object>with(
"clogHeat", entity.clogHeat,
"sleeping", entity.isSleeping()
));
return arr;
}
@@ -87,6 +87,7 @@ public class Consumers{
return map.containsKey(type);
}
@SuppressWarnings("unchecked")
public <T extends Consume> T get(Class<T> type){
if(!map.containsKey(type)){
throw new IllegalArgumentException("Block does not contain consumer of type '" + type + "'!");
+28 -28
View File
@@ -1,7 +1,7 @@
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.java.srcDirs = ["src/"]
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
@@ -10,25 +10,25 @@ def PACKR_DIR = "$System.env.PACKR_DIR"
def ICON_DIR = new File("core/assets/sprites/icon.icns")
ext.getPlatform = {
if (project.hasProperty("platform")) {
if(project.hasProperty("platform")){
def lc = platform.toLowerCase()
if (lc == "windows64") {
if(lc == "windows64"){
return "windows64"
} else if (lc == "windows32") {
}else if(lc == "windows32"){
return "windows32"
} else if (lc == "linux") {
}else if(lc == "linux"){
return "linux64"
} else if (lc == "mac") {
}else if(lc == "mac"){
return "mac"
} else {
}else{
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows/linux/mac")
}
} else {
}else{
throw new InvalidUserDataException("No platform defined. Set platform with -Pplatform=windows/linux/mac")
}
}
task run(dependsOn: classes, type: JavaExec) {
task run(dependsOn: classes, type: JavaExec){
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
@@ -37,7 +37,7 @@ task run(dependsOn: classes, type: JavaExec) {
jvmArgs "-XstartOnFirstThread"
}
ignoreExitValue = true
if (project.hasProperty("args")) {
if(project.hasProperty("args")){
args Eval.me(project.getProperties()["args"])
}
@@ -46,7 +46,7 @@ task run(dependsOn: classes, type: JavaExec) {
}
}
task debug(dependsOn: classes, type: JavaExec) {
task debug(dependsOn: classes, type: JavaExec){
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
@@ -55,38 +55,38 @@ task debug(dependsOn: classes, type: JavaExec) {
debug = true
}
task dist(type: Jar) {
task dist(type: Jar){
dependsOn classes
writeVersion()
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from{ configurations.compile.collect{ zipTree(it) } }
from files(project.assetsDir)
manifest {
manifest{
attributes 'Main-Class': project.mainClassName
}
}
task clearOut(type: Delete){
doLast {
doLast{
delete "packr-out/"
}
}
//note: call desktop:dist beforehand
task packrCmd() {
task packrCmd(){
doLast {
doLast{
copy {
copy{
into PACKR_DIR
from "build/libs/desktop-release.jar"
}
exec {
exec{
commandLine("java", "-jar", PACKR_DIR + "packr.jar",
"--verbose",
@@ -104,7 +104,7 @@ task packrCmd() {
}
}
task fixMac (type: Copy){
task fixMac(type: Copy){
dependsOn "packrCmd"
into "packr-out/" + appName + ".app/Contents/"
@@ -117,12 +117,12 @@ task fixMac (type: Copy){
}
}
task fixWindows32 (type: Copy){
task fixWindows32(type: Copy){
dependsOn "packrCmd"
into "packr-out/jre/bin/"
from PACKR_DIR + "zip.dll"
rename ("zip.dll", "ojdkbuild_zlib.dll")
rename("zip.dll", "ojdkbuild_zlib.dll")
doLast{
copy{
@@ -132,21 +132,21 @@ task fixWindows32 (type: Copy){
}
}
task packrZip() {
task packrZip(){
dependsOn "packrCmd"
finalizedBy "clearOut"
if(project.hasProperty("platform")) {
if(project.hasProperty("platform")){
if (getPlatform() == "mac") {
if(getPlatform() == "mac"){
dependsOn "fixMac"
}
if (getPlatform() == "windows32") {
if(getPlatform() == "windows32"){
dependsOn "fixWindows32"
}
task zip (type: Zip){
task zip(type: Zip){
from "packr-out/"
archiveName "$appName-${getPlatform()}-${getVersionString()}.zip"
destinationDir(file("packr-export"))
+11 -11
View File
@@ -1,7 +1,7 @@
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.java.srcDirs = ["src/"]
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.tools.texturepacker.TexturePacker
@@ -12,25 +12,25 @@ def textureFolder = "../core/assets-raw/sprites/generated/"
task swapColors(){
doLast{
if (project.hasProperty("colors")) {
if(project.hasProperty("colors")){
def carr = new File(getProperty("colors")).text.split("\n")
def map = [:]
def swaps = 0
carr.each {str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1]))}
carr.each{ str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1])) }
def tmpc = new Color()
fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit { file ->
fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit{ file ->
if(file.isDirectory()) return
swaps ++
swaps++
def img = ImageIO.read(file.file)
for (x in (0..img.getWidth()-1)) {
for (y in (0..img.getHeight()-1)) {
for(x in (0..img.getWidth() - 1)){
for(y in (0..img.getHeight() - 1)){
def c = img.getRGB(x, y)
Color.argb8888ToColor(tmpc, c)
if(tmpc.a < 0.1f) continue
if(map.containsKey(c)){
img.setRGB(x, y, (int)map.get(c))
img.setRGB(x, y, (int) map.get(c))
}
}
}
@@ -46,7 +46,7 @@ task swapColors(){
task pack(){
dependsOn 'prePack'
doLast {
doLast{
TexturePacker.process("core/assets-raw/sprites/", "core/assets/sprites/", "sprites.atlas")
delete{
@@ -71,7 +71,7 @@ task cleanup(){
}
}
task generateSprites(dependsOn: classes, type: JavaExec) {
task generateSprites(dependsOn: classes, type: JavaExec){
file(textureFolder).mkdirs()
main = "io.anuke.mindustry.PackerLauncher"
@@ -80,7 +80,7 @@ task generateSprites(dependsOn: classes, type: JavaExec) {
workingDir = textureFolder
}
task updateBundles(dependsOn: classes, type: JavaExec) {
task updateBundles(dependsOn: classes, type: JavaExec){
file(textureFolder).mkdirs()
main = "io.anuke.mindustry.BundleLauncher"