Skip to content

Commit 6b487ef

Browse files
authored
Java sub-projects have been added, including PCGen-base and PCGen-formula repositories (#7563)
* Convert PCGen-base and PCGen-Formula to JPMS subprojects Restructure the build to make PCGen-base and PCGen-Formula proper Java modules (JPMS) as Gradle subprojects, replacing the old external JAR dependencies (net.sourceforge.pcgen:PCGen-base:1.0.170 and net.sourceforge.pcgen:PCGen-Formula:1.0.200). Build infrastructure: - Add 'PCGen-base' and 'PCGen-Formula' to settings.gradle as included projects - Write new build.gradle for each subproject (java-library, Java 25, JUnit 5) - Replace external JAR deps with project(':PCGen-base') and project(':PCGen-Formula') - Remove ivy fileRepo repository (no longer needed) - Remove PCGen-base/PCGen-Formula from jlink forceMerge (proper named modules now) - Move JavaCompile/Test task config out of allprojects{} to root-only scope Module descriptors: - Create module-info.java for pcgen.base (exports utility packages) - Create module-info.java for pcgen.formula (requires transitive pcgen.base, exports formula parser and solver packages) - Update main module-info.java: requires pcgen.base; requires pcgen.formula Split-package resolution (JPMS forbids two modules owning same package): - Move generic formula classes to PCGen-Formula: AddingFormula, DividingFormula, MultiplyingFormula, SubtractingFormula, ReferenceFormula - Move generic format/test classes to PCGen-base: Dice, Die, DiceFormat, InequalityTester - Delete TypeSafeConstant from main (identical copy exists in PCGen-base) - Relocate pcgen.base.formula.Formula to pcgen.cdom.formula.Formula (legacy interface that depends on pcgen.core — cannot live in generic module) - Relocate pcgen.base.calculation.* to pcgen.cdom.calculation.* (PCGen-specific adapter layer, not part of the generic solver) Pre-commit JavaCC parser: - Generate parser source from formula.jjt using jjtree+javacc 7.0.13 - Place all generated files in PCGen-Formula/code/src/java/pcgen/base/formula/parse/ - No build-time generation needed Update ~150 files for import changes across main source and tests. Both subprojects compile successfully. Main source has remaining compilation errors from API differences between the old published JARs and the current in-repo source (Phase 6: API migration still needed). * Phase 6: Migrate main source to new PCGen-Formula/PCGen-base APIs Complete API migration enabling the main module to compile against the in-repo PCGen-Formula and PCGen-base subprojects (current source) rather than the old published JARs. Key API changes applied: - LegalScope -> ImplementedScope (getParentScope -> drawsFrom/isGlobal) - FormulaManager removed; replaced by ManagerFactory pattern - ScopeManagerInst -> ImplementedScopeLibrary (registerScope -> addScope) - VariableStrategy -> DependencyStrategy - Modifier.getDependencies -> captureDependencies; added isValid - NEPFormula.getDependencies -> captureDependencies - ScopeInstance.getLegalScope -> getImplementedScope - VarScoped: removed getLocalScopeName/getVariableParent from interface, added getProviderFor(ImplementedScope) for scope hierarchy navigation - SolverManager: addModifierAndSolve -> addModifier, solveChildren -> processSolver, getDefaultValue -> getDefault - FormatManagerFactory.build and FormatManagerLibrary.getFormatManager signature changes (Optional parameters) - VariableLibrary.getVariableFormat now returns Optional<FormatManager<?>> - ScopeInstanceFactory.get(String, VarScoped) replaces old Optional-based API - FormulaFactory.getValidFormula no longer takes FormulaManager parameter Structural additions: - GlobalPCVarScoped: sentinel VarScoped for PC global scope instances - PCGenScoped.getLocalScopeName(): moved from VarScoped interface to PCGen-specific PCGenScoped interface - ImplementedScopeLibrary.getScopes(): collection accessor for GUI code - VariableContext.validateDefaults(): delegates to SupplierValueStore * Fix simple test compilation errors for new PCGen-Formula/PCGen-base APIs Mechanical updates to test/testcommon sources to align with renamed and reshaped APIs in the JPMS subprojects: - Modifier.getDependencies → captureDependencies, added isValid stub - NEPFormula.getDependencies → captureDependencies - LegalScope → ImplementedScope / PCGenScope type references - SimpleScopeInstance constructor: removed Optional parent parameter - AggressiveSolverManager/DynamicSolverManager → SimpleSolverManager - ColumnFormatFactory/TableFormatFactory.build() now takes Optional params Remaining test errors require rewriting AbstractFormulaTestCase (removes FormulaManager) and dependent test classes — left for a separate change. * Fix test compilation and runtime failures for JPMS API migration - Add equals/hashCode to GlobalPCVarScoped to fix ScopeInstance identity mismatches when multiple instances are created across test and production code - Fix scope getName() methods to return fully-qualified names (e.g. "PC.SKILL") matching the registration keys used by ImplementedScopeLibrary - Add getFunctionLibrary() and getOperatorLibrary() accessors to VariableContext for test infrastructure access - Rewrite AbstractFormulaTestCase to use ManagerFactory/ScopeInstanceFactory instead of removed FormulaManager - Update SimpleSolverManager.processSolver to preserve existing store values when no solver is built, preventing VariableChannel.set() from being overwritten by format defaults - Adapt tests to explicitly call processSolver after addModifier since SimpleSolverManager does not auto-evaluate like the old DynamicSolverManager * Update Gradle wrapper to 9.5.1 * Remove processSolver calls after user-input channel writes SimpleSolverManager.processSolver() writes the format default when no solver exists, which overwrites values set via VariableChannel.set() and ChannelUtilities.setGlobalChannel(). This was correct for the old DynamicSolverManager (which auto-cascaded), but incorrect for SimpleSolverManager where channel writes are the final value. - Revert SimpleSolverManager.processSolver() to original upstream logic - Remove processSolver() call from VariableChannel.set() - Remove processSolver() call from ChannelUtilities.setGlobalChannel() - Remove unused SolverManagerFacet field from ChannelUtilities * Open pcgen.cdom.base to pcgen.base for StagingProxy reflection access PCGen-base's StagingProxy.applyTo() reflectively invokes methods on VarHolder (in pcgen.cdom.base). With proper module boundaries enforced, this requires an explicit opens directive. * Add JUnit Platform Launcher to subproject test dependencies JPMS modular projects with inferModulePath require the launcher artifact explicitly on the test runtime classpath. * Revert String equality branch in CaseInsensitiveString.equals() Reverts the change from a7e1952 which added an `instanceof String` branch to equals(). This violates the equals symmetry contract: cis.equals("Foo") returned true but "Foo".equals(cis) always returns false since String is unaware of CaseInsensitiveString. The upstream pcgen-base repo never accepted this change, and the existing CaseInsensitiveStringTest.testString() explicitly asserts that this comparison must be false. Callers that need case-insensitive comparison with a raw String should wrap it in a CaseInsensitiveString first. * Restore processSolver after addModifier/removeModifier in SolverManagerFacet The Phase 6 API migration (094525d) replaced addModifierAndSolve() with addModifier() but omitted the follow-up processSolver() call that recomputes the variable value. Without it, modifiers were registered but never evaluated, causing GlobalModifyTest to hang waiting for a value that was never computed. Also short-circuit global-scope resolution: when the target scope is global, call scopeFacet.getGlobalScope() directly instead of walking the VarScoped hierarchy — global variables have no meaningful scoped object to traverse. In GlobalModifyTest.targetFacetCount(), guard against an empty diagnose list (which is valid when no solver has been built yet) and remove a stale comment about a missing API method. * Resolve global scope correctly in SolverManagerFacet When MODIFY is parsed inside a non-global scope (e.g., MODIFY:Face on a SIZE object), VarModifier.getLegalScope() reports the parsing scope, not the variable's actual scope. Following that path produced a ScopeInstance that did not match the one used when reading the variable, so modifiers were applied to a different VariableID than channels read from. Routine the scope through resolveScope(): if the parsed scope is global, or if the variable is legally defined at the global scope, use the global ScopeInstance. Otherwise fall back to the local scope as before. Fixes the Pathfinder FACE tests (which use MODIFY:Face on SIZE objects to set the global Face variable to "5,5") and the GlobalModifyTest identity-mismatch failures. * Copy globalVarScopedMap entry on PlayerCharacter clone PlayerCharacter.clone() invokes bean.copyContents(id, aClone.id) on every facet, but AbstractItemFacet.copyContents() copies the underlying map directly without going through set(), so ScopeFacet.set()'s side effect of registering the GlobalPCVarScoped sentinel was skipped on the clone. The cloned character then had a null entry in globalVarScopedMap, and getGlobalScope() handed back a ScopeInstance whose owner was null, causing NullPointerExceptions in VarScoped.getProviderFor() during the 26 pcGenGUI*Test save/restore flows. Override copyContents() to also copy the globalVarScopedMap entry. * Fix CI release pipeline after JPMS subproject migration - jlink: add `addExtraDependencies('javafx')` so the merged module (which inherits `requires javafx.graphics` from controlsfx) can resolve JavaFX modules from `mods/lib` during merged-module compilation. - jlink: declare `prepareMergedJarsDir.dependsOn copyToLibs` to satisfy Gradle 9.5's implicit-dependency validation; both tasks read/write `build/libs/`. - Test config: move the JavaFX `--module-path mods/lib --add-modules javafx.*` JVM args out of `allprojects { tasks.withType(Test) }`. The pure-formula subprojects (PCGen-base, PCGen-Formula) have no `mods/lib` and don't depend on JavaFX, so applying those args to their tests crashed JVM startup with `FindException: Module javafx.web not found`. - Remove unused imports flagged by checkstyle after the JPMS API migration. * Generate PCGen-Formula parser at build time via JJTree+JavaCC The PCGen-Formula parse package gitignores seven JavaCC-generated files (FormulaParser, FormulaParserConstants, FormulaParserTokenManager, ParseException, Token, TokenMgrError, SimpleCharStream). They were previously produced by an Ant build that no longer runs after the JPMS subproject migration, so clean CI checkouts (including CodeQL's autobuild) failed compileJava with "cannot find symbol: FormulaParser". Add a javacc configuration and two JavaExec tasks (jjtree, javacc) to PCGen-Formula/build.gradle. JJTree converts formula.jjt into an annotated .jj under build/generated/jjtree, then JavaCC emits the seven parser/token classes into build/generated/sources/javacc, which is added as a secondary srcDir of the main source set. The hand-maintained AST/Visitor/Node/SimpleNode/Operator classes in code/src/java remain canonical because JJTree's auxiliary outputs land in a directory not on the source path. * Generate redundant JJTree outputs at build time The 16 AST classes plus Node, JJTFormulaParserState, FormulaParserTreeConstants, FormulaParserVisitor, and FormulaParserDefaultVisitor in PCGen-Formula/code/src/java/pcgen/base/formula/parse were byte-identical to JJTree's output from formula.jjt — pure boilerplate that didn't need to live in source control. Wire JJTree's output dir as a secondary srcDir of the main source set, drop JJTree's SimpleNode.java stub in a doLast (the hand-edited SimpleNode in code/src/java is canonical), and remove the 21 redundant files. The .gitignore in the parse package now covers all generated artifacts so they can't accidentally be re-added. Operator.java and SimpleNode.java are the only remaining hand-maintained files in that package. * Document why SimpleNode is hand-maintained Note the PCGen-specific Operator/text fields, the ~50 call sites that prevent a rename, and the NODE_CLASS=PCGenBaseNode alternative for any future cleanup. * Fix DynamicScope.getName() to return fully-qualified scope name ImplementedScopeLibrary (new API) keys scopes by scope.getName() directly, whereas the old ScopeManagerInst built the full dotted name from the scope hierarchy. All hardcoded PCGenScope implementations (SkillScope, StatScope, etc.) were updated to return their full name (e.g. "PC.SKILL"), but DynamicScope was missed — it still returned only the category's local name (e.g. "MOVEMENT" instead of "PC.MOVEMENT"). This caused MODIFYOTHER:PC.MOVEMENT|... and LOCAL:PC.MOVEMENT|... tokens to fail with "illegal variable scope" warnings at load time, breaking DataLoadTest for any source that uses dynamic scopes (e.g. Starfinder armor entries using MODIFYOTHER to apply movement penalties). * Fix getLocalVariableID to use owner's local scope, not global PC scope In the Phase 6 API migration, the call: instFactory.get(localScopeName.get(), Optional.of(owner)) was replaced with: SCOPE_FACET.get(id, owner) ScopeFacet.get(CharID, VarScoped) always uses GlobalPCScope.GLOBAL_SCOPE_NAME ("PC"), so variables declared in child scopes (e.g. CHANNEL*STATSCORE in PC.STAT) could not be found — VariableManager.getActiveScope only walks drawsFrom() upward, not into child scopes. Restore the original intent: get the owner's proper local scope name via PCGenScoped.getLocalScopeName() and use the ScopeInstanceFactory directly. * Address Sonar issues in VariableUtilities Replace wildcard VariableID<?> returns on getLocalVariableID with a generic <T> parameter (S1452), matching the existing pattern on getGlobalVariableID. Replace the unguarded Optional.get() on the owner's local scope name with orElseThrow (S3655), carrying the variable name, owner class, and owner identity in the message so a misrouted call can be diagnosed from the log alone. * Fix stale links and git rebase command in README Replace defunct AdoptOpenJDK links with Eclipse Temurin (Adoptium). Correct git rebase command: fetch before checkout, and rebase from upstream/master. * Include PCGen-base and PCGen-Formula test results in CI report After the JPMS subproject migration, subprojects produce their own test results under PCGen-base/ and PCGen-Formula/. Add those paths to the Publish Test Results step so they are not silently omitted. * Drop unused orange-extensions compileOnly dependency com.yuvimasory:orange-extensions had no references in any source file. The library exposes Apple-specific eawt APIs that the project does not use; the dependency was carried by the build configuration alone. * Move xmlunit-core to testImplementation scope Only PcgenFtlTestCase referenced org.xmlunit.*; no production code did. Keeping it on the production module path forced a `requires org.xmlunit;` in module-info and pulled the jar into the runtime image for nothing. * Add UNICODE_INPUT=true to suppress JavaCC non-ASCII warning The BASIC_LETTER token definition covers Unicode ranges beyond Latin. Without UNICODE_INPUT=true, JavaCC warns about non-ASCII characters in the generated regex. The option also ensures the parser handles Unicode input correctly when a non-default Reader is used. * Document fullJpackage as the correct native bundle task jpackageImage alone skips assembleJpackageImage, leaving data/plugins/ preview/outputsheets out of the bundle. fullJpackage runs the full chain. Also document the macOS .DS_Store workaround. * Remove dead cross-platform build infrastructure from jlink/jpackage Pre-late-2024, PCGen used NSIS for the Windows installer. NSIS is script-driven and platform-agnostic, so a single host could produce installers for all five target platforms (linux x64/aarch64, mac x64/aarch64, windows x64). The all-platforms JDK download chain (downloadJDKs / extractJDKs / downloadJavaFXMods, plus the five-entry targetPlatform() block in jlink {}) was load-bearing for that workflow, and PCGEN_ALL_PLATFORMS=true was the switch that turned it on. NSIS was retired in commits 306cee4..be48763 in favor of jpackage. jpackage is not platform-agnostic: it shells out to native OS tooling (hdiutil/pkgbuild on macOS, WiX on Windows, dpkg-deb on Linux), and the Beryx jlink plugin's mergedModule step invokes the target JDK's native javac to synthesize a module-info. The moment NSIS left, cross-platform builds from a single host stopped working - verified 2026-05-19 on macOS aarch64, where PCGEN_ALL_PLATFORMS=true ./gradlew jlink fails with "jdk_linux_aarch64/bin/javac: cannot execute binary file". CI sidestepped this by moving to a per-OS matrix (.github/workflows/gradle-release.yml) where each runner builds only its own platform. PCGEN_ALL_PLATFORMS is never set in any workflow and would fail on every GitHub-hosted runner if it were. This commit removes the now-dead surface: - The PCGEN_ALL_PLATFORMS env-var branches in jlink {} and tasks.named("jlink"); registers only the host targetPlatform(). - Aggregator tasks downloadJDKs, extractJDKs, downloadJavaFXMods. - The unused 'jre' task (no callers). Per-platform downloadJdk_*, extractJdk_*, downloadJfxMods_*, and extractJfxMods_* tasks are kept - they back the host-only path and CI caches them by glob. AGENTS.md updated to point at the per-platform task names. * Collapse per-platform JDK/JFX tasks to single host-targeted tasks Follow-up to "Remove dead cross-platform build infrastructure". The prior commit removed the all-platforms aggregator tasks and the five-entry targetPlatform() block, but the four platforms.each { } loops were left intact, registering 20 download/extract tasks of which only the host platform's 4 ever fire. Collapse the loops to single tasks: downloadJdk, extractJdk, downloadJfxMods, extractJfxMods. Filenames remain platform-stamped (jdks/jdk_${hostOs}_${hostArch}.${ext}) so the GitHub Actions cache glob in gradle-release.yml keeps working - per-runner cache keys already isolate the linux/mac/windows builds. Remove the platforms ext list, which existed only to drive the loops. Lift host-OS/arch detection to a single computation at script scope (above jlink {}) and reuse it from jlink {}, jpackage {}, and tasks.named("jlink") instead of recomputing in three places. Verified by running ./gradlew jlink end-to-end on macOS aarch64: build/image/pcgen-mac-aarch64/bin/java reports openjdk 25.0.3. Updates CI workflow comments and AGENTS.md to reference the new flat task names. * Disable unused distZip/distTar tasks The application plugin's distZip/distTar produce build/distributions/ archives containing the pcgen jar plus ~150 runtime dependency jars and the generated start scripts. Nothing in this project consumes them: - CI publishes the custom 5-zip layout from buildDist (data, docs, program, libs, image) plus jpackage native installers. The release pipeline never reads build/distributions/. - End users install via jpackage-produced .dmg/.pkg/.exe/.deb/.rpm with a bundled JRE, not a raw jar pile that needs a system JDK. - Local dev uses ./gradlew run / qbuild, which don't touch dist*. Disable both with enabled = false. They stay in the task graph (assemble depends on them) but skip their actions, so every build stops materializing ~150 jars into build/distributions/ for nobody to read. Drop distTar/distZip from sourcesJar's dependsOn — that was a stale workaround for a Gradle implicit-dependency warning between copyToLibs and the dist tasks, now moot. sourcesJar's content comes from sourceSets.main.allSource, which is independent of dist*. * Remove dead build tasks and stale debug prints - buildonly: registered in 2014, never referenced anywhere in the repo (no CI, docs, scripts). Functionally a worse qbuild — same dependency on copyToOutput but missing the actual copy logic that makes qbuild useful. Pure dead weight. - quickbuild: same story, never referenced. "build runnable output and run tests" is just `./gradlew qbuild test` — no dedicated task needed. - println("IN copyToOutput") / println("IN buildonly"): debug prints left over from the 2014 Gradle conversion (commit f00f99c). They spammed stdout on every build with no useful info. - Stale TODO + commented-out `dependsOn copyToOutput` in the build task: documenting a non-change from 18 months ago. The decision to not have build populate output/ is permanent — qbuild fills that role for devs who want it. Kept mustRunAfter clean (load-bearing) with a clearer comment. - Dropped the now-orphan "// Alias tasks" comment.
1 parent 71423dc commit 6b487ef

264 files changed

Lines changed: 1752 additions & 1560 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gradle-release-manual.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ jobs:
160160
cache-read-only: false
161161
cache-overwrite-existing: true
162162

163-
# Cache cross-platform JDK and JavaFX jmod archives downloaded by
164-
# downloadJdk_* / downloadJavaFXMods_* tasks. These are pinned by
163+
# Cache the host-platform JDK and JavaFX jmod archives downloaded by
164+
# the downloadJdk / downloadJfxMods tasks. Filenames are stamped with
165+
# ${hostOs}_${hostArch}, so each runner OS gets its own cache bucket
166+
# via the runner-keyed actions/cache key. These are pinned by
165167
# javaVersion (gradle.properties) and the URL templates (build.gradle),
166168
# so keying on those file hashes invalidates correctly when we bump
167169
# the JDK or JavaFX version. We cache only the archives (.tar.gz / .zip)

.github/workflows/gradle-release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ jobs:
130130
cache-read-only: false
131131
cache-overwrite-existing: true
132132

133-
# Cache cross-platform JDK and JavaFX jmod archives downloaded by
134-
# downloadJdk_* / downloadJavaFXMods_* tasks. These are pinned by
133+
# Cache the host-platform JDK and JavaFX jmod archives downloaded by
134+
# the downloadJdk / downloadJfxMods tasks. Filenames are stamped with
135+
# ${hostOs}_${hostArch}, so each runner OS gets its own cache bucket
136+
# via the runner-keyed actions/cache key. These are pinned by
135137
# javaVersion (gradle.properties) and the URL templates (build.gradle),
136138
# so keying on those file hashes invalidates correctly when we bump
137139
# the JDK or JavaFX version. We cache only the archives (.tar.gz / .zip)

.github/workflows/gradle-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
build/test-results/**/*.xml
4343
build/test-results/**/*.trx
4444
build/test-results/**/*.json
45+
PCGen-base/build/test-results/**/*.xml
46+
PCGen-base/build/test-results/**/*.trx
47+
PCGen-base/build/test-results/**/*.json
48+
PCGen-Formula/build/test-results/**/*.xml
49+
PCGen-Formula/build/test-results/**/*.trx
50+
PCGen-Formula/build/test-results/**/*.json
4551
4652
- name: Run Coverage
4753
run: ./gradlew testCoverage

AGENTS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ Always use the wrapper (./gradlew). Java 25 is required; Gradle will fetch depen
6565
- ./gradlew clean (also triggers cleanPlugins, cleanOutput, cleanJdks, cleanMods, cleanMasterSheets)
6666

6767
Notes
68-
- Some tasks trigger downloads of JDKs/JavaFX for all platforms (downloadJDKs, extractJDKs, downloadJavaFXMods) or host SDK (downloadJavaFXLocal/extractJavaFXLocal). CI caches build/jre and build/libs.
69-
- The `jre` task prepares all platform JDKs with JavaFX modules for runtime image creation.
68+
- jlink/jpackage build only the host platform. The download/extract tasks (downloadJdk, extractJdk, downloadJfxMods, extractJfxMods) target the host OS/arch automatically; the host SDK helper for local dev is downloadJavaFXLocal/extractJavaFXLocal. CI caches build/jre and build/libs.
7069
- Runtime bundles expect assets in data/, system/, outputsheets/, preview/, vendordata/, homebrewdata/.
7170

7271
## Running From Source

PCGen-Formula/build.gradle

Lines changed: 63 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,93 @@
1-
/*
2-
* PCGen formula component build using the Gradle tool. This file specifies the
3-
* core build tasks and refers to other files in the code/gradle directory for
4-
* additional tasks for specific output.
5-
*
6-
* Developer build: gradle
7-
* Incremental dev build: gradle build
8-
* Full build: gradle all
9-
*/
10-
111
plugins {
12-
id "ca.coglinc2.javacc" version "3.0.0"
13-
id 'java'
14-
id 'eclipse'
15-
id 'jacoco'
16-
id 'ivy-publish'
17-
id 'checkstyle'
18-
id 'pmd'
19-
id 'com.github.ben-manes.versions' version '0.39.0'
20-
id 'com.github.spotbugs' version '4.7.5'
2+
id 'java-library'
213
}
224

235
group = 'net.sourceforge.pcgen'
24-
description = """PCGen formula library"""
25-
26-
defaultTasks 'clean', 'build'
27-
28-
sourceCompatibility = 1.11
29-
targetCompatibility = 1.11
30-
31-
ext {
32-
majorVersion = 1
33-
minorVersion = 0
34-
}
6+
description = 'PCGen formula library - generic expression parser and solver system'
357

36-
repositories {
37-
mavenCentral()
38-
ivy {
39-
name "Pcgen Repo"
40-
url 'http://pc-gen.org/librepo'
41-
allowInsecureProtocol true
8+
java {
9+
toolchain {
10+
languageVersion = JavaLanguageVersion.of(25)
4211
}
12+
modularity.inferModulePath = true
4313
}
4414

45-
dependencies {
46-
// Use this if you want to reference your own local pcgen base, alter the
47-
// relative path to what you need.
48-
//compile files("../../pcgen-base/PCGen-base/build/libs/PCgen-base-1.0.jar")
49-
50-
implementation group: 'net.sourceforge.pcgen', name: 'PCGen-base', version:'1.0.220'
51-
testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.8.0'
52-
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.2'
53-
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.0'
54-
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.0'
55-
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.0'
56-
}
15+
def generatedJjtreeDir = layout.buildDirectory.dir('generated/sources/jjtree').get().asFile
16+
def generatedJavaccDir = layout.buildDirectory.dir('generated/sources/javacc').get().asFile
5717

5818
sourceSets {
5919
main {
60-
java {
61-
srcDirs 'code/src/java'
62-
}
63-
}
64-
javacc {
65-
java {
66-
srcDirs 'code/src/javacc'
67-
}
20+
java { srcDirs = ['code/src/java', generatedJjtreeDir, generatedJavaccDir] }
6821
}
6922
test {
70-
java {
71-
srcDirs 'code/src/test'
72-
}
73-
}
74-
}
75-
76-
test {
77-
useJUnitPlatform()
78-
reports {
79-
junitXml.enabled = true
80-
html.enabled = false
23+
java { srcDirs = ['code/src/test'] }
8124
}
82-
systemProperties 'property': 'value'
8325
}
8426

85-
jacocoTestReport {
86-
reports {
87-
xml {
88-
enabled true // coveralls plugin depends on xml format report
89-
}
90-
91-
html {
92-
enabled true
93-
}
94-
}
95-
96-
afterEvaluate {
97-
getClassDirectories().from(files(classDirectories.files.collect {
98-
fileTree(dir: it, exclude: ['**/testsupport/**', '**/Abstract**TestCase', '**/**Test', 'pcgen/base/formula/parse/FormulaParser**', 'pcgen/base/formula/parse/AST**', 'pcgen/base/formula/parse/JJT**', 'pcgen/base/formula/parse/Node**', 'pcgen/base/formula/parse/ParseException**', 'pcgen/base/formula/parse/SimpleCharStream**', 'pcgen/base/formula/parse/Token**'])
99-
}))
100-
}
101-
}
102-
103-
compileJjtree {
104-
inputDirectory = file('code/src/jjtree')
105-
// We consciously choose to put the output in the main repo tree so that
106-
// SimpleNode only exists once...
107-
outputDirectory = file('code/src/javacc/')
108-
include '**/*.java'
27+
repositories {
28+
mavenCentral()
10929
}
11030

111-
compileJavacc {
112-
inputDirectory = file('code/src/javacc/')
113-
outputDirectory = file('code/src/java/')
31+
configurations {
32+
javacc
11433
}
11534

116-
// Calculate the version number - runs in the parse phase
117-
allprojects {
118-
ext.buildTimestamp = new Date().format('yyyy-MM-dd HH:mm:ss Z')
119-
if (System.env.BUILD_NUMBER) {
120-
project.version = "$majorVersion.$minorVersion.$System.env.BUILD_NUMBER"
35+
dependencies {
36+
api project(':PCGen-base')
37+
38+
javacc 'net.java.dev.javacc:javacc:7.0.13'
39+
40+
testImplementation platform('org.junit:junit-bom:5.11.4')
41+
testImplementation 'org.junit.jupiter:junit-jupiter-api'
42+
testImplementation 'org.junit.jupiter:junit-jupiter-params'
43+
testImplementation 'junit:junit:4.13.2'
44+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
45+
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
46+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
47+
}
48+
49+
// SimpleNode.java and Operator.java in code/src/java are hand-maintained; everything
50+
// else in pcgen/base/formula/parse is generated at build time. JJTree produces the AST
51+
// classes, the visitor interfaces, and an annotated .jj grammar; JavaCC then turns the
52+
// .jj into the parser and token classes.
53+
tasks.register('jjtree', JavaExec) {
54+
def src = file('code/src/jjtree/pcgen/base/formula/parse/formula.jjt')
55+
def outDir = new File(generatedJjtreeDir, 'pcgen/base/formula/parse')
56+
inputs.file(src)
57+
outputs.dir(generatedJjtreeDir)
58+
classpath = configurations.javacc
59+
mainClass = 'jjtree'
60+
args "-OUTPUT_DIRECTORY=${outDir}", src.absolutePath
61+
doFirst {
62+
generatedJjtreeDir.deleteDir()
63+
outDir.mkdirs()
12164
}
122-
else {
123-
project.version = "$majorVersion.$minorVersion"
65+
doLast {
66+
// SimpleNode is hand-maintained in code/src/java; drop JJTree's stub so the
67+
// two don't collide on the source path.
68+
new File(outDir, 'SimpleNode.java').delete()
12469
}
12570
}
12671

127-
task echoVer() doLast {
128-
println "${project.name} Version: ${project.version} (${buildTimestamp})"
129-
}
130-
131-
jar {
132-
manifest {
133-
attributes 'Implementation-Title': 'PCGenFormulaLibrary', 'Implementation-Version': project.version,
134-
'Built-On': buildTimestamp
72+
tasks.register('javacc', JavaExec) {
73+
dependsOn 'jjtree'
74+
def jjFile = new File(generatedJjtreeDir, 'pcgen/base/formula/parse/formula.jj')
75+
def outDir = new File(generatedJavaccDir, 'pcgen/base/formula/parse')
76+
inputs.file(jjFile)
77+
outputs.dir(generatedJavaccDir)
78+
classpath = configurations.javacc
79+
mainClass = 'javacc'
80+
args "-OUTPUT_DIRECTORY=${outDir}", jjFile.absolutePath
81+
doFirst {
82+
generatedJavaccDir.deleteDir()
83+
outDir.mkdirs()
13584
}
13685
}
13786

138-
task sourceJar(type: Jar) {
139-
from sourceSets.main.java
140-
classifier "sources"
87+
tasks.named('compileJava') {
88+
dependsOn 'javacc'
14189
}
14290

143-
task javadocJar(type: Jar, dependsOn: javadoc) {
144-
classifier = 'javadoc'
145-
from javadoc.destinationDir
91+
tasks.named('test') {
92+
useJUnitPlatform()
14693
}
147-
148-
// Rules for how we publish our artifacts in ivy compliant format
149-
publishing {
150-
repositories {
151-
ivy {
152-
name "fileRepo"
153-
url '/var/www/librepo'
154-
}
155-
}
156-
publications {
157-
ivy(IvyPublication) {
158-
from components.java
159-
configurations {
160-
sources {}
161-
javadoc {}
162-
}
163-
artifact(sourceJar) {
164-
type "sources"
165-
conf "sources"
166-
}
167-
artifact(javadocJar) {
168-
type "javadoc"
169-
conf "javadoc"
170-
}
171-
descriptor.withXml {
172-
asNode().info[0].appendNode('description', description)
173-
}
174-
}
175-
}
176-
}
177-
178-
//We end up with an unneeded task with SpotBugs and JavaCC that causes a failure
179-
//see: https://github.com/spotbugs/spotbugs-gradle-plugin/issues/70
180-
tasks.whenTaskAdded {task ->
181-
if(task.name.contains("spotbugsJavacc")) {
182-
task.enabled = false
183-
}
184-
}
185-
186-
apply from: 'gradle/reporting.gradle'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module pcgen.formula {
2+
requires transitive pcgen.base;
3+
4+
exports pcgen.base.formula;
5+
exports pcgen.base.formula.analysis;
6+
exports pcgen.base.formula.base;
7+
exports pcgen.base.formula.exception;
8+
exports pcgen.base.formula.factory;
9+
exports pcgen.base.formula.function;
10+
exports pcgen.base.formula.inst;
11+
exports pcgen.base.formula.library;
12+
exports pcgen.base.formula.operator.array;
13+
exports pcgen.base.formula.operator.bool;
14+
exports pcgen.base.formula.operator.generic;
15+
exports pcgen.base.formula.operator.number;
16+
exports pcgen.base.formula.operator.string;
17+
exports pcgen.base.formula.parse;
18+
exports pcgen.base.formula.visitor;
19+
exports pcgen.base.solver;
20+
}

code/src/java/pcgen/base/formula/AddingFormula.java renamed to PCGen-Formula/code/src/java/pcgen/base/formula/AddingFormula.java

File renamed without changes.

code/src/java/pcgen/base/formula/DividingFormula.java renamed to PCGen-Formula/code/src/java/pcgen/base/formula/DividingFormula.java

File renamed without changes.

code/src/java/pcgen/base/formula/MultiplyingFormula.java renamed to PCGen-Formula/code/src/java/pcgen/base/formula/MultiplyingFormula.java

File renamed without changes.

code/src/java/pcgen/base/formula/ReferenceFormula.java renamed to PCGen-Formula/code/src/java/pcgen/base/formula/ReferenceFormula.java

File renamed without changes.

0 commit comments

Comments
 (0)