Commit 1c6a2f7
Fix CSSWatcher live reload: drop stale bindings + extract m2 designer jar
Two recent CSS/localization changes regressed the simulator's live CSS
reload, in different ways.
1. addThemeProps stomped user edits with stale @cn1-bind entries.
PR #4884 added applyThemeBindings() inside UIManager.buildTheme so a
single addThemeProps({"@accent-color": ...}) override could retune
every var()-bound theme key. But CSSWatcher reloads the theme through
the same code path -- and addThemeProps never clears themeConstants.
When the user replaced a `var()` rule with a literal in their CSS,
the recompiled theme.res no longer emitted the matching
`@cn1-bind:<key>` entry, but the previous binding was still sitting
in themeConstants. applyThemeBindings happily re-overlaid the
user's fresh literal value with the stale binding's resolved value,
so the visible change disappeared on every reload.
Fix: in buildTheme, before iterating the incoming Hashtable, detect
any binding whose subject style key the new load is re-setting
without re-asserting the binding alongside, and drop those bindings
before the overlay pass runs. Pure `@accent-color` overrides keep
working because they don't carry style keys, so no bindings are
considered stale.
2. MavenUtils.findDesignerJarInM2 returned the unrunnable wrapper zip.
PR #4852 added an m2 fallback for the CSSWatcher's designer-jar
lookup, used whenever -Dcodename1.designer.jar isn't passed in (e.g.
simulator launched from the IDE rather than `mvn cn1:run`). The
helper returned `codenameone-designer-<v>-jar-with-dependencies.jar`
directly from m2 -- but that artifact is a zip wrapper containing a
single inner designer_1.jar (see maven/designer/pom.xml's antrun
step), with no top-level Main-Class manifest. `java -jar wrapper.zip`
fails with "no main manifest attribute", the CSS subprocess never
starts, and the watcher silently waits for ::refresh:: lines that
never come.
Fix: mirror AbstractCN1Mojo.getDesignerJar's pattern -- unzip the
wrapper to an `<artifact>.jar-extracted/` sibling on demand and
return the inner designer_1.jar so `java -jar` actually launches.
Tests:
- UIManagerThemeBindingsTest gains three regression cases:
cssReloadDropsStaleBindingWhenRuleBecomesLiteral (the actual
reproducer), cssReloadKeepsBindingWhenStillEmittedTogether (guard
against an over-eager fix), and overrideOnlyReloadKeepsBindings
(repeated `@accent-color` retunes still work). The first fails
before the UIManager fix; all three pass after.
- MavenUtilsTest is new and covers the wrapper-vs-inner-jar resolution
with five cases: happy path, re-use of extracted inner jar when the
wrapper hasn't changed, re-extract when the wrapper mtime advances,
null when the core jar isn't in an m2 layout, and null when the
designer artifact is missing. To make these actually executable, the
javase pom now pins maven-surefire-plugin to 3.2.5 (the parent's
2.21.0 doesn't auto-discover JUnit Jupiter). The pre-existing
CSSWatcherTest + LocationSimulationTest + JavaSEPortFontMappingTest
in the same module also start running as a side effect.
- pr.yml gets a new "Run JavaSE port unit tests" step so this whole
test class -- which compiled but never executed -- is wired into CI.
Without it, regressions in CSSWatcher/MavenUtils/JavaSEPort helpers
would continue to slip through, which was the original gap the user
flagged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6bc2988 commit 1c6a2f7
6 files changed
Lines changed: 364 additions & 4 deletions
File tree
- .github/workflows
- CodenameOne/src/com/codename1/ui/plaf
- Ports/JavaSE/src/com/codename1/impl/javase/util
- maven
- core-unittests/src/test/java/com/codename1/ui/plaf
- javase
- src/test/java/com/codename1/impl/javase/util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 | | |
117 | 130 | | |
118 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1790 | 1790 | | |
1791 | 1791 | | |
1792 | 1792 | | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
1793 | 1818 | | |
1794 | 1819 | | |
1795 | 1820 | | |
| |||
1801 | 1826 | | |
1802 | 1827 | | |
1803 | 1828 | | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
1804 | 1834 | | |
1805 | 1835 | | |
1806 | 1836 | | |
| |||
Lines changed: 76 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
88 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| |||
98 | 118 | | |
99 | 119 | | |
100 | 120 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
104 | 139 | | |
105 | 140 | | |
106 | 141 | | |
107 | 142 | | |
108 | 143 | | |
109 | 144 | | |
110 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
111 | 183 | | |
112 | 184 | | |
113 | 185 | | |
| |||
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
129 | 202 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
128 | 139 | | |
129 | 140 | | |
130 | 141 | | |
| |||
0 commit comments