@@ -468,6 +468,7 @@ def syncEclipseRunClasspaths = tasks.register('syncEclipseRunClasspaths') {
468468 }
469469
470470 int changedLaunches = 0
471+ int changedTestExclusions = 0
471472 if (eclipseLaunchDir. isDirectory()) {
472473 File eclipseClasses = file(' bin/main' ). canonicalFile
473474 String modClasses = " ${ mod_id} %%${ eclipseClasses.absolutePath} "
@@ -485,6 +486,27 @@ def syncEclipseRunClasspaths = tasks.register('syncEclipseRunClasspaths') {
485486 / < mapEntry key= " MOD_CLASSES" value= " [^" ]* " \/ >/) {
486487 " < mapEntry key= \" MOD_CLASSES\" value=\" ${ modClasses} \" />"
487488 }
489+ String excludeTestKey = ' org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE'
490+ String excludeTestAttribute =
491+ " <booleanAttribute key=\" ${ excludeTestKey} \" value=\" true\" />"
492+ String beforeTestExclusion = synced
493+ if (synced. contains(" key=\" ${ excludeTestKey} \" " )) {
494+ synced = synced. replaceFirst(
495+ / < booleanAttribute key= " org\. eclipse\. jdt\. launching\. ATTR_EXCLUDE_TEST_CODE" value= " [^" ]* " \/ >/,
496+ excludeTestAttribute)
497+ } else {
498+ int launchHeaderEnd = synced.indexOf('\n ', synced.indexOf('<launchConfiguration'))
499+ if (launchHeaderEnd < 0) {
500+ throw new GradleException(" Malformed Eclipse Java launch configuration : ${launchFile}" )
501+ }
502+ String lineSeparator = synced.contains('\r\n ') ? '\r\n ' : '\n '
503+ synced = " ${synced. substring(0 , launchHeaderEnd + 1 )}" +
504+ " ${excludeTestAttribute}${lineSeparator}" +
505+ synced.substring(launchHeaderEnd + 1)
506+ }
507+ if (beforeTestExclusion != synced) {
508+ changedTestExclusions++
509+ }
488510 if (original != synced) {
489511 launchFile.setText(synced, 'UTF-8')
490512 changedLaunches++
@@ -510,7 +532,7 @@ def syncEclipseRunClasspaths = tasks.register('syncEclipseRunClasspaths') {
510532 changedLaunchGroups++
511533 }
512534 }
513- logger. lifecycle(" Eclipse runtime paths aligned with ${ eclipseCache} (${ stableClasspaths.size()} Forge classpaths, ${ changedProjectClasspath} project classpath, ${ changedResourceExclusions} metadata exclusion, ${ changedPrepareLaunches} prepare launches, ${ changedLaunches} slim launches, ${ changedLaunchGroups} direct project launches updated)" )
535+ logger.lifecycle(" Eclipse runtime paths aligned with ${eclipseCache} (${stableClasspaths. size()} Forge classpaths, ${changedProjectClasspath} project classpath, ${changedResourceExclusions} metadata exclusion, ${changedPrepareLaunches} prepare launches, ${changedLaunches} slim launches, ${changedTestExclusions} test exclusions, ${ changedLaunchGroups} direct project launches updated)" )
514536 }
515537}
516538
0 commit comments