for some reasons I don't use the java plugin for gradle, but I invoke ant.javacdynamically. How can I build a dynamic javac include() based on a list ?
for example:
def srcToCompile=["**/File1.java","**/File2.java","**/FileN.java"];
(...)
ant.javac(
destdir: tmpDir,
srcdir: srcDir
includeantruntime:false,
failonerror: true,
fork: true,
classpath : classpath1,
debug: true
) {
include(name: srcToCompile) //<< DOESN'T WORK, I also tested srcToCompile.join(":")
}
thanks.
EDIT: by 'doesn't work', I mean ant.javac doesn't interpret a List or a colon-separated-string: no source is found and nothing is compiled. ant.javac expects something like
include(name:"**/File1.java")
include(name:"**/File2.java")
include(name:"**/FileN.java")
but I want to generate this list of include when gradle is invoked.
If you look an ant javac docs you'll see that includes and include both accept a string but you are trying to pass a collection
Eg:
<javac destdir="${build}"
classpath="xyz.jar"
debug="on">
<src path="${src}"/>
<src path="${src2}"/>
<include name="mypackage/p1/**"/>
<include name="mypackage/p2/**"/>
<exclude name="mypackage/p1/testpackage/**"/>
</javac>
and
<javac srcdir="${src}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
debug="on"/>
In Gradle this would be
ant.javac(includes: srcToCompile.join(','), ...)
or
ant.javac(
...
) {
srcToCompile.each {
include(name: it)
}
}
Related
I am trying to get my test results visible in Jira using Allure 2.13.8. The test results are visible but are not displayed as links back to the report, so called backlinks.
Here is my situation.
When I generate an Allure report with maven using allure-maven:
mvn clean test allure:report
an executor.json is created with maven build info inside allure-results dir.
environment {
ALLURE_JIRA_LAUNCH_ISSUES = 'xxx-9'
ALLURE_JIRA_ENABLED = 'true'
ALLURE_JIRA_ENDPOINT = 'http://localhost:8080/rest/'
ALLURE_JIRA_USERNAME = 'xxx'
ALLURE_JIRA_PASSWORD = 'xxxx'
}
stage('Test Execution') {
steps {
withMaven(options: [artifactsPublisher(disabled: true)],
maven: 'MAVEN_HOME') {
sh "mvn clean test -Dtest=ApplyForCreditCardTestsDE,_FailedTests* -Denv=qa-de"
}
}
}
The above env variables trigger the jira-plugin within Allure to export test results and launch to Jira. This works, but this executor.json do not contain links needed to create these backlinks. Just some limited info such as project name, that's it.
When I generate an Allure report with Jenkins Allure plugin:
stage('Generate Test Report') {
steps {
script {
allure([
includeProperties: true,
jdk: '',
properties: [
[key: 'ALLURE_JIRA_LAUNCH_ISSUES',value: 'xxx-9'],
[key: 'ALLURE_JIRA_ENABLED',value: 'true'],
[key: 'ALLURE_JIRA_ENDPOINT',value: 'http://localhost:8080/rest/'],
[key: 'ALLURE_JIRA_USERNAME',value: 'xxx'],
[key: 'ALLURE_JIRA_PASSWORD',value: 'xxxx']
],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'target/allure-results']]
])
}
}
}
an executor.json is created with jenkins build info inside allure-results dir.
{"buildName":"test #35","buildOrder":"35","reportName":"AllureReport","name":"Jenkins","buildUrl":"http://localhost:8085/job/test/35/","reportUrl":"http://localhost:8085/job/test/35/allure","type":"jenkins","url":"http://localhost:8085/"}
This is what I need to be pushed to Jira.
For some reason I cannot figure out how the jira-plugin can be triggered from this plugin? Or do I need to use Allure Command Line Interface to do this? I'm lost.
If you can help me out that would be much appreciated.
I try to delete directory in 'foo/dir' with name 'public-someHash'. 'SomeHash' was created dynamically (eg 'dsflsdfn') and always new. I tried to use 'fileTree' but directory still present. There is my code:
tasks.create(name: 'delete', type : Delete) {
delete fileTree(dir: 'foo/dir/', include: 'public-*/**')
}
What is wrong with my mask?
UDP: I have similar task in Ant and all works fine:
<target name="delete">
<delete includeemptydirs="true">
<fileset dir="foo/dir/">
<include name="public-*/**"/>
</fileset>
</delete>
</target>
EDIT: Apologies, as original answer was based on a misreading of the question.
Here's one way to do it, but not the most elegant:
task myDelete(type: Delete) {
def files = new HashSet()
new File('foo/dir').eachFile { file ->
if (file.isDirectory() && (file.name ==~ /public-.*/)) {
files << file
}
}
delete files
}
I'm used to working with Makefiles but my current project uses .qbs files. How do I run a simple terminal command through qbs without creating or requiring files? Similar to a phony rule in make.
The following works and shows "awesome" in my terminal.
import qbs 1.0
Project {
name: "cli"
Product {
name: "helloworld"
type: "application"
files: "TEST.c"
Depends { name: "cpp" }
}
Product {
type: ["custom-image"]
Depends { name: "helloworld" }
Rule {
inputsFromDependencies: ["application"]
Artifact {
fileTags: ["custom-image"]
}
prepare: {
var cmd = new Command("echo", "awesome")
return cmd
}
}
}
}
However I have to touch my dummy TEST.c file before each run. Without the helloworld dependency the Rule does not run.
Any ideas? Thank you very much!
It's buried in the documentation in a very non obvious place and further obscured by Command (which is not the correct way, lol). I've had your problem too.
What you need is this:
http://doc.qt.io/qbs/jsextension-process.html
I'm not sure what your end goal is but you could use Transformer{} instead of a Rule{}. The biggest difference between a Rule{} and a Transformer{} is you don't need any inputs for the Transformer{} to run.
Also see Transformer.alwaysRun property.
https://doc.qt.io/qbs/transformer-item.html
I have defined two system properties in gradle.properties:
systemProp.buildDir=build
systemProp.cfgDir=build\\cfg
And I have the following task defined in build.gradle:
task clean(group:'clean',description:'clean the project') << {
ant.sequential {
delete(dir: System.properties.buildDir)
mkdir(dir: System.properties.buildDir)
delete(dir: System.properties.cfgDir)
mkdir(dir: System.properties.cfgDir)
}
}
This generates the following error:
Execution failed for task ':clean'.
> Cannot convert the provided notation to a File or URI: {dir=build}.
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
But this equivalent block of code does not generate any error and works as expected:
task clean(group:'clean',description:'clean the project') << {
ant.delete(dir: System.properties.buildDir)
ant.mkdir(dir: System.properties.buildDir)
ant.delete(dir: System.properties.cfgDir)
ant.mkdir(dir: System.properties.cfgDir)
}
Is the error on the first syntax a bug in gradle, or am I missing something?
This error is caused by the fact that your Gradle build script delegates to an instance of the Project interface, which also has a method called delete, whose argument is evaluated by Project.file(). If you want to use the Ant task you'll have to qualify it with the ant prefix.
I'm trying to get this Grunt plugin to work:
https://npmjs.org/package/dss
This documentation plugin ironically seems to be lacking proper documentation. Can someone help me out by giving me an example of something that worked for them. The main thing that's screwing me up is the "your_target" property. Not sure what's suppose to go in there.
Say I have a SASS file in the following path from the root directory:
sass/main.scss
What would my ouput be by default? And where would it output to? Also what format does it ouput to?
grunt.initConfig({
DSS: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Is "your_target" property the path to my sass file or the path to the documentation file I'm trying to create? Would it be defined like this?
...
your_target: {
// Target-specific file lists and/or options go here.
sass: "sass/main.scss"
},
...
I don't know what the property name should be. :(
dss: {
docs: {
options: {
},
files: {
'api/': 'css/**/*.{css,scss,sass,less,styl}'
}
}
}