- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在让新开发人员使用我们的 Java 代码,但我在 Windows 中遇到了错误。大多数 Gradle 命令工作正常,但我们的部署命令 (dpDeployAll) 失败。我在 3 台不同的 Windows 机器上遵循相同的设置过程;两台Win10机器出现此错误,Win7机器没有。
这是堆栈跟踪:
$ gradle dpDeployAll -Phost=10.2.9.106 --stacktrace
:deploy:checkJavaVersion UP-TO-DATE
:deploy:compileJava UP-TO-DATE
:deploy:compileGroovy UP-TO-DATE
:deploy:processResources UP-TO-DATE
:deploy:classes UP-TO-DATE
:deploy:dpDeployAll
ChargeAdmin servlet version on 10.2.9.106 is 1.3.1
Using profile all_production
Exception in thread "main" java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:414)
at java.io.File.getCanonicalPath(File.java:618)
at java_io_File$getCanonicalPath$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at deploy.Deploy$_runDeploy_closure7.doCall(Deploy.groovy:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at deploy.Deploy.runDeploy(Deploy.groovy:161)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
at deploy.Deploy.runDeployProfile(Deploy.groovy:144)
at deploy.Deploy.run(Deploy.groovy:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at deploy.Deploy.main(Deploy.groovy:335)
:deploy:dpDeployAll FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':deploy:dpDeployAll'.
> Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':deploy:dpDeployAll'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:369)
at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:74)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
... 70 more
BUILD FAILED
Total time: 4.258 secs
编辑:添加deploy.gradle文件:
version '3.8.0'
apply plugin: 'groovy'
dependencies {
compile localGroovy()
compile group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.3'
compile group: 'com.github.inamik.text.tables', name: 'inamik-text-tables', version: '1.0-SNAPSHOT'
compile group: 'org.eclipse', name: 'org.eclipse.osgi', version: ECLIPSE_OSGI_VERSION
}
['dpDeployAll', 'dpDeploy', 'dpDeployAllCustom', 'dpList', 'dpUninstall', 'dpUninstallAll'].each { name ->
//noinspection GroovyAssignabilityCheck
task "$name"(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'deploy.Deploy'
//noinspection GrUnresolvedAccess
doFirst {
if (project.hasProperty('host')) {
arguments.add(0, project.getProperty('host'))
} else {
throw new InvalidUserDataException("Missing host property: specify with \"-Phost=hostname\"")
}
//noinspection GrUnresolvedAccess,GroovyAssignabilityCheck
args arguments
}
}
}
dpDeployAll {
doFirst {
ext.arguments = ['deploy_all']
arguments += ['all_production']
}
}
dpDeploy {
doFirst {
ext.arguments = ['deploy']
if (project.hasProperty('package')) {
def packageName = project.getProperty('package')
arguments += [packageName]
} else {
throw new InvalidUserDataException("Missing packageName property: specify with \"-Ppackage=package\"")
}
}
}
dpUninstall {
doFirst {
ext.arguments = ['uninstall']
if (project.hasProperty('package')) {
def packageName = project.getProperty('package')
arguments += [packageName]
} else {
throw new InvalidUserDataException("Missing packageName property: specify with \"-Ppackage=package\"")
}
}
}
dpUninstallAll {
doFirst {
ext.arguments = ['uninstall_all']
}
}
dpList {
doFirst {
ext.arguments = ['list']
}
}
编辑:添加deploy.groovy文件:
package deploy
import com.inamik.text.tables.Cell.Functions
import com.inamik.text.tables.GridTable
import com.inamik.text.tables.grid.Border
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.Method
import org.apache.http.HttpStatus
import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.entity.mime.content.ByteArrayBody
class Deploy {
private static final String DEPLOY_ALL = 'deploy_all'
private static final String DEPLOY = 'deploy'
private static final String UNINSTALL = 'uninstall'
private static final String LIST = 'list'
private static final String UNINSTALL_ALL = 'uninstall_all'
private static final String ADMIN_USERNAME = 'REDACTED'
private static final String ADMIN_PASSWORD = 'REDACTED'
private static final String ADMIN_SERVLET_PREFIX = '/charge_admin'
private static final String GET_PACKAGES_SERVLET = ADMIN_SERVLET_PREFIX + '/get_packages'
private static final String UNINSTALL_PACKAGES_SERVLET = ADMIN_SERVLET_PREFIX + '/uninstall_package'
private static final String UPLOAD_PACKAGE_SERVLET = ADMIN_SERVLET_PREFIX + '/upload_package'
private static final String CHARGEADMIN_PACKAGE_NAME = 'com.projectfw.charge.chargeadmin'
private static final String PACKAGE_COLUMN_HEADER = "Package"
private static final String OLD_VERSION_COLUMN_HEADER = "Old Version"
private static final String NEW_VERSION_COLUMN_HEADER = "New Version"
private static final String STATUS_COLUMN_HEADER = "Status"
private static final String DEV_VERSION_STRING = "dev"
private static final String UNINSTALLED_STATUS = "UNINSTALLED"
private static final String NO_CHANGE_STATUS = "NO_CHANGE"
private static final String INSTALLED_FRESH_STATUS = "INSTALLED_FRESH"
private static final String OVERWRITTEN_STATUS = "OVERWRITTEN"
private final HTTPBuilder http
private final String[] args
private final String command
private final String host
private DeploymentPackage chargeAdminPackage
private List<DeploymentPackage> nonChargeAdminPackages
private Deploy(String[] args) {
this.args = args
this.host = args[0]
this.command = args[1]
this.http = new HTTPBuilder(String.format("http://%s", host))
http.auth.basic(ADMIN_USERNAME, ADMIN_PASSWORD)
}
private void run() {
populateExistingPackages()
println()
println "ChargeAdmin servlet version on $host is ${chargeAdminPackage.getOldVersion()}"
println()
switch (command) {
case DEPLOY_ALL:
final String profileName = args[2]
runDeployProfile(profileName)
break
case DEPLOY:
final String packageName = args[2]
runDeploySingle(packageName)
break
case UNINSTALL:
final String packageName = args[2]
runUninstall(packageName)
break
case LIST:
runList()
break
case UNINSTALL_ALL:
runUninstallAll()
break
default:
throw new RuntimeException("Unknown command $command")
}
}
private void runUninstallAll() {
if (nonChargeAdminPackages.size() == 0) {
println "No packages to uninstall on $host"
} else {
nonChargeAdminPackages.each {
uninstallSinglePackage(it.packageName)
}
}
println()
printStatusTable()
}
private void runList() {
printStatusTable()
}
private void runDeploySingle(String packageName) {
runDeploy(Arrays.asList(packageName), false, true)
}
private void runUninstall(String packageName) {
uninstallSinglePackage(packageName)
println()
printStatusTable()
}
private void uninstallSinglePackage(String packageName) {
if (nonChargeAdminPackages.find { it.packageName == packageName } == null) {
println "WARNING: Package $packageName does not exist on $host"
} else {
http.request(Method.POST) { req ->
uri.path = UNINSTALL_PACKAGES_SERVLET
requestContentType = ContentType.URLENC
body = [package: packageName]
}
DeploymentPackage packageUninstalled = nonChargeAdminPackages.find { it.packageName == packageName }
packageUninstalled.setStatus(UNINSTALLED_STATUS)
packageUninstalled.clearNewVersion()
println "Uninstalled package $packageName version ${packageUninstalled.getOldVersion()}"
}
}
private void runDeployProfile(String profileName) {
File profile = new File(profileName + '.txt')
println "Using profile $profileName"
if (!profile.exists()) {
throw new RuntimeException("Profile file ${profile.getCanonicalPath()} does not exist")
}
String contents = profile.getText('UTF-8')
List<String> deploymentPackageNames = contents.tokenize('\n').asList()
Collections.sort(deploymentPackageNames)
deploymentPackageNames = deploymentPackageNames.findAll {
!it.contains(CHARGEADMIN_PACKAGE_NAME)
}
runDeploy(deploymentPackageNames, true, false)
}
private void runDeploy(List<String> deploymentPackageNames, boolean deleteUnlistedPackages, boolean force) {
List<DeploymentPackage> packagesToUninstall = new LinkedList<>()
List<DeploymentPackage> packagesToInstallFresh = new LinkedList<>()
List<DeploymentPackage> packagesToOverwrite = new LinkedList<>()
if (deleteUnlistedPackages) {
// First, uninstall packages which are on the server but which aren't in the profile.
nonChargeAdminPackages.each {
if (!deploymentPackageNames.contains(it.getPackageName())) {
packagesToUninstall.add(it)
}
}
}
deploymentPackageNames.each {
File localPackageDir = new File("../$it/build/distributions")
if (!localPackageDir.exists()) {
throw new RuntimeException("Build directory ${localPackageDir.getCanonicalPath()} does not exist")
}
File[] deploymentPackageVersionFiles = localPackageDir.listFiles()
if (deploymentPackageVersionFiles.length == 0) {
throw new RuntimeException("Build directory ${localPackageDir.getCanonicalPath()} is empty")
}
// Collect all the versions in the directory
DeploymentPackage[] deploymentPackageVersions = deploymentPackageVersionFiles.collect { File file ->
String version = file.getName().substring(
file.getName().indexOf('-') + 1, file.getName().lastIndexOf('.'))
String packageName = file.getName().substring(0, file.getName().indexOf('-'))
DeploymentPackage deploymentPackageVersion = new DeploymentPackage(packageName)
deploymentPackageVersion.setNewVersion(version)
deploymentPackageVersion.setLocalPath(file.getCanonicalPath())
deploymentPackageVersion
}
// Find the one with the highest version number
DeploymentPackage highestVersionedDeploymentPackage = deploymentPackageVersions.max {
it.getNewVersion()
}
// Find the one that already exists on the server that we are comparing to:
DeploymentPackage existingOnServer = nonChargeAdminPackages.find {
it.getPackageName() == highestVersionedDeploymentPackage.getPackageName()
}
if (existingOnServer == null) {
// We need to upload the package for the first time
packagesToInstallFresh.add(highestVersionedDeploymentPackage)
} else if (existingOnServer.getOldVersion() != highestVersionedDeploymentPackage.getNewVersion()) {
// Existing version on server doesn't equal candidate version, should replace,
// even if candidate version is older.
packagesToUninstall.add(existingOnServer)
packagesToOverwrite.add(highestVersionedDeploymentPackage)
} else if (existingOnServer.getOldVersion().getQualifier().contains(DEV_VERSION_STRING)) {
// Existing version on server has the dev version qualifier, should replace,
// even though the version numbers are identical.
packagesToUninstall.add(existingOnServer)
packagesToOverwrite.add(highestVersionedDeploymentPackage)
} else if (force) {
// Replace it no matter what.
packagesToUninstall.add(existingOnServer)
packagesToOverwrite.add(highestVersionedDeploymentPackage)
}
}
Collections.sort(packagesToUninstall)
Collections.sort(packagesToOverwrite)
Collections.sort(packagesToInstallFresh)
packagesToUninstall.each {
uninstallSinglePackage(it.getPackageName())
}
packagesToOverwrite.each {
uploadPackage(it)
DeploymentPackage existing =
nonChargeAdminPackages.find { existing -> existing.getPackageName() == it.getPackageName() }
existing.setNewVersion(it.getNewVersion())
existing.setStatus(OVERWRITTEN_STATUS)
}
packagesToInstallFresh.each {
uploadPackage(it)
it.setStatus(INSTALLED_FRESH_STATUS)
nonChargeAdminPackages.add(it)
}
println()
printStatusTable()
}
private void uploadPackage(DeploymentPackage pkg) {
File file = new File(pkg.getLocalPath())
http.request(Method.POST) { req ->
uri.path = UPLOAD_PACKAGE_SERVLET
requestContentType = 'multipart/form-data'
req.entity = MultipartEntityBuilder.create()
.addPart("file", new ByteArrayBody(file.bytes, file.getName()))
.build()
}
println "Deployed ${pkg.getPackageName()} version ${pkg.getNewVersion()}"
}
private void populateExistingPackages() {
String packagesString = http.request(Method.GET) { req ->
uri.path = GET_PACKAGES_SERVLET
response.success = { resp, reader ->
reader.getText().toString()
}
response.failure = { HttpResponseDecorator resp, reader ->
if (resp.getStatus() == HttpStatus.SC_UNAUTHORIZED) {
throw new RuntimeException("Unauthorized -- is the ChargeAdmin servlet installed?")
}
}
}
最佳答案
您得到的异常似乎源于这些代码行:
File localPackageDir = new File("../$it/build/distributions")
if (!localPackageDir.exists()) {
throw new RuntimeException("Build directory ${localPackageDir.getCanonicalPath()} does not exist")
}
所以打印这个错误时,异常发生在.getCanonicalPath()
期间。
给定的路径“../$it/build/distributions”可能存在于您的 Windows 7 计算机上,但不存在于您的 Windows 10 计算机上,其中 $it 是 all_products.txt 中的名称之一。
该名称可能包含一些破坏 Java getCanonicalPath()
的字符,因此,如果该文件夹也不存在,您可能会在 Windows7 上遇到相同的错误。
该文件夹是构建输出文件夹,因此您可能必须运行另一个任务来创建该文件夹。
关于java - Gradle 部署失败并显示 "java.io.IOException: The filename, directory name, or volume label syntax is incorrect",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47764858/
我有名为 xxx.java.i、xxx.java.d、xxx.jar.i 的文件。我知道这些文件与 Java 有某种关系。这个扩展是什么意思以及它的用途是什么?它与 .class 扩展名的类型相同吗?
我的命名尽量在语法上正确*。我一直使用 filename 而不是 fileName。 java 约定似乎也使用这个,但 FxCop 更喜欢 fileName。 有一个discussion on Wik
来自MISRA-C 2004 : 19.3 (req): The '#include' directive shall be followed by either a or "filename" s
我有一个 SKScene 类,我需要在其中实现一个自定义初始化程序来覆盖 SKScene 父类(super class) SKNode 的初始化程序 init(fileNamed: fileNamed
在 C 和 C++ 编程语言中,在 include 中使用尖括号和使用引号有什么区别?声明,如下? #include #include "filename" 最佳答案 实际上,区别在于预处理器搜索包
我想解压一个文件,例如使用 shell 命令将“tar123.tar.gz”复制到目录/myunzip/tar123/”。 tar -xf tar123.tar.gz 将解压缩文件,但在与我工作的目录
我是 C 语言新手,我知道这两个命令都完成相同的任务,但是其中一个命令是否会执行与另一个命令不同的操作? 最佳答案 首先,如果您使用 make,那么对于 hello.c,您将调用 make 作为 ma
我正在编写一个程序,它将文件名列表存储为字符串数组。当我将其声明为 char *filenames[1] 我没有错误......但是当我这样做时 char *filenames 我遇到了一些错误。不在
我在将 Appirater 集成到我的应用程序时遇到了一些问题。我已经正确添加了所有必要的文件,并拥有正确的代码(我认为),但是在尝试将其实现到我的 AppDelegate.m 文件中时出现错误。当我
在 include 中使用尖括号和引号有什么区别?指令? #include <filename> #include "filename"
我目前正在寻找一种批量获取变量并仅解析文件名的方法。 例如,我将来自另一个应用程序的 -s 参数传递给我的批处理文件,该参数随后被设置为我的源变量。源文件变量通常包含如下内容:C:\Program F
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
我正在尝试从源代码安装rtorrent,但是在编译时出现错误。我正在使用新的Ubuntu 20.04 VM。 libtorrent安装 sudo apt update sudo apt upgrade
在 GNU Makefile(在 Ubuntu Linux 系统上)中,如何删除列表中每个文件名的文件名后缀,以便在第一个点处截断文件名? 假设我有 NAMES = file1.a.b.c file2
1-intro-to deepleanring and computer visionk.MKV 2.Kaggle Deep Learning - YouTube.MP4 Convolutional
我希望 gvim 始终在单独的窗口中打开并立即返回命令提示符。换句话说我想要 gvim filename 与相同 gvim filename & 看来我应该可以用别名来做到这一点。别名是否有特殊的通配
以下代码发送一个 GET 请求,该请求的响应应该在客户端 (Chrome) 上启动文件下载过程。 $.ajax({ type: "GET", traditional: true, asyn
我有一堆 filename.bz2.gz 的文件,我想将其转换为 filename.gz。 有什么帮助吗? 谢谢 最佳答案 有了您的文件名*.bz2.gz,我假设该文件是使用以下压缩顺序创建的: ec
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Reference - What does this symbol mean in PHP? 我正在制作一个
如何合并 abc.mp4.tmp 与实际 交换文件abc.mp4 文件。我试图使用 Wowza Media server 3.6 录制现场事件,但录制的文件在最后一刻没有正确混合。 abc.mp4.t
我是一名优秀的程序员,十分优秀!