我目前在使用 Gradle 和 Git 时遇到一些问题。
我正在使用 fxlauncher 自动更新我的应用程序。它是使用 Gradle 的构建过程进行配置的。这是根项目的 build.gradle
文件:
group 'de.zerotask'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
group 'de.zerotask'
version = rootProject.version
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile project(':fx-framework')
compile project(':guice-injector')
compile 'no.tornado:fxlauncher:1.0.11'
}
// This part creates the app manifest needed for updating app
// Installer Filename without suffix
def appFilename = 'Taskflow'
// The JavaFX Application class name
def appMainClass = 'de.zerotask.taskflow.TaskflowApplication'
// Optional override to specify where the cached files are stored. Default is current working directory
def cacheDir = 'cache'
// Optional parameters to the application, will be embedded in the launcher and can be overriden on the command line
def appParameters = ''
// The Application vendor used by javapackager
def appVendor = 'Zerotask'
// The Application version used by javapackager
def appVersion = '1.0'
// Base URL where you will host the application artifacts
def appUrl = 'https://sirwindfield.github.io/taskflow/application-content/'
// Optional scp target for application artifacts hosted at the above url
def appDeployTarget = ''
jar.archiveName = "taskflow.jar"
task buildApp(dependsOn: ['copyDependencies', 'generateAppManifest', 'embedAppManifest'])
task copyDependencies {
dependsOn jar
configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
project.copy {
from artifact.file
into 'build/libs'
rename { "${artifact.name}.${artifact.extension}" }
}
}
}
task generateAppManifest(type: JavaExec) {
main = 'fxlauncher.CreateManifest'
classpath = sourceSets.main.runtimeClasspath
args = [appUrl, appMainClass, 'build/libs', '--cache-dir=' + cacheDir, appParameters]
}
task embedAppManifest(type: Exec) {
mustRunAfter 'generateAppManifest'
workingDir 'build/libs'
commandLine 'jar', 'uf', 'fxlauncher.jar', 'app.xml'
}
task installer(type: Exec, dependsOn: 'buildApp') {
commandLine 'javapackager', '-deploy', '-native', '-outdir', 'installer', '-outfile', appFilename, '-srcdir', 'build/libs', '-srcfiles', 'fxlauncher.jar', '-appclass', 'fxlauncher.Launcher', '-name', "${rootProject.name}", '-title', "${rootProject.name}", '-vendor', "$appVendor", "-Bidentifier", "${rootProject.group}.${appFilename}", '-Bidentifier=' + project.group + '.' + appFilename, '-BappVersion=' + appVersion
}
task deployApp(type: Exec, dependsOn: 'embedAppManifest') {
workingDir 'build/libs'
// commandLine 'scp', '-r', '.', appDeployTarget
}
这一切都应该发生在 master 上。我确保在使用 gradle 执行 buildApp
任务之前切换了分支。
任务完成后,我切换到 gh-pages 分支。 Gradle 还在此处创建了 build
目录以及每个子模块的 build
目录。
我不知道为什么。我认为文件更改应该只发生在当前分支而不是其他分支上。
如果有人可以帮助我解决这个问题并向我解释为什么会发生这种情况,那真的会让我很高兴!
最佳答案
当您切换分支时,未提交到存储库的文件将保留在您的工作区中,这与 gradle 无关,但这就是 git
的工作原理。
关于java - 为什么 Gradle 在另一个 git 分支中创建文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37913057/