Hello,
An ant task needs system properties to be set. I would like to learn how to do it. No matter what I tried all failed with: Cannot get property ‘value’ on null object See my latest try in the code.
Thanks!
task schemaTool << {
def props = new Properties();
File f = new File(sourceSets.main.output.resourcesDir, "pg-nucleus.properties")
f.withInputStream { props.load(it) }
println "Loaded " + props.size() + " local properties"
ant.taskdef(name: 'schematool',
classname: 'org.datanucleus.store.schema.SchemaToolTask',
classpath: configurations.jdo.asPath,
)
ant.schematool(dir: sourceSets.main.output.resourcesDir, verbose: 'true', mode: 'create', failonerror: 'true') {
classpath {
pathelement(location: sourceSets.main.output.classesDir.getPath())
pathelement(path: configurations.jdo.asPath)
}
fileset(dir: sourceSets.main.output.resourcesDir) {
include(name: '**/*.jdo')
include(name: '**/*.orm')
}
props.each(
ant.properties[it.key] = it.value
)
}
}
The original task (excerpt):
<taskdef name="schematool" classname="org.datanucleus.store.schema.SchemaToolTask" />
<schematool failonerror="true" verbose="true" mode="create">
<classpath>
<path refid="schematool.classpath"/>
</classpath>
<fileset dir="${classes.dir}">
<include name="**/*.jdo"/>
</fileset>
<sysproperty key="datanucleus.ConnectionDriverName"
value="${datanucleus.ConnectionDriverName}"/>
..