我在Centos 7终端中使用了gradle build命令,得到了输出:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type InitScriptHandler using BuildScopeServices.createInitScriptHandler().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run Code Online (Sandbox Code Playgroud) 如何将travis-ci env变量用作Gradle的属性?
我在gradle路径下本地拥有gradle.properties:
sonatypeRepo = abcd
Run Code Online (Sandbox Code Playgroud)
我用的是build.gradle:
uploadArchives {
//more
repository(url: sonatypeRepo) {
// more
}
//more
}
Run Code Online (Sandbox Code Playgroud)
当然它在当地有效.在travis我已经在设置下添加了变量,所以我看到了构建日志:
Setting environment variables from repository settings
$ export sonatypeRepo=[secure]
Run Code Online (Sandbox Code Playgroud)
它失败了:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/Diolor/Swipecards/library/build.gradle' line: 49
* What went wrong:
A problem occurred evaluating project ':library'.
> No such property: sonatypeRepo for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
Run Code Online (Sandbox Code Playgroud)
如何将Travis的env变量用作Grable属性,还可以使用本地构建?
在Terraform中,我正在尝试创建一个包含带有可变键的地图的模块.我不确定这是否可行,但我尝试了以下但没有成功.
resource "aws_instance" "web" {
ami = "${var.base_ami}"
availability_zone = "${var.region_a}"
instance_type = "${var.ec2_instance_size}"
security_groups = ["sec1"]
count = "${var.ec2_instance_count}"
tags {
Name = "${var.role} ${var_env}"
role = "${var.app_role}"
${var.app_role} = "${var_env}"
}
}
Run Code Online (Sandbox Code Playgroud)
还有这个:
tags {
Name = "${var.role} ${var_env}"
}
tags."${var.role}" = "${var.env}"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?Terraform目前无法做到这一点吗?
我正在将Gradle构建脚本从Groovy迁移到Kotlin DSL,其中没有真正记录的事情之一是如何填充额外的属性。
在Groovy 中,我可以写:
ext {
comp = 'node_exporter'
compVersion = '0.16.0'
compProject = 'prometheus'
arch = 'linux-amd64'
tarball = "v${compVersion}/${comp}-${compVersion}.${arch}.tar.gz"
downloadSrc = "https://github.com/${compProject}/${comp}/releases/download/${tarball}"
unzipDir = "${comp}-${compVersion}.${arch}"
}
Run Code Online (Sandbox Code Playgroud)
我发现在Kotlin DSL 中,我可以通过以下方式实现相同的功能:
val comp by extra { "filebeat" }
val compVersion by extra { "6.4.0" }
val arch by extra { "linux-x86_64" }
val tarball by extra { "${comp}-${compVersion}-${arch}.tar.gz" }
val downloadSrc by extra { "https://artifacts.elastic.co/downloads/beats/${comp}/${tarball}" }
val unzipDir …Run Code Online (Sandbox Code Playgroud) 我想使用通配符复制目录,但fromGradle copy任务的方法不接受通配符.
// this doesn't work
task copyDirectory(type: Copy) {
from "/path/to/folder-*/"
into "/target"
}
// this does
task copyDirectory(type: Copy) {
from "/path/to/folder-1.0/"
into "/target"
}
Run Code Online (Sandbox Code Playgroud) 使用 Rust 1.11 和 Cargo 1.12(每晚),我试图创建一个[workspace]包含一些库和一些可执行文件的。
在我的根文件夹中,我添加了我的子板条箱:
cargo new loader
cargo new shell --bin
Run Code Online (Sandbox Code Playgroud)
然后我将cargo.toml下面显示的内容添加到我的根文件夹中。
cargo new loader
cargo new shell --bin
Run Code Online (Sandbox Code Playgroud)
cargo build在我的根文件夹中运行会产生:
Run Code Online (Sandbox Code Playgroud)[package] name = "rustenv" version = "0.1.0" authors = ["ME"] [workspace] members = [ "loader" , "shell" ]
[workspace]鉴于我本质上是 Visual Studio 用户,我对此功能应该如何工作感到有些困惑,在那里,我可以简单地将项目添加到工作区。看来我还需要与 Cargo 做一些其他事情才能获得相同的效果。
我想编写JUnit 5参数化测试,它将字符串数组(String[])作为参数:
@ParameterizedTest
@MethodSource("stringArrayProvider")
void parseFirstAndSecondInt(String[] args) {
Arguments arguments = new Arguments(args);
assertEquals(1, arguments.getFirst());
assertEquals(2, arguments.getSecond());
}
Run Code Online (Sandbox Code Playgroud)
我不确定,如何提供字符串数组的集合/流/迭代器.我没有成功尝试使用@MethodSource注释方法
static Stream<String[]> stringArrayProvider() {
return Stream.of(
new String[]{"1", "2"},
new String[]{"1", "2", "3"});
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个例外:
org.junit.jupiter.params.converter.ArgumentConversionException:
No implicit conversion to convert object of type java.lang.String to type [Ljava.lang.String;
Run Code Online (Sandbox Code Playgroud)
有这种参数化测试的好设计/解决方案是什么?
以下是我的 AWS terraform 项目的文件夹结构:
c:\terraform
??modules
? ??ec2-fullstacks
? ??main.tf
? ??variables.tf
??qa
??testappapi
??testappapi_backend.tfvars
??main.tf
??terraform.tfvars
Run Code Online (Sandbox Code Playgroud)
在模块下:
内容c:\terraform\modules\ec2-fullstacks\main.tf:
c:\terraform
??modules
? ??ec2-fullstacks
? ??main.tf
? ??variables.tf
??qa
??testappapi
??testappapi_backend.tfvars
??main.tf
??terraform.tfvars
Run Code Online (Sandbox Code Playgroud)
的c:\terraform\modules\ec2-fullstacks\variables.tf内容:
provider "aws" {
}
terraform {
backend "s3" {
encrypt = true
}
}
data "aws_ami" "ami" {
most_recent = true
filter {
name = "name"
values = ["${var.ec2_ami_name}*"]
}
}
output "ami_id" {
value = "${data.aws_ami.ami.id}"
}
Run Code Online (Sandbox Code Playgroud)
在项目(testappapi)下:
内容C:\terraform\qa\testappapi\main.tf:
variable …Run Code Online (Sandbox Code Playgroud) 我正在使用 Gradle 版本 4.10.3(需要 Android 支持),并尝试将测试预编译脚本放入我的buildSrc文件夹中,以便与项目中的各种模块一起使用。这是我的基本代码设置:
//maven-deploy.gradle.kts, a custom precompiled plugin under
// buildSrc\src\main\kotlin\maven-deploy.gradle.kts
plugins {
maven
signing
}
//a test task
tasks {
register("hello") {
doLast {
println("hello")
}
}
}
//buildSrc build.gradle.kts
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
repositories {
jcenter()
}
//main project root's build.gradle.kts
plugins {
base
kotlin("jvm") version Vof.kotlin apply false
kotlin("android") version Vof.kotlin apply false
kotlin("android.extensions") version Vof.kotlin apply false
id("kotlinx-serialization") version Vof.kotlin apply false
id("maven-deploy")
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error:Plugin [id: 'maven-deploy'] was not …Run Code Online (Sandbox Code Playgroud) 我正在使用 swagger-codegen-maven-plugin (2.2.1) 从 YML 配置生成 java 和 typescript 代码类文件。我有两个问题。
如何在 YML 中定义枚举属性数组?
如何在 YML 中将地图属性枚举定义为键,将布尔值定义为值?
让我知道这可能还是有任何解决方法?目前,我在 java 和 typescrtipt 中定义了枚举类并将其作为字符串传递。谢谢。
DataInfo:
type: object
properties:
enumTest: -- works fine
type: string
enum:
- one
- two
enumTestArray: --failing to generate code
type: array
items:
type: string
enum:
- one
-two
testMap: -- works fines generate Map<String, Boolean> and { [key: string]: boolean; };
type: object
additionalProperties:
type: boolean
Run Code Online (Sandbox Code Playgroud)
更新:
与第一个问题相关:定义枚举属性数组。swagger-codegen-maven-plugin 生成无效的 java 类文件,如下所示: 生成 <、> 和 " 字符的外观和问题。 …
gradle ×5
terraform ×2
api ×1
java ×1
junit ×1
junit5 ×1
kotlin ×1
module ×1
parameters ×1
rest ×1
rust ×1
rust-cargo ×1
sonatype ×1
swagger-2.0 ×1
travis-ci ×1
unit-testing ×1
variables ×1
yaml ×1