Fix build due to JCenter shutdown (fixes #1135) (#1136)

This commit is contained in:
Catfriend1 2024-10-21 23:48:31 +02:00 committed by GitHub
parent b960117994
commit 84144f8211
16 changed files with 223 additions and 209 deletions

View File

@ -6,7 +6,7 @@ cls
REM
REM Script Consts.
SET CLEANUP_BEFORE_BUILD=1
SET SKIP_RELEASE_BUILD=0
SET SKIP_RELEASE_BUILD=1
REM
REM Runtime Variables.
IF EXIST "%LocalAppData%\Android\Sdk" SET "ANDROID_SDK_ROOT=%LocalAppData%\Android\Sdk"

View File

@ -56,7 +56,7 @@ git fetch --quiet --all
SET RESULT=%ERRORLEVEL%
IF NOT "%RESULT%" == "0" echo [ERROR] git fetch FAILED. & goto :eos
REM
echo [INFO] Reading required SyncthingNative from versions.gradle ...
echo [INFO] Reading required SyncthingNative from build.gradle.kts ...
IF NOT DEFINED SYNCTHING_NATIVE_REQUIRED_VERSION call :getRequiredSynchtingNativeVersion
REM
echo [INFO] Checking out syncthing_%SYNCTHING_NATIVE_REQUIRED_VERSION% ...
@ -103,17 +103,17 @@ goto :eof
REM
REM Get "versionMajor"
SET VERSION_MAJOR=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
SET VERSION_MAJOR=%VERSION_MAJOR:"=%
REM
REM Get "versionMinor"
SET VERSION_MINOR=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
SET VERSION_MINOR=%VERSION_MINOR:"=%
REM
REM Get "versionPatch"
SET VERSION_PATCH=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
SET VERSION_PATCH=%VERSION_PATCH:"=%
REM
SET "SYNCTHING_NATIVE_REQUIRED_VERSION=v%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%"

View File

@ -1,152 +0,0 @@
plugins {
id 'com.android.application'
id 'com.github.ben-manes.versions'
id 'com.github.triplet.play' version '3.6.0'
}
dependencies {
androidTestImplementation 'androidx.annotation:annotation:1.2.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
annotationProcessor "com.google.dagger:dagger-compiler:2.38.1"
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core:1.3.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.fragment:fragment:1.2.5'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.annimon:stream:1.2.2'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.google.dagger:dagger:2.38.1'
implementation 'com.google.guava:guava:30.1.1-android'
// Do not upgrade zxing:core beyond 3.3.0 to ensure Android 6.0 compatibility, see issue #761.
implementation 'com.google.zxing:core:3.3.0'
implementation ('com.journeyapps:zxing-android-embedded:4.2.0') { transitive = false }
implementation 'eu.chainfire:libsuperuser:1.1.0.202004101746'
implementation 'org.mindrot:jbcrypt:0.4'
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
}
apply from: 'versions.gradle'
def ourVersionCode = versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionWrapper
def ourVersionName = "${versionMajor}.${versionMinor}.${versionPatch}.${versionWrapper}"
android {
compileSdkVersion 35
buildToolsVersion '35.0.0'
ndkVersion = "${ndkVersionShared}"
namespace = 'com.nutomic.syncthingandroid'
buildFeatures.dataBinding = true
defaultConfig {
applicationId "com.github.catfriend1.syncthingandroid"
minSdkVersion 21
targetSdkVersion 35
versionCode ourVersionCode
versionName ourVersionName
testApplicationId 'com.github.catfriend1.syncthingandroid.test'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
release {
storeFile = {
def path = System.getenv("SYNCTHING_RELEASE_STORE_FILE")
return (path) ? file(path) : null
}()
storePassword System.getenv("SIGNING_PASSWORD") ?: ""
keyAlias System.getenv("SYNCTHING_RELEASE_KEY_ALIAS") ?: ""
keyPassword System.getenv("SIGNING_PASSWORD") ?: ""
}
}
buildTypes {
release {
signingConfig = signingConfigs.release.storeFile ? signingConfigs.release : null
}
debug {
applicationIdSuffix ".debug"
gradle.buildFinished {
buildResult -> if (buildResult.failure) {
logger.lifecycle("BUILD FAILED")
}
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
bundle {
language {
enableSplit = false
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
}
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}
lint {
abortOnError true
disable 'UnsafeExperimentalUsageError', 'UnsafeExperimentalUsageWarning', 'ExpiringTargetSdkVersion', 'ExpiredTargetSdkVersion'
}
}
play {
// Use ANDROID_PUBLISHER_CREDENTIALS environment variable to specify serviceAccountCredentials.
track = 'beta'
resolutionStrategy = com.github.triplet.gradle.androidpublisher.ResolutionStrategy.IGNORE
defaultToAppBundles = true
}
tasks.whenTaskAdded { task ->
if (task.name == 'compileDebugSources') {
// task.dependsOn lint
// task.mustRunAfter lint
}
}
/**
* Some languages are not supported by Google Play, so we ignore them.
*/
task deleteUnsupportedPlayTranslations(type: Delete) {
delete 'src/main/play/listings/el-EL/'
delete 'src/main/play/listings/en/'
delete 'src/main/play/listings/eu/'
delete 'src/main/play/listings/nb/'
delete 'src/main/play/listings/nl_BE/'
delete 'src/main/play/listings/nl-BE/'
delete 'src/main/play/listings/nn/'
delete 'src/main/play/listings/ta/'
}
task postBuildScript(type: Exec) {
executable = 'python'
args = ['-u', './postbuild.py']
}
project.afterEvaluate {
project.getTasks().getByName("mergeDebugJniLibFolders").dependsOn(":syncthing:buildNative")
}

148
app/build.gradle.kts Normal file
View File

@ -0,0 +1,148 @@
plugins {
id("com.android.application")
id("com.github.ben-manes.versions")
id("com.github.triplet.play") version "3.7.0"
}
dependencies {
androidTestImplementation("androidx.annotation:annotation:1.2.0")
androidTestImplementation("androidx.test:rules:1.4.0")
annotationProcessor("com.google.dagger:dagger-compiler:2.38.1")
implementation("androidx.preference:preference:1.1.1")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation("androidx.core:core:1.3.0")
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.fragment:fragment:1.2.5")
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.0.0")
implementation("androidx.recyclerview:recyclerview:1.1.0")
implementation("com.android.volley:volley:1.2.1")
implementation("com.annimon:stream:1.2.2")
implementation("com.google.android.material:material:1.4.0")
implementation("com.google.code.gson:gson:2.8.8")
implementation("com.google.dagger:dagger:2.38.1")
implementation("com.google.guava:guava:30.1.1-android")
// Do not upgrade zxing:core beyond 3.3.0 to ensure Android 6.0 compatibility, see issue #761.
implementation("com.google.zxing:core:3.3.0")
implementation("com.journeyapps:zxing-android-embedded:4.2.0") { isTransitive = false }
implementation("eu.chainfire:libsuperuser:1.1.1")
implementation("org.mindrot:jbcrypt:0.4")
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
}
android {
val ndkVersionShared = rootProject.extra.get("ndkVersionShared")
val versionMajor: kotlin.Int by rootProject.extra
val versionMinor: kotlin.Int by rootProject.extra
val versionPatch: kotlin.Int by rootProject.extra
val versionWrapper: kotlin.Int by rootProject.extra
compileSdk = 35
buildToolsVersion = "35.0.0"
ndkVersion = "${ndkVersionShared}"
namespace = "com.nutomic.syncthingandroid"
buildFeatures.dataBinding = true
defaultConfig {
applicationId = "com.github.catfriend1.syncthingandroid"
minSdk = 21
targetSdk = 35
versionCode = versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionWrapper
versionName = "${versionMajor}.${versionMinor}.${versionPatch}.${versionWrapper}"
testApplicationId = "com.github.catfriend1.syncthingandroid.test"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
create("release") {
storeFile = System.getenv("SYNCTHING_RELEASE_STORE_FILE")?.let(::file)
storePassword = System.getenv("SIGNING_PASSWORD")
keyAlias = System.getenv("SYNCTHING_RELEASE_KEY_ALIAS")
keyPassword = System.getenv("SIGNING_PASSWORD")
}
}
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
isDebuggable = true
isJniDebuggable = true
isMinifyEnabled = false
}
getByName("release") {
signingConfig = signingConfigs.runCatching { getByName("release") }
.getOrNull()
.takeIf { it?.storeFile != null }
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
bundle {
language {
enableSplit = false
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
}
packaging {
jniLibs {
useLegacyPackaging = true
}
}
lint {
abortOnError = true
disable += "UnsafeExperimentalUsageError"
disable += "UnsafeExperimentalUsageWarning"
disable += "ExpiringTargetSdkVersion"
disable += "ExpiredTargetSdkVersion"
}
}
play {
// Use ANDROID_PUBLISHER_CREDENTIALS environment variable to specify serviceAccountCredentials.
track = "beta"
resolutionStrategy = com.github.triplet.gradle.androidpublisher.ResolutionStrategy.IGNORE
defaultToAppBundles = true
}
/**
* Some languages are not supported by Google Play, so we ignore them.
*/
tasks.register<Delete>("deleteUnsupportedPlayTranslations") {
delete(
"src/main/play/listings/el-EL/",
"src/main/play/listings/en/",
"src/main/play/listings/eu/",
"src/main/play/listings/nb/",
"src/main/play/listings/nl_BE/",
"src/main/play/listings/nl-BE/",
"src/main/play/listings/nn/",
"src/main/play/listings/ta/",
)
}
task<Exec>("postBuildScript") {
commandLine("python", "-u" , "./postbuild.py")
}
project.afterEvaluate {
project.getTasks().getByName("mergeDebugJniLibFolders").dependsOn(":syncthing:buildNative")
}

View File

@ -20,7 +20,6 @@ import com.google.zxing.common.BitMatrix;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.nutomic.syncthingandroid.BuildConfig;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.activities.MainActivity;
import com.nutomic.syncthingandroid.activities.RecentChangesActivity;
@ -135,7 +134,7 @@ public class DrawerFragment extends Fragment implements SyncthingService.OnServi
* Reason: SyncthingNative's Web UI is not approved by Google because
* it is lacking full DPAD navigation support. See issue #567.
*/
mDrawerActionWebGui.setVisibility((!mRunningOnTV || BuildConfig.DEBUG) ? View.VISIBLE : View.GONE);
mDrawerActionWebGui.setVisibility((!mRunningOnTV) ? View.VISIBLE : View.GONE);
// Enable buttons if syncthing is running.
mDrawerRecentChanges.setEnabled(syncthingRunning);

View File

@ -1,6 +0,0 @@
ext {
versionMajor = 1
versionMinor = 27
versionPatch = 12
versionWrapper = 0
}

View File

@ -1,30 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
// Cannot be called "ndkVersion" as that leads to naming collision
ndkVersionShared = '27.0.12077973'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.36.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

31
build.gradle.kts Normal file
View File

@ -0,0 +1,31 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
extra.apply {
// Cannot be called "ndkVersion" as that leads to naming collision
// Changes to this value must be reflected in `./docker/Dockerfile`
set("ndkVersionShared", "27.0.12077973")
set("versionMajor", 1)
set("versionMinor", 28)
set("versionPatch", 0)
set("versionWrapper", 0)
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.6.1")
classpath("com.github.ben-manes:gradle-versions-plugin:0.42.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
tasks.register<Delete>("clean") {
delete(layout.buildDirectory)
}

3
ga.cmd Normal file
View File

@ -0,0 +1,3 @@
@echo off
git add .
goto :eof

View File

@ -1,4 +1,3 @@
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false
android.nonFinalResIds=false
android.nonTransitiveRClass=false

View File

@ -1,8 +1,8 @@
#Thu Sep 29 21:34:28 CEST 2022
# https://gradle.org/release-checksums/
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
zipStoreBase=GRADLE_USER_HOME

View File

@ -24,31 +24,31 @@ IF NOT DEFINED BUILD_FLAVOUR_GPLAY echo [ERROR] Env var BUILD_FLAVOUR_GPLAY not
REM
REM Get "applicationId"
SET APPLICATION_ID=
FOR /F "tokens=2 delims= " %%A IN ('type "%SCRIPT_PATH%app\build.gradle" 2^>^&1 ^| findstr /c:"applicationId "') DO SET APPLICATION_ID=%%A
FOR /F "tokens=3 delims= " %%A IN ('type "%SCRIPT_PATH%app\build.gradle.kts" 2^>^&1 ^| findstr /c:"applicationId "') DO SET APPLICATION_ID=%%A
SET APPLICATION_ID=%APPLICATION_ID:"=%
echo [INFO] applicationId="%APPLICATION_ID%"
REM
REM Get "versionMajor"
SET VERSION_MAJOR=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
SET VERSION_MAJOR=%VERSION_MAJOR:"=%
REM echo [INFO] versionMajor="%VERSION_MAJOR%"
REM
REM Get "versionMinor"
SET VERSION_MINOR=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
SET VERSION_MINOR=%VERSION_MINOR:"=%
REM echo [INFO] versionMinor="%VERSION_MINOR%"
REM
REM Get "versionPatch"
SET VERSION_PATCH=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
SET VERSION_PATCH=%VERSION_PATCH:"=%
REM echo [INFO] versionPatch="%VERSION_PATCH%"
REM
REM Get "versionWrapper"
SET VERSION_WRAPPER=
FOR /F "tokens=2 delims== " %%A IN ('type "%SCRIPT_PATH%app\versions.gradle" 2^>^&1 ^| findstr "versionWrapper"') DO SET VERSION_WRAPPER=%%A
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionWrapper"') DO SET VERSION_WRAPPER=%%A
SET VERSION_WRAPPER=%VERSION_WRAPPER:"=%
REM echo [INFO] versionWrapper="%VERSION_WRAPPER%"
REM

View File

@ -1 +0,0 @@
include ':app', ':syncthing'

21
settings.gradle.kts Normal file
View File

@ -0,0 +1,21 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = java.net.URI("https://jitpack.io") }
}
}
include(
":app",
":syncthing"
)

View File

@ -63,11 +63,11 @@ def fail(message, *args, **kwargs):
def get_min_sdk(project_dir):
with open(os.path.join(project_dir, 'app', 'build.gradle')) as file_handle:
with open(os.path.join(project_dir, 'app', 'build.gradle.kts')) as file_handle:
for line in file_handle:
tokens = list(filter(None, line.split()))
if len(tokens) == 2 and tokens[0] == 'minSdkVersion':
return int(tokens[1])
if len(tokens) == 3 and tokens[0] == 'minSdk':
return int(tokens[2])
fail('Failed to find minSdkVersion')
@ -316,6 +316,8 @@ syncthing_dir = os.path.join(module_dir, 'src', 'github.com', 'syncthing', 'sync
prerequisite_tools_dir = os.path.dirname(os.path.realpath(__file__)) + os.path.sep + ".." + os.path.sep + ".." + os.path.sep + "syncthing-android-prereq"
min_sdk = get_min_sdk(project_dir)
# print ('Info: min_sdk = ' + str(min_sdk))
# Check if git is available.
git_bin = which("git");
if not git_bin:
@ -330,7 +332,7 @@ print('git_bin=\'' + git_bin + '\'')
# Check if go is available.
go_bin = which("go");
if not go_bin:
print('Warning: go is not available on the PATH.')
print('Info: go is not available on the PATH. Trying install_go')
install_go();
# Retry: Check if go is available.
go_bin = which("go");

@ -1 +1 @@
Subproject commit a3c340ece9895887dfeaec759340f807f3b80e51
Subproject commit 6d64daaba326ba8378c700e00a31e425c7c90579