@@ -132,6 +132,7 @@ tasks.withType(Checkstyle).configureEach {
132132
133133repositories {
134134 gradlePluginPortal()
135+ mavenLocal()
135136 mavenCentral()
136137
137138 // JavaCC 8 Snapshots
@@ -172,13 +173,13 @@ dependencies {
172173 xmlDoclet (' com.manticore-projects.tools:xml-doclet:+' ){ changing = true }
173174
174175 // enforce latest version of JavaCC
175- testImplementation(' org.javacc:core:8.1.0 -SNAPSHOT' ) { changing = true }
176- testImplementation(' org.javacc.generator:java:8.1.0 -SNAPSHOT' ) { changing = true }
176+ testImplementation(' org.javacc:core:8.1.1 -SNAPSHOT' ) { changing = true }
177+ testImplementation(' org.javacc.generator:java:8.1.1 -SNAPSHOT' ) { changing = true }
177178
178179 jmh ' org.openjdk.jmh:jmh-core:1.37'
179180 jmh ' org.openjdk.jmh:jmh-generator-annprocess:1.37'
180- javacc(' org.javacc:core:8.1.0 -SNAPSHOT' ) { changing = true }
181- javacc(' org.javacc.generator:java:8.1.0 -SNAPSHOT' ) { changing = true }
181+ javacc(' org.javacc:core:8.1.1 -SNAPSHOT' ) { changing = true }
182+ javacc(' org.javacc.generator:java:8.1.1 -SNAPSHOT' ) { changing = true }
182183}
183184configurations. configureEach {
184185 resolutionStrategy. eachDependency { DependencyResolveDetails details ->
@@ -188,6 +189,10 @@ configurations.configureEach {
188189 }
189190 }
190191}
192+ configurations. javacc {
193+ resolutionStrategy. force ' org.javacc:core:8.1.1-SNAPSHOT' ,
194+ ' org.javacc.generator:java:8.1.1-SNAPSHOT'
195+ }
191196
192197compileJavacc {
193198 arguments = [
@@ -200,79 +205,6 @@ compileJavacc {
200205 ]
201206}
202207
203- // Post-process the generated CCJSqlParserTokenManager.java to split large static
204- // array initializers into separate methods, preventing the <clinit> method from
205- // exceeding the JVM's 64KB bytecode limit (which breaks ASM-based tools like sbt-assembly).
206- tasks. register(' splitTokenManagerStaticInit' ) {
207- dependsOn(compileJavacc)
208-
209- def tokenManagerFile = layout. buildDirectory. file(
210- " generated/javacc/net/sf/jsqlparser/parser/CCJSqlParserTokenManager.java"
211- )
212-
213- inputs. file(tokenManagerFile)
214- outputs. file(tokenManagerFile)
215-
216- doLast {
217- def file = tokenManagerFile. get(). asFile
218- if (! file. exists()) {
219- throw new GradleException (" CCJSqlParserTokenManager.java not found at ${ file} " )
220- }
221- def content = file. text
222-
223- // Pattern matches static final array field declarations with inline initialization.
224- // We extract large ones and move their initialization into separate methods.
225- def fieldsToExtract = [
226- // [regex-safe field name, array type for method return]
227- [' stringLiterals' , ' int[]' ],
228- [' jjstrLiteralImages' , ' String[]' ],
229- [' jjmatchKinds' , ' int[]' ],
230- [' jjnewLexState' , ' int[]' ],
231- ]
232-
233- fieldsToExtract. each { entry ->
234- def fieldName = entry[0 ]
235- def arrayType = entry[1 ]
236-
237- // Match: <modifiers> <type> <fieldName> = { ... };
238- // The field declaration may use 'public' or 'private' and 'static final'
239- def pattern = ~" (?s)((?:public|private)\\ s+static\\ s+final\\ s+${java.util.regex.Pattern.quote(arrayType)}\\ s+${fieldName}\\ s*=\\ s*)\\ {(.*?)\\ };"
240- def matcher = pattern. matcher(content)
241- if (matcher. find()) {
242- def prefix = matcher. group(1 )
243- def body = matcher. group(2 )
244- def methodName = " _init_${ fieldName} "
245- def replacement = " ${ prefix}${ methodName} ();\n " +
246- " private static ${ arrayType} ${ methodName} () { return new ${ arrayType} {${ body} }; }"
247- content = matcher. replaceFirst(java.util.regex.Matcher . quoteReplacement(replacement))
248- logger. lifecycle(" splitTokenManagerStaticInit: extracted ${ fieldName} initialization into ${ methodName} ()" )
249- }
250- }
251-
252- // Handle int[][] arrays separately (jjcompositeState, jjnextStateSet)
253- def arrayArrayFields = [' jjcompositeState' , ' jjnextStateSet' ]
254- arrayArrayFields. each { fieldName ->
255- def pattern = ~" (?s)(private\\ s+static\\ s+final\\ s+int\\ [\\ ]\\ [\\ ]\\ s+${fieldName}\\ s*=\\ s*)\\ {(.*?)\\ };"
256- def matcher = pattern. matcher(content)
257- if (matcher. find()) {
258- def prefix = matcher. group(1 )
259- def body = matcher. group(2 )
260- def methodName = " _init_${ fieldName} "
261- def replacement = " ${ prefix}${ methodName} ();\n " +
262- " private static int[][] ${ methodName} () { return new int[][] {${ body} }; }"
263- content = matcher. replaceFirst(java.util.regex.Matcher . quoteReplacement(replacement))
264- logger. lifecycle(" splitTokenManagerStaticInit: extracted ${ fieldName} initialization into ${ methodName} ()" )
265- }
266- }
267-
268- file. text = content
269- }
270- }
271-
272- tasks. withType(JavaCompile ). configureEach {
273- dependsOn(' splitTokenManagerStaticInit' )
274- }
275-
276208java {
277209 withSourcesJar()
278210 // withJavadocJar()
0 commit comments