From 2180fd28517675172c38679b798cc20a2a25afbe Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 4 Aug 2025 06:21:21 -0400 Subject: [PATCH] GP-5901: Support for Gradle 9.0.0 --- Ghidra/Features/BSim/build.gradle | 1 - build.gradle | 1 - gradle/support/eclipseLauncher.gradle | 164 -------------------------- gradle/support/sbom.gradle | 5 +- 4 files changed, 3 insertions(+), 168 deletions(-) delete mode 100644 gradle/support/eclipseLauncher.gradle diff --git a/Ghidra/Features/BSim/build.gradle b/Ghidra/Features/BSim/build.gradle index 0c88c9a329..47600e5a07 100755 --- a/Ghidra/Features/BSim/build.gradle +++ b/Ghidra/Features/BSim/build.gradle @@ -24,7 +24,6 @@ apply plugin: 'eclipse' eclipse.project.name = 'Features BSim' import java.nio.file.Files -import org.gradle.util.GUtil // NOTE: fetchDependencies.gradle must be updated if postgresql version changes def postgresql_distro = "postgresql-15.13.tar.gz" diff --git a/build.gradle b/build.gradle index 159eb7dd7b..da978cca88 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,6 @@ apply plugin: 'eclipse' apply from: 'gradle/root/eclipse.gradle' -apply from: "gradle/support/eclipseLauncher.gradle" apply from: "gradle/support/loadApplicationProperties.gradle" diff --git a/gradle/support/eclipseLauncher.gradle b/gradle/support/eclipseLauncher.gradle deleted file mode 100644 index d45c0f1faf..0000000000 --- a/gradle/support/eclipseLauncher.gradle +++ /dev/null @@ -1,164 +0,0 @@ -/* ### - * IP: GHIDRA - * - * 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. - */ -import org.gradle.api.*; -import org.gradle.artifacts.*; -import org.gradle.process.JavaExecSpec; -import org.gradle.api.file.*; -import org.gradle.api.tasks.*; -import org.gradle.api.internal.file.UnionFileCollection; - -import groovy.xml.MarkupBuilder; - -public class WriteEclipseLauncher extends JavaExec { - @OutputFile - File dest; - - @Input - boolean isRunFave = false; - - @Input - boolean isDbgFave = false; - - @Input - boolean useEclipseDefaultClasspath = false - - public E one(Collection col) { - assert col.size() == 1; - return col.iterator().next(); - } - - void walkFileCollection(UnionFileCollection col, Set gathered) { - col.sources.each { - walkFileCollection(it, gathered); - } - } - - void walkFileCollection(ConfigurableFileCollection col, Set gathered) { - col.from.each { - walkFileCollection(it, gathered); - } - } - - void walkFileCollection(SourceSetOutput col, Set gathered) { - gathered.add(col); - } - - void walkFileCollection(Configuration col, Set gathered) { - col.allDependencies.each { - walkDependency(it, gathered) - } - } - - void walkDependency(ExternalModuleDependency dep, Set gathered) { - gathered.add(dep) - } - - void walkDependency(ProjectDependency dep, Set gathered) { - gathered.add(dep) - Project project = dep.dependencyProject - String confName = dep.targetConfiguration ?: 'default' - Configuration configuration = project.configurations."$confName" - walkFileCollection(configuration, gathered) - } - - String makeEntryXml(ExternalModuleDependency dep, FileCollection cp) { - def writer = new StringWriter(); - def xml = new MarkupBuilder(writer); - def file = cp.find { it.name.contains(dep.name) } - xml.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - xml.runtimeClasspathEntry( - externalArchive: file, - path: 5, - // TODO: Figure out source jar - type: 2 - ); - return writer - } - - String makeEntryXml(Project proj) { - def writer = new StringWriter(); - def xml = new MarkupBuilder(writer); - xml.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - xml.runtimeClasspathEntry( - path: 5, - projectName: proj.eclipse.project.name, - type: 1 - ) - return writer - } - - String makeEntryXml(ProjectDependency dep, FileCollection cp) { - return makeEntryXml(dep.dependencyProject); - } - - String makeEntryXml(SourceSetOutput out, FileCollection cp) { - Task task = one(out.buildDependencies.getDependencies(null)) - return makeEntryXml(task.project) - } - - public File forName(String name) { - return project.file(".launch/${name}.launch") - } - - List getJvmArgumentsForEclipse() { - List all = allJvmArgs; - int index = all.indexOf('-cp'); - if (index == -1) { - return all; - } - all.remove(index); - all.remove(index); - return all; - } - - @TaskAction - void exec() { // Override exec. Instead write launcher - dest.parentFile.mkdirs(); - def launcher = new MarkupBuilder(new FileWriter(dest)); - Set gathered = new LinkedHashSet(); - if (!useEclipseDefaultClasspath) { - walkFileCollection(classpath, gathered); - } - launcher.mkp.xmlDeclaration(version: '1.0', encoding: 'UTF-8', standalone: 'no') - launcher.launchConfiguration(type: 'org.eclipse.jdt.launching.localJavaApplication') { - listAttribute(key: 'org.eclipse.debug.ui.favoriteGroups') { - if (isRunFave) { - listEntry(value: 'org.eclipse.debug.ui.launchGroup.run'); - } - if (isDbgFave) { - listEntry(value: 'org.eclipse.debug.ui.launchGroup.debug'); - } - } - if (!useEclipseDefaultClasspath) { - listAttribute(key: 'org.eclipse.jdt.launching.CLASSPATH') { - gathered.each { - listEntry(value: makeEntryXml(it, classpath)) - } - } - } - booleanAttribute(key: 'org.eclipse.jdt.launching.DEFAULT_CLASSPATH', value: useEclipseDefaultClasspath); - stringAttribute(key: 'org.eclipse.jdt.launching.MAIN_TYPE', value: main); - // TODO: Proper escaping of program and JVM arguments. - stringAttribute(key: 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS', value: args.join(' ')); - stringAttribute(key: 'org.eclipse.jdt.launching.PROJECT_ATTR', value: project.eclipse.project.name); - stringAttribute(key: 'org.eclipse.jdt.launching.VM_ARGUMENTS', value: jvmArgumentsForEclipse.join(' ')); - } - } -} - -allprojects { - ext.WriteEclipseLauncher = WriteEclipseLauncher -} diff --git a/gradle/support/sbom.gradle b/gradle/support/sbom.gradle index 806c0334a1..62c22b9104 100644 --- a/gradle/support/sbom.gradle +++ b/gradle/support/sbom.gradle @@ -4,9 +4,9 @@ * 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. @@ -15,6 +15,7 @@ */ import java.util.jar.JarFile import groovy.json.JsonOutput +import groovy.xml.XmlSlurper /****************************************************************************************** *