Skip to content

Commit b17d5b6

Browse files
committed
build(flatpak): Refactor build configuration to support offline build-logic resolution
- Replace basic `settings.gradle.kts` appending with a Python-based rewriting script for both root and `build-logic` settings. - Configure `pluginManagement` and `dependencyResolutionManagement` to strictly use the local offline repository for all project modules. - Explicitly include `build-logic` and configure its version catalog resolution from `gradle/libs.versions.toml`. - Update build source from a remote Git tag to the local directory for development builds. - Remove the `--offline` flag from the Gradle execution as network isolation is handled by the Flatpak sandbox. - Update comments to clarify Flathub submission requirements for source types.
1 parent 94d1f66 commit b17d5b6

1 file changed

Lines changed: 59 additions & 22 deletions

File tree

packaging/flatpak/zed.rainxch.githubstore.yml

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,65 @@ modules:
5151
build-commands:
5252
# Use local Gradle distribution (no network needed)
5353
- sed -i 's|distributionUrl=.*|distributionUrl=gradle-bin.zip|' gradle/wrapper/gradle-wrapper.properties
54-
# Configure Gradle to use the offline Maven repository (pre-downloaded dependencies)
54+
# Rewrite settings.gradle.kts files to use offline Maven repository
5555
- |
56-
cat >> settings.gradle.kts << 'SETTINGS_EOF'
57-
pluginManagement {
58-
repositories.clear()
59-
repositories {
60-
maven { url = uri("/run/build/githubstore/offline-repository") }
61-
gradlePluginPortal()
62-
}
63-
}
64-
dependencyResolutionManagement {
65-
repositories.clear()
66-
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
67-
repositories {
68-
maven { url = uri("/run/build/githubstore/offline-repository") }
69-
}
70-
}
71-
SETTINGS_EOF
56+
python3 -c "
57+
# 1. Rewrite root settings.gradle.kts
58+
lines = open('settings.gradle.kts').readlines()
59+
includes = [l for l in lines if l.strip().startswith('include(')]
60+
with open('settings.gradle.kts', 'w') as f:
61+
f.write('rootProject.name = \"GithubStore\"\n')
62+
f.write('enableFeaturePreview(\"TYPESAFE_PROJECT_ACCESSORS\")\n\n')
63+
f.write('pluginManagement {\n')
64+
f.write(' includeBuild(\"build-logic\")\n')
65+
f.write(' repositories {\n')
66+
f.write(' maven { url = uri(\"/run/build/githubstore/offline-repository\") }\n')
67+
f.write(' gradlePluginPortal()\n')
68+
f.write(' }\n')
69+
f.write('}\n\n')
70+
f.write('dependencyResolutionManagement {\n')
71+
f.write(' repositories {\n')
72+
f.write(' maven { url = uri(\"/run/build/githubstore/offline-repository\") }\n')
73+
f.write(' }\n')
74+
f.write('}\n\n')
75+
f.write('plugins {\n')
76+
f.write(' id(\"org.gradle.toolchains.foojay-resolver-convention\") version \"1.0.0\"\n')
77+
f.write('}\n\n')
78+
for inc in includes:
79+
f.write(inc)
80+
print('Rewrote root settings.gradle.kts for offline build')
81+
82+
# 2. Rewrite build-logic/settings.gradle.kts
83+
with open('build-logic/settings.gradle.kts', 'w') as f:
84+
f.write('@file:Suppress(\"UnstableApiUsage\")\n\n')
85+
f.write('rootProject.name = \"build-logic\"\n\n')
86+
f.write('pluginManagement {\n')
87+
f.write(' repositories {\n')
88+
f.write(' maven { url = uri(\"/run/build/githubstore/offline-repository\") }\n')
89+
f.write(' gradlePluginPortal()\n')
90+
f.write(' }\n')
91+
f.write('}\n\n')
92+
f.write('dependencyResolutionManagement {\n')
93+
f.write(' repositories {\n')
94+
f.write(' maven { url = uri(\"/run/build/githubstore/offline-repository\") }\n')
95+
f.write(' gradlePluginPortal()\n')
96+
f.write(' }\n\n')
97+
f.write(' versionCatalogs {\n')
98+
f.write(' create(\"libs\") {\n')
99+
f.write(' from(files(\"../gradle/libs.versions.toml\"))\n')
100+
f.write(' }\n')
101+
f.write(' }\n')
102+
f.write('}\n\n')
103+
f.write('include(\":convention\")\n')
104+
print('Rewrote build-logic/settings.gradle.kts for offline build')
105+
"
72106
# Disable Android targets (no Android SDK in Flatpak sandbox)
73107
- bash packaging/flatpak/disable-android-for-flatpak.sh
74-
# Build uber JAR (fully offline — all deps from offline-repository)
108+
# Build uber JAR — all deps resolved from offline-repository (local file:// Maven repo,
109+
# no network needed even without --offline flag since sandbox has no network access)
75110
- ./gradlew :composeApp:packageUberJarForCurrentOS
76111
--no-daemon
77112
--no-configuration-cache
78-
--offline
79113
-Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=2g"
80114
-Dorg.gradle.parallel=false
81115
# Install the JAR
@@ -93,9 +127,12 @@ modules:
93127
- install -Dm644 composeApp/src/jvmMain/resources/logo/app_icon.png
94128
/app/share/icons/hicolor/512x512/apps/zed.rainxch.githubstore.png
95129
sources:
96-
- type: git
97-
url: https://github.com/OpenHub-Store/GitHub-Store.git
98-
tag: 1.6.2
130+
# NOTE: For Flathub submission, switch this to:
131+
# type: git
132+
# url: https://github.com/OpenHub-Store/GitHub-Store.git
133+
# tag: <release-tag>
134+
- type: dir
135+
path: ../../
99136
# Gradle distribution (referenced by gradle-wrapper.properties after sed patch)
100137
- type: file
101138
url: https://services.gradle.org/distributions/gradle-8.14.3-bin.zip

0 commit comments

Comments
 (0)