在自定义gradle插件中,project.version似乎总是如此unspecified.为什么以及如何project.version在自定义插件(类)中检索?
例如:
apply plugin: 'java'
apply plugin: MyPlugin
version = "1.0.0"
println "In build file: $project.version"
class MyPlugin implements Plugin<Project> {
public void apply(Project project) {
project.task('myTask') {
println "In plugin: $project.version"
}
}
}
Run Code Online (Sandbox Code Playgroud)
打印出来:
%> gradle -q myTask
In plugin: unspecified
In build file: 1.0.0
Run Code Online (Sandbox Code Playgroud)
除了我真的想知道为什么?
有没有办法让JAXB为已定义的元素生成集合集而不是列表?
例如,为此xsd生成一套书籍:
<xs:element name="Collection">
<xs:complexType>
<xs:sequence>
<xs:element name ="books">
<xs:complexType>
<xs:sequence>
<xs:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
Run Code Online (Sandbox Code Playgroud)
使用以下bindings.xml时
<jxb:bindings schemaLocation="schema.xsd">
<jxb:bindings node="//xs:element[@name='Shop']/xs:complexType/xs:sequence/xs:element[@name='books']">
<jxb:property collectionType="java.util.HashSet" />
</jxb:bindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)
生成具有混凝土HashSet实现的书籍列表:
List<Book> books = new HashSet<Book>();
Run Code Online (Sandbox Code Playgroud) 以下测试应该通过,但事实并非如此
class EngineTest extends FunSuite {
test("engine should not be null") {
val manager: ScriptEngineManager = new ScriptEngineManager
val engine: ScriptEngine = manager.getEngineByName("nashorn")
assert(engine != null)
}
}
Run Code Online (Sandbox Code Playgroud)
在manager.getEngineFactories()似乎是空的.为什么?如何初始化上下文?