小编use*_*070的帖子

配置子项目后执行Gradle任务

我有一个多项目 Gradle 构建,其中子项目被分配独立于根项目的版本号。我想将此版本号注入到每个子项目中的几个资源文件中。通常,我会通过为根构建中的每个子项目配置 processResources 任务来完成此操作。然而,问题是 Gradle 似乎在加载子项目的构建文件之前执行 processResources 任务,并注入“未指定”作为版本。

目前,我的项目如下所示:

/设置.gradle

include 'childA' // ... and many others
Run Code Online (Sandbox Code Playgroud)

/build.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'com.example.exampleplugin'
}

subprojects {
    // This has to be configured before processResources
    customPlugin {
        baseDir = "../common"
    }

    processResources {
        // PROBLEM: version is "unspecified" here
        inputs.property "version", project.version

        // Inject the version:
        from(sourceSets.main.resources.srcDirs) {
            include 'res1.txt', 'res2.txt', 'res3.txt'
            expand 'version':project.version
        }
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

/childA/build.gradle

version = "0.5.424"
Run Code Online (Sandbox Code Playgroud)

我考虑在root的开头添加evaluationDependsOnChildren()build.gradle,但这会导致错误,因为 …

gradle

9
推荐指数
3
解决办法
6446
查看次数

由于“分叉测试工具失败”,sbt 测试失败

我有一个 Scala 项目,我正在用sbt. 运行时sbt test,测试本身通过,但随后命令失败并显示“分叉测试工具失败:java.io.EOFException”。

build.sbt 文件未指定fork in Test.

运行后失败的错误示例sbt test

[info] Run completed in 5 seconds, 494 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[error] Error during tests:
[error]     Forked test harness failed: java.io.EOFException
[error]     at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2959)
[error]     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1539)
[error]     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
[error]     at sbt.React.react(ForkTests.scala:177)
[error]     at …
Run Code Online (Sandbox Code Playgroud)

scala sbt

7
推荐指数
1
解决办法
327
查看次数

为什么PHP允许在一种情况下将文字传递给pass-by-reference参数而不允许其他情况?

该函数array_shift()通过引用获取一个参数.传递数组文字会导致致命错误:

$ php -r'var_export(array_shift(array("Test#0"));'; echo

致命错误:在第1行的命令行代码中,只能通过引用传递变量

这按预期失败.但是,当使用call_user_func_array调用函数时,PHP表现得很奇怪:

<?php
var_export(call_user_func_array("array_shift", array(array("Test #1"))));
echo "\n";

$arg1 = array("Test #2");
var_export(call_user_func_array("array_shift", array($arg1)));
echo "\n";

$args = array(array("Test #3"));
var_export(call_user_func_array("array_shift", $args));
echo "\n";
Run Code Online (Sandbox Code Playgroud)

执行时:

$ php test.php

'测试#1'

警告:参数1到array_shift()应该是一个引用,在第6行的/Users/kcc/test.php中给出的值NULL

警告:参数1到array_shift()应该是一个引用,在第10行的/Users/kcc/test.php中给出的值NULL

可以理解的是call_user_func_array(),不会触发致命错误,但为什么第一种形式可以正常工作呢?

php pass-by-reference php-internals

5
推荐指数
1
解决办法
534
查看次数

为什么 Guice 在 main 中从 UncaughtExceptionHandler 抛出 $ComputationException?

我正在尝试运行一个使用 Guice 并启动 Netty HTTP 服务器的应用程序。这是使用Java 8。

但是,在启动时,我在控制台中看到此错误:

Exception: com.google.inject.internal.util.$ComputationException thrown from the UncaughtExceptionHandler in thread "main"
Run Code Online (Sandbox Code Playgroud)

没有堆栈跟踪,没有别的。

什么会导致这个错误?

java guice

3
推荐指数
1
解决办法
2587
查看次数

标签 统计

gradle ×1

guice ×1

java ×1

pass-by-reference ×1

php ×1

php-internals ×1

sbt ×1

scala ×1