From 62b38f9da82c89af00ab2059b24c836815f06c0a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 16 Jul 2025 04:58:41 +0200 Subject: [PATCH] Fix TypeScript dependencies and optimize Eclipse formatter build - Install npm dependencies if node_modules missing - Only rebuild Eclipse formatter if source is newer than JAR - Make Eclipse formatter less verbose --- .../spine/formatter/EclipseFormatter.java | 17 ++++++++++------- formatters/format-java.sh | 5 ++++- formatters/format-ts.sh | 8 ++++++++ spine-cpp/src/spine/Bone.cpp | 2 +- spine-csharp/src/Skeleton.cs | 2 +- spine-haxe/spine-haxe/spine/Skeleton.hx | 2 +- .../src/com/esotericsoftware/spine/Bone.java | 2 +- spine-ts/spine-core/src/Bone.ts | 2 +- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/formatters/eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java b/formatters/eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java index 02f8bd90d..b8ad48d1a 100644 --- a/formatters/eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java +++ b/formatters/eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java @@ -27,20 +27,21 @@ public class EclipseFormatter { CodeFormatter formatter = new DefaultCodeFormatter(options); // Format each file - int successCount = 0; + int changedCount = 0; int errorCount = 0; for (int i = 1; i < args.length; i++) { try { - formatFile(formatter, args[i]); - successCount++; + if (formatFile(formatter, args[i])) { + changedCount++; + } } catch (Exception e) { System.err.println("Error formatting " + args[i] + ": " + e.getMessage()); errorCount++; } } - System.out.println("Formatting complete: " + successCount + " files formatted, " + errorCount + " errors"); + System.out.println("Formatting complete: " + changedCount + " files changed, " + errorCount + " errors"); if (errorCount > 0) { System.exit(1); @@ -83,12 +84,12 @@ public class EclipseFormatter { } } - System.out.println("Loaded " + settings.size() + " formatter settings from " + xmlPath); + // Removed verbose output return settings; } - private static void formatFile(CodeFormatter formatter, String filePath) throws Exception { + private static boolean formatFile(CodeFormatter formatter, String filePath) throws Exception { Path path = Paths.get(filePath); if (!Files.exists(path)) { @@ -119,8 +120,10 @@ public class EclipseFormatter { if (!content.equals(formatted)) { Files.writeString(path, formatted); System.out.println("Formatted: " + filePath); + return true; } else { - System.out.println("No changes: " + filePath); + // Silent when no changes + return false; } } } \ No newline at end of file diff --git a/formatters/format-java.sh b/formatters/format-java.sh index 8aed6fb39..fa7934c19 100755 --- a/formatters/format-java.sh +++ b/formatters/format-java.sh @@ -10,7 +10,10 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd "$dir" > /dev/null # Build the Eclipse formatter if needed -if [ ! -f "eclipse-formatter/target/eclipse-formatter-1.0.0-jar-with-dependencies.jar" ]; then +jar_file="eclipse-formatter/target/eclipse-formatter-1.0.0-jar-with-dependencies.jar" +src_file="eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java" + +if [ ! -f "$jar_file" ] || [ "$src_file" -nt "$jar_file" ]; then echo "Building Eclipse formatter..." pushd eclipse-formatter > /dev/null mvn -q clean package diff --git a/formatters/format-ts.sh b/formatters/format-ts.sh index 2ea327518..ed03e2ce5 100755 --- a/formatters/format-ts.sh +++ b/formatters/format-ts.sh @@ -19,10 +19,18 @@ fi # Format TypeScript files pushd ../spine-ts > /dev/null +if [ ! -d "node_modules" ]; then + echo "Installing spine-ts dependencies..." + npm install +fi npm run format popd > /dev/null pushd ../tests > /dev/null +if [ ! -d "node_modules" ]; then + echo "Installing tests dependencies..." + npm install +fi npm run format popd > /dev/null diff --git a/spine-cpp/src/spine/Bone.cpp b/spine-cpp/src/spine/Bone.cpp index 1494bdff7..7ce2fbb8c 100644 --- a/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/src/spine/Bone.cpp @@ -52,7 +52,7 @@ Bone::Bone(Bone &bone, Bone *parent) } Bone *Bone::getParent() { - return _parent; + return _parent ; } Array &Bone::getChildren() { diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 92127a23e..2508579df 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -73,7 +73,7 @@ namespace Spine { bone = new Bone(boneData, parent); parent.children.Add(bone); } - this.bones.Add(bone); + this.bones.Add(bone) ; } slots = new ExposedList(data.slots.Count); diff --git a/spine-haxe/spine-haxe/spine/Skeleton.hx b/spine-haxe/spine-haxe/spine/Skeleton.hx index 8e4a4a93c..0828fb20e 100644 --- a/spine-haxe/spine-haxe/spine/Skeleton.hx +++ b/spine-haxe/spine-haxe/spine/Skeleton.hx @@ -102,7 +102,7 @@ class Skeleton { * See Skeleton.update(). */ public var time:Float = 0; - public var windX:Float = 1; + public var windX:Float = 1 ; public var windY:Float = 0; public var gravityX:Float = 0; public var gravityY:Float = 1; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java index 82bffa40c..fb9efe2a0 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Bone.java @@ -53,7 +53,7 @@ public class Bone extends PosedActive { /** Copy constructor. Does not copy the {@link #getChildren()} bones. */ public Bone (Bone bone, @Null Bone parent) { this(bone.data, parent); - pose.set(bone.pose); + pose.set(bone.pose) ; } /** The parent bone, or null if this is the root bone. */ diff --git a/spine-ts/spine-core/src/Bone.ts b/spine-ts/spine-core/src/Bone.ts index 2113b29f1..e48ec406f 100644 --- a/spine-ts/spine-core/src/Bone.ts +++ b/spine-ts/spine-core/src/Bone.ts @@ -57,7 +57,7 @@ export class Bone extends PosedActive { copy (parent: Bone | null): Bone { const copy = new Bone(this.data, parent); copy.pose.set(this.pose); - return copy; + return copy ; } }