Skip to content

Commit

Permalink
Fix Gradle build for GWT + eclipse target, thanks GPT-4
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Dec 4, 2023
1 parent d4f1368 commit 3335e75
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
30 changes: 22 additions & 8 deletions backends/gdx-backends-gwt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,34 @@ eclipse {
withXml {
def node = it.asNode()

//Exclude emu folder from main classpath entry
// Collect nodes to modify for excluding emu folder
def nodesToModify = []
node.children().each { c ->
if(c.attribute('path').equals('src')) {
c.attributes().put('excluding', 'com/badlogic/gdx/backends/gwt/emu/')
if (c.attribute('path').equals('src')) {
nodesToModify << c
}
}

//Add second classpath entry for emu folder if not exists
// Modify the collected nodes for excluding emu folder
nodesToModify.each { c ->
def newAttrs = c.attributes().collectEntries { [(it.key): it.value] }
newAttrs.put('excluding', 'com/badlogic/gdx/backends/gwt/emu/')

def newNode = new Node(c.parent(), c.name(), newAttrs)
c.children().each { child ->
newNode.append(child)
}
c.replaceNode(newNode)
}

// Add second classpath entry for emu folder if not exists
def emuNodes = node.children().findAll { it.name() == 'classpathentry' && it.'@path'.equals('src/com/badlogic/gdx/backends/gwt/emu/')}
if (emuNodes.size() == 0) {
def emuNode = node.appendNode('classpathentry')
emuNode.attributes().put('kind', 'src')
emuNode.attributes().put('path', 'src/com/badlogic/gdx/backends/gwt/emu/')
emuNode.attributes().put('excluding', 'java/lang/System.java')
node.appendNode('classpathentry', [
kind: 'src',
path: 'src/com/badlogic/gdx/backends/gwt/emu/',
excluding: 'java/lang/System.java'
])
}
}
}
Expand Down
30 changes: 22 additions & 8 deletions extensions/gdx-box2d/gdx-box2d-gwt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,34 @@ eclipse {
withXml {
def node = it.asNode()

//Exclude emu folder from main classpath entry
// Collect nodes to modify
def nodesToModify = []
node.children().each { c ->
if(c.attribute('path').equals('src')) {
c.attributes().put('excluding', 'com/badlogic/gdx/physics/box2d/gwt/emu/')
if (c.attribute('path').equals('src')) {
nodesToModify << c
}
}

//Add second classpath entry for emu folder if not exists
// Modify the collected nodes
nodesToModify.each { c ->
def newAttrs = c.attributes().collectEntries { [(it.key): it.value] }
newAttrs.put('excluding', 'com/badlogic/gdx/physics/box2d/gwt/emu/')

def newNode = new Node(c.parent(), c.name(), newAttrs)
c.children().each { child ->
newNode.append(child)
}
c.replaceNode(newNode)
}

// Add second classpath entry for emu folder if not exists
def emuNodes = node.children().findAll { it.name() == 'classpathentry' && it.'@path'.equals('src/com/badlogic/gdx/physics/box2d/gwt/emu/')}
if (emuNodes.size() == 0) {
def emuNode = node.appendNode('classpathentry')
emuNode.attributes().put('kind', 'src')
emuNode.attributes().put('path', 'src/com/badlogic/gdx/physics/box2d/gwt/emu/')
emuNode.attributes().put('excluding', 'java/lang/System.java')
node.appendNode('classpathentry', [
kind: 'src',
path: 'src/com/badlogic/gdx/physics/box2d/gwt/emu/',
excluding: 'java/lang/System.java'
])
}
}
}
Expand Down

0 comments on commit 3335e75

Please sign in to comment.