我创建了简单的build.gradle.kts文件
group = "com.lapots.breed"
version = "1.0-SNAPSHOT"
plugins { java }
java { sourceCompatibility = JavaVersion.VERSION_1_8 }
repositories { mavenCentral() }
dependencies {}
task<JavaExec>("execute") {
main = "com.lapots.breed.Application"
classpath = java.sourceSets["main"].runtimeClasspath
}
Run Code Online (Sandbox Code Playgroud)
在src/main/java/com.lapots.breed我Application用 main 方法创建类
package com.lapots.breed;
public class Application {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试执行execute任务时,它失败了,错误是任务不存在。此外,当我列出所有可用的任务时,gradlew tasks它不会显示execute任务。
问题是什么?
在源代码中:
// Contains returns true if substr is within s.
func Contains(s, substr string) bool {
return Index(s, substr) >= 0
}
// ContainsAny returns true if any Unicode code points in chars are within s.
func ContainsAny(s, chars string) bool {
return IndexAny(s, chars) >= 0
}
Run Code Online (Sandbox Code Playgroud)
唯一的区别似乎是substr和the Unicode code points in chars.我写了一些测试来测试它们.他们的行为似乎完全相同.我不明白何时使用哪个.
我需要在symlink目录中从Java运行本机进程.我们有以下目录结构:
guido@Firefly:~/work$ tree
.
??? path
??? to
??? symlink -> /home/guido/work
3 directories, 0 files
Run Code Online (Sandbox Code Playgroud)
我从~/work目录启动Java应用程序,并希望在目录中运行本机进程~/work/path/to/symlink.
但是,如果我使用以下Java代码,则符号链接工作目录将解析为实际路径.相反,我想在绝对路径中运行命令.
(请注意,该pwd命令仅用于说明,应替换为"真实"命令(例如go build在我的情况下)).
File baseDir = new File("/home/guido/work");
File link = new File(baseDir, "path/to/symlink");
Files.createSymbolicLink(link.toPath(), baseDir.toPath());
Process process = new ProcessBuilder()
.command("pwd")
.directory(link)
.start();
String output = getOutput(process);
System.out.println(output); // Prints: /home/guido/work
Run Code Online (Sandbox Code Playgroud)
我能够通过以下解决方法满足我的需求,但启动shell只是为了能够在特定目录中触发一个简单的进程看起来很愚蠢.另外,我失去了平台独立性.
String[] cmd = {"/bin/sh", "-c", "cd " + link + " && pwd"};
Process process …Run Code Online (Sandbox Code Playgroud) 我想用 2 个作业运行 CI pipline:
是否可以?
我正在构建一个自定义的gradle.kts脚本,该脚本将对我们所有的各个模块进行maven发布到sonatype存储库,但是遇到一个奇怪的错误。这是我maven-deploy.gradle.kts文件的内容:
plugins {
`maven-publish`
signing
}
publishing {
//expression 'publishing' cannot be invoked as a function.
//The function invoke() is not found
}
Run Code Online (Sandbox Code Playgroud)
我可以在maven-deploy.gradle.kts文件中正常运行任务,但不能尝试使用publishinggradle文档中的函数。有任何想法吗?我正在使用gradle版本4.10.3(我需要Android支持)。该maven-deploy.gradle.kts文件位于我的主项目的文件中buildSrc/src/main/kotlin,并正在其中添加。id("maven-deploy")build.gradle.kts
我正在尝试将pom.xml文件上传到 Artifactory 服务器上托管的 Maven 存储库。该<project>部分pom.xml如下所示:
<groupId>com.x.y.z</groupId>
<artifactId>common</artifactId>
<version>2.3.0-RELEASE</version>
<packaging>jar</packaging>
Run Code Online (Sandbox Code Playgroud)
我在 Pipeline 脚本中使用 Jenkins 的 Artifactory 插件,这是uploadSpec
<groupId>com.x.y.z</groupId>
<artifactId>common</artifactId>
<version>2.3.0-RELEASE</version>
<packaging>jar</packaging>
Run Code Online (Sandbox Code Playgroud)
当我现在尝试上传工件时,收到以下错误消息:
java.io.IOException: Failed to deploy file.
Status code: 409
Response message: Artifactory returned the following errors:
The target deployment path 'com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom'
does not match the POM's expected path prefix 'com/x/y/z/common/2.2.7'.
Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path. Status code: 409 …Run Code Online (Sandbox Code Playgroud) 我有一个Spring Security配置,我必须在其中使用加密属性。我有实用程序静态方法,PasswordUtil.decode()通过它我可以解码一个属性以供进一步使用。
以下解决方案有效,但特定的SpEL对我来说看起来很丑陋。所以,我的问题是:是否可以将给定的SpEL表达式重构为更好/更短/惯用的东西?
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("#{T(my.package.PasswordUtil).decode('${signkey.password}')}")
private String signKeyPassword;
}
Run Code Online (Sandbox Code Playgroud) 我在使用功能更新VIM中的信息时遇到了麻烦.我的代码如下:
map <F4> :call UpdateTitle()<cr>'s
"Update the latest modification time and filename
function UpdateTitle()
normal m'
execute '/# *Last modified:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M")@'
normal ''
normal mk
execute '/# *Filename:/s@:.*$@\=": ".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copyright." | echohl None
endfunction
Run Code Online (Sandbox Code Playgroud)
当我按下F4VIM时,它会工作.但它始终显示错误消息E20: Mark not set.我以为错误发生在最后两行.但我找不到解决方案.
我试过了echoerr.它有效,但不是我的意思.我试着echomsg和echo孤独.但它不起作用.没有消息输出.但是错误消息显示为E20: Mark not set.
此外,即使我删除整个回声线.同样的错误再次出现.
VIM版本是7.0.237.
在GitLab CI上使用并行 Gradle作业:
我收到以下随机 Gradle异常:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().
Run Code Online (Sandbox Code Playgroud)
我使用没有任何GitLab CIdocker缓存的执行器。我使用Docker卷,而Gradle缓存指向该卷:gitlab-runner
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().
Run Code Online (Sandbox Code Playgroud)
目录的访问权限没有问题/pipelines …
我kotlin application通过gradle init --dsl kotlin-> 将项目加载到intellij 中生成了一个骨架,并收到以下错误。附上截图。
Type mismatch : inferred type is kotlin.String but java.lang.String was expected.
我已经尝试了使缓存/重启无效的各种步骤。删除 .gradle、.idea、~/.gradle 等,刷新 gradle 项目,停止 gradle 守护进程。刷新 Intellij 项目(删除 ~/.intellijIDea../system 目录)。然而,没有一个有帮助。请告诉我我还能做什么?
正如我所说,我通过gradle init --dsl kotlin. gradle 版本 5.2.1,kotlin 插件版本 1.3.20。都是最新的。intellij idea 是 2018.3 版本。对于初学者,build.gradle.kts如下所示:
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
id("org.jetbrains.kotlin.jvm").version("1.3.20")
// Apply the application plugin to add support for building a CLI application. …Run Code Online (Sandbox Code Playgroud)