Fix Android TV APK distribution (#139)

* Fix Android TV APK distribution

* Fix Android TV Gradle settings

* Run Android TV APK checks on branch pushes

* Add Android TV launcher assets
This commit is contained in:
Kuek Hao Yang
2026-04-02 21:03:02 +08:00
committed by GitHub
parent f096cc977b
commit 644cc3993b
18 changed files with 739 additions and 21 deletions
+101
View File
@@ -0,0 +1,101 @@
name: Android TV APK
on:
pull_request:
paths:
- "android-tv/**"
- ".github/workflows/android-tv-apk.yml"
push:
paths:
- "android-tv/**"
- ".github/workflows/android-tv-apk.yml"
workflow_dispatch:
inputs:
release_tag:
description: "Optional release tag used to publish the built APK"
required: false
type: string
release_title:
description: "Optional release title"
required: false
type: string
kvideo_url:
description: "Optional default KVideo URL baked into the APK"
required: false
type: string
permissions:
contents: write
jobs:
build_android_tv_apk:
runs-on: ubuntu-latest
env:
KVIDEO_URL: ${{ github.event_name == 'workflow_dispatch' && inputs.kvideo_url || '' }}
defaults:
run:
working-directory: android-tv
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: gradle
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install Android SDK packages
run: sdkmanager "platforms;android-34" "build-tools;34.0.0"
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Build debug APK
run: ./gradlew --no-daemon assembleDebug -PkvideoUrl="$KVIDEO_URL"
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: kvideo-android-tv-apk
path: android-tv/app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: error
- name: Publish GitHub release
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag != '' }}
working-directory: .
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ inputs.release_tag }}
RELEASE_TITLE: ${{ inputs.release_title }}
run: |
release_notes="$(mktemp)"
effective_title="${RELEASE_TITLE:-Android TV APK ${RELEASE_TAG}}"
default_url_text="${KVIDEO_URL:-未预置,首次启动时手动填写}"
cat >"$release_notes" <<EOF
预构建的 Android TV APK。
使用方式:
1. 下载并侧载安装 APK
2. 首次启动时输入你的 KVideo 地址
3. 保存后即可直接进入
构建提交:$GITHUB_SHA
默认地址:$default_url_text
EOF
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" "android-tv/app/build/outputs/apk/debug/app-debug.apk#KVideo-AndroidTV.apk" --clobber
gh release edit "$RELEASE_TAG" --title "$effective_title" --notes-file "$release_notes"
else
gh release create "$RELEASE_TAG" "android-tv/app/build/outputs/apk/debug/app-debug.apk#KVideo-AndroidTV.apk" \
--title "$effective_title" \
--notes-file "$release_notes" \
--target "$GITHUB_SHA"
fi
+21 -8
View File
@@ -781,6 +781,11 @@ npm start
项目内置了一个轻量的 Android TV WebView 壳应用,可以将 KVideo 打包成 APK 安装到 Android TV 或机顶盒上。
**直接下载:**
- 仓库维护者可以通过 GitHub Actions 的 `Android TV APK` 工作流直接发布预构建 APK 到 **Releases**
- 用户下载安装后,首次启动时填写自己的 KVideo 地址即可,不需要再改源码重新编译
**前置要求:**
- [Android Studio](https://developer.android.com/studio)(推荐)或 Android SDK Command-line Tools
@@ -788,33 +793,41 @@ npm start
**步骤:**
1. **修改目标 URL**:编辑 `android-tv/app/src/main/java/com/kvideo/tv/MainActivity.kt`,将 `KVIDEO_URL` 改为你的部署地址
```kotlin
private const val KVIDEO_URL = "https://your-kvideo-instance.com"
```
2. **使用 Android Studio 构建(推荐)**
1. **使用 Android Studio 构建(推荐)**
- 用 Android Studio 打开 `android-tv/` 目录
- 等待 Gradle 同步完成
- 点击 **Build → Build Bundle(s) / APK(s) → Build APK(s)**
- APK 输出在 `android-tv/app/build/outputs/apk/debug/app-debug.apk`
3. **使用命令行构建**
2. **使用命令行构建**
```bash
cd android-tv
./gradlew assembleDebug
```
APK 输出在 `app/build/outputs/apk/debug/app-debug.apk`
4. **安装到 Android TV**
如果你希望在构建时预置默认地址,可额外传入 `-PkvideoUrl`
```bash
cd android-tv
./gradlew assembleDebug -PkvideoUrl="https://your-kvideo-instance.com"
```
3. **安装到 Android TV**
```bash
adb install app/build/outputs/apk/debug/app-debug.apk
```
或通过 U 盘、文件管理器等方式侧载安装。
4. **首次启动配置**
- 首次打开 APK 时输入你的 KVideo 部署地址
- 保存后应用会记住该地址,后续直接打开即可
- 需要修改地址时,可在站点根页按返回,或使用部分遥控器的菜单键重新打开设置页
> **注意**:此 APK 是一个 WebView 壳应用,需要你的 KVideo 实例已经部署并可访问。APK 本身不包含 KVideo 代码,仅作为 TV 端的浏览器入口。
>
> **最低系统要求**Android 8.0 (API 26) 及以上。Android 7.0 及更低版本的 WebView 不支持本项目使用的 ES2017+ JavaScript 特性和现代 CSS,可能导致白屏。如遇白屏问题,请升级系统 WebView 或使用 Android 8.0+ 设备。
>
> **发布方式**GitHub Actions 的 `Android TV APK` 工作流会持续验证壳应用可构建;如需对外发布预构建 APK,可手动触发该工作流并填写 `release_tag`,生成对应的 GitHub Release 资产。
#### 选项 6Apple TV 应用构建
+14 -1
View File
@@ -3,16 +3,25 @@ plugins {
id("org.jetbrains.kotlin.android") version "1.9.22"
}
val defaultKVideoUrl = providers
.gradleProperty("kvideoUrl")
.orElse("")
.get()
.replace("\\", "\\\\")
.replace("\"", "\\\"")
android {
namespace = "com.kvideo.tv"
compileSdk = 34
defaultConfig {
applicationId = "com.kvideo.tv"
minSdk = 21
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0.0"
buildConfigField("String", "DEFAULT_KVIDEO_URL", "\"$defaultKVideoUrl\"")
}
buildTypes {
@@ -32,6 +41,10 @@ android {
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true
}
}
dependencies {
@@ -14,9 +14,11 @@
<application
android:allowBackup="true"
android:banner="@drawable/tv_banner"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
@@ -1,6 +1,8 @@
package com.kvideo.tv
import android.annotation.SuppressLint
import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
@@ -9,23 +11,30 @@ import android.webkit.WebChromeClient
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import androidx.activity.ComponentActivity
class MainActivity : ComponentActivity() {
companion object {
/**
* The URL of your deployed KVideo instance.
* Change this to your own domain or IP address.
*/
private const val KVIDEO_URL = "https://kvideo.example.com"
private const val PREFS_NAME = "kvideo_tv_settings"
private const val PREF_SERVER_URL = "server_url"
}
private lateinit var webView: WebView
private lateinit var setupContainer: View
private lateinit var urlInput: EditText
private lateinit var statusText: TextView
private lateinit var openButton: Button
private lateinit var saveButton: Button
private lateinit var prefs: android.content.SharedPreferences
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
// Fullscreen immersive mode
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@@ -41,6 +50,15 @@ class MainActivity : ComponentActivity() {
setContentView(R.layout.activity_main)
webView = findViewById(R.id.webview)
setupContainer = findViewById(R.id.setup_container)
urlInput = findViewById(R.id.url_input)
statusText = findViewById(R.id.status_text)
openButton = findViewById(R.id.open_button)
saveButton = findViewById(R.id.save_button)
saveButton.setOnClickListener {
openConfiguredUrl()
}
webView.apply {
setLayerType(View.LAYER_TYPE_HARDWARE, null)
@@ -58,14 +76,25 @@ class MainActivity : ComponentActivity() {
webViewClient = WebViewClient()
webChromeClient = WebChromeClient()
}
loadUrl(KVIDEO_URL)
val configuredUrl = getConfiguredUrl()
if (configuredUrl.isNotEmpty()) {
urlInput.setText(configuredUrl)
loadConfiguredUrl(configuredUrl)
} else {
showSetup(getString(R.string.status_first_launch))
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (!isSetupVisible() && (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_SETTINGS)) {
showSetup(getString(R.string.status_settings_hint))
return true
}
// Map D-pad center to Enter for spatial navigation
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
if (!isSetupVisible() && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
webView.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER))
return true
}
@@ -73,7 +102,7 @@ class MainActivity : ComponentActivity() {
}
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
if (!isSetupVisible() && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
webView.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER))
return true
}
@@ -82,11 +111,16 @@ class MainActivity : ComponentActivity() {
@Deprecated("Use OnBackPressedDispatcher")
override fun onBackPressed() {
if (isSetupVisible()) {
@Suppress("DEPRECATION")
super.onBackPressed()
return
}
if (webView.canGoBack()) {
webView.goBack()
} else {
@Suppress("DEPRECATION")
super.onBackPressed()
showSetup(getString(R.string.status_settings_hint))
}
}
@@ -94,4 +128,86 @@ class MainActivity : ComponentActivity() {
webView.destroy()
super.onDestroy()
}
private fun openConfiguredUrl() {
val normalizedUrl = normalizeUrl(urlInput.text.toString())
if (!isValidUrl(normalizedUrl)) {
statusText.text = getString(R.string.status_invalid_url)
urlInput.requestFocus()
return
}
prefs.edit().putString(PREF_SERVER_URL, normalizedUrl).apply()
loadConfiguredUrl(normalizedUrl)
}
private fun loadConfiguredUrl(url: String) {
setupContainer.visibility = View.GONE
statusText.text = getString(R.string.status_ready)
webView.loadUrl(url)
}
private fun showSetup(message: String) {
val currentUrl = getConfiguredUrl()
if (currentUrl.isNotEmpty() && urlInput.text.toString().isBlank()) {
urlInput.setText(currentUrl)
}
if (currentUrl.isNotEmpty()) {
openButton.text = getString(R.string.button_open_saved)
openButton.setOnClickListener {
urlInput.setText(currentUrl)
loadConfiguredUrl(currentUrl)
}
} else {
openButton.text = getString(R.string.button_exit)
openButton.setOnClickListener {
finish()
}
}
statusText.text = message
setupContainer.visibility = View.VISIBLE
urlInput.requestFocus()
}
private fun getConfiguredUrl(): String {
val savedUrl = prefs.getString(PREF_SERVER_URL, null)?.trim().orEmpty()
if (isValidUrl(savedUrl)) {
return savedUrl
}
val defaultUrl = normalizeUrl(BuildConfig.DEFAULT_KVIDEO_URL)
return if (isValidUrl(defaultUrl)) defaultUrl else ""
}
private fun isSetupVisible(): Boolean = setupContainer.visibility == View.VISIBLE
private fun normalizeUrl(rawUrl: String): String {
val trimmed = rawUrl.trim()
if (trimmed.isEmpty()) {
return ""
}
val withScheme = if (
trimmed.startsWith("http://", ignoreCase = true) ||
trimmed.startsWith("https://", ignoreCase = true)
) {
trimmed
} else {
"https://$trimmed"
}
return withScheme.removeSuffix("/")
}
private fun isValidUrl(url: String): Boolean {
if (url.isBlank()) {
return false
}
val uri = Uri.parse(url)
val scheme = uri.scheme?.lowercase()
return (scheme == "http" || scheme == "https") && !uri.host.isNullOrBlank()
}
}
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:angle="0"
android:endColor="#1D4ED8"
android:startColor="#0F172A" />
<corners android:radius="20dp" />
</shape>
</item>
<item android:gravity="center">
<inset
android:insetBottom="28dp"
android:insetLeft="118dp"
android:insetRight="118dp"
android:insetTop="28dp">
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</inset>
</item>
</layer-list>
@@ -8,4 +8,102 @@
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/setup_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E6101115"
android:gravity="center"
android:orientation="vertical"
android:padding="32dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F31A1C22"
android:elevation="12dp"
android:maxWidth="680dp"
android:orientation="vertical"
android:padding="32dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_title"
android:textColor="#FFFFFF"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/setup_description"
android:textColor="#D7DBE5"
android:textSize="18sp" />
<EditText
android:id="@+id/url_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="#FF0D0F14"
android:hint="@string/setup_hint"
android:importantForAutofill="no"
android:imeOptions="actionDone"
android:inputType="textUri"
android:minHeight="56dp"
android:paddingHorizontal="18dp"
android:paddingVertical="14dp"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textColorHint="#7D8597"
android:textSize="20sp" />
<TextView
android:id="@+id/status_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:text="@string/status_ready"
android:textColor="#F5B942"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<Button
android:id="@+id/open_button"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:text="@string/button_open_saved"
android:textAllCaps="false"
android:textSize="18sp" />
<Button
android:id="@+id/save_button"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/button_save"
android:textAllCaps="false"
android:textSize="18sp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/setup_footer"
android:textColor="#9EA7BA"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@@ -1,3 +1,14 @@
<resources>
<string name="app_name">KVideo</string>
<string name="setup_title">连接你的 KVideo</string>
<string name="setup_description">首次使用时输入你的 KVideo 部署地址。保存后,APK 会记住这个地址,后续可直接打开。</string>
<string name="setup_hint">https://example.com</string>
<string name="setup_footer">提示:如果 APK 已打开站点,按返回直到页面根目录即可回到这里;部分遥控器也可直接按菜单键打开此设置页。</string>
<string name="button_open_saved">打开已保存地址</string>
<string name="button_save">保存并重载</string>
<string name="button_exit">退出</string>
<string name="status_ready">已准备就绪</string>
<string name="status_first_launch">首次使用请先填写可访问的 KVideo 地址</string>
<string name="status_invalid_url">地址无效。请输入完整的 http:// 或 https:// 地址,或输入域名后让应用自动补全为 https://。</string>
<string name="status_settings_hint">你可以在这里修改服务器地址,然后重新打开 KVideo。</string>
</resources>
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+248
View File
@@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1 -1
View File
@@ -6,7 +6,7 @@ pluginManagement {
}
}
dependencyResolution {
dependencyResolutionManagement {
repositories {
google()
mavenCentral()