I'm using the groovy ant task to compile my groovy files, but it seems like groovy locks the jar file so it can't be moved, deleted, signed, etc. Has anyone run into this bug before and have a workaround? Seems weird that if I run the groovy ant task and compile to a jar file that groovy doesn't release that jar file.
thanks,
Jeff
Does the file get released once the ant build is complete? If this is the case try setting fork="true" on the groovy task so that another JVM is created, rather than Groovy sharing Ant's JVM. This means once Groovy is complete the forked JVM will be disposed and the lock should be freed.
If the lock persists after the Ant build completes, could you provide a bit more detail on what you're doing with Groovy?
Related
Documentation for the Groovy Plugin of Jenkins states that
The system groovy script, OTOH, runs inside the Jenkins master's JVM.
Thus it will have access to all the internal objects of Jenkins, so
you can use this to alter the state of Jenkins. It is similar to the
Jenkins Script Console functionality.
Yet I find that I have a groovy script that I can successfully run in Jenkins Script Console but which does NOT run if entered as a "System Groovy Script" on a build configuration. There are compiler errors. Clearly, the Jenkins Script Console is running with a different classpath than the script in my build. But I can't find information on what the default classpath is when running a script for a build or what the classpath is when running from the Script Console, so I might duplicate that for my script.
Also, the plugin offers a classpath entry field for running the script as a file but that option does not exist for entering the script as text.
I can't get my script to work either way.
What am I missing?
I think the answer is that the Script Console auto-imports the whole Jenkins library. That is not the case with the System Groovy Script. So what worked for me was to run the script, and for every compiler error about an unknown class, add an import statement for that class. I learned what packages they were from by looking at Javadocs.
Automating this would be a nice improvement to the plugin.
May be use the grab dependency management to resolve the library to add
I am invoking a windows batch command from Jenkins, after i get the latest version of my project from SVN. the windows batch command just performs certain file copying, after the all the files are retrieved from SVN and runs an ANT build. In the ANT build process, i am generating a JSP file where i have tried to capture the in the following fashion.
%BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION%
Unfortunately none of this information is understood by the build process and it just writes %BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION% into the file.
Could you please let me know if there is a way to capture these information into a file in the way i am trying to do? if not, could you direct me on how these information could be captured into a JSP file during the process that we are following?
BUILD_TAG, SVN_REVISION, etc are all environment variables that are present during a Jenkins build, and to use them in Ant, you would use them as any other environment variable from Ant
First, add a line:
<property environment="env"/>
Then you can reference any environment variable with this prefix, like:
${env.VAR_NAME}
So in your case, you'd do:
${env.BUILD_TAG}-${env.BUILD_NUMBER}-${env.BUILD_ID}-${env.SVN_REVISION}
I have this Java project there I import an Ant build.xml file with some tasks, like this:
ant.importBuild 'build.xml'
task myTaskA(dependsOn: ':Modules:MyModule:assemble') << {
// do stuff here...
}
compileJava.dependsOn(myTaskA)
configure(jar) {
include 'classes.dex'
}
jar.dependsOn(antCompile)
The task antCompile comes from the Ant build.xml script. However, for some reason, this task is being called at start up when invoke gradlew assemble, it doesn't even wait for the jar task to start.
Also, the antCompile task is defined as the following target in build.xml:
<target name="antCompile" depends="-setup">
</target>
That Ant target, -compile is always the first task to be executed when I invoke gradlew assemble. This doesn't make any sense. That task is never invoked anywhere, it's only a dependency of antCompile. Why is it being executed?
This is, obviously, not what I want... How can I prevent such behaviors?
Seems to work as expected. The build script makes jar depend on antCompile, which according to your words depends on -compile. assemble depends on jar, so executing gradle assembmle should run -compile first.
In any case, it should be said that ant.importBuild has known limitations, and can result in differences in behavior compared to running the Ant build directly. Also you'll lose many of Gradle's advantages when not describing the build in terms of Gradle's own abstractions. Therefore I recommend to port the build to Gradle, rather than using ant.importBuild (which isn't used that often in the real world). Note that it's perfectly fine to reuse Ant tasks in cases where Gradle doesn't provide any equivalent.
I need to fork a new process for a specific ant task. I dont see a fork attribute in the taskdef how do I do it ?
I should be clearer, I am not talking about executing ANT in a forked process:
I have an ant task X, which I need to run in a forked process. Its some third party task which i use with taskdef X and then use this way
Is there anyway to tell any that anytime i use that task please fork the process and run ?
See Running Ant via Java in the Ant manual.
I have multiple JavaFX 2.0 apps (built with the default ant scripts generated by netbeans 7.0) which I want to be wrapped up into a war by a maven pom in the parent directory.
The war-building pom has lots of ant tasks in the compile phase that look like this:
<ant antfile="FXapplication1/build.xml" target="jar"/>
But when I go to run 'mvn compile', I get this error from ant:
"C:\path\to\warbuilder\FXapplication1\nbproject\build-impl.xml:209: Must set src.dir"
The ant script builds fine when explicitly called inside its own directory, so I'm assuming that the problem is that it's looking in the war builder's local directory for its source files, rather than looking for them relative to the build.xml. Is there a way to specify a working path for a given ant task?
Try making the JavaFX apps modules of the warbuilder app, each with their own pom which executes <ant antfile="build.xml" target="jar"/>,
rather than running <ant antfile="FXapplication1/build.xml" target="jar"/> from the parent.
The parent should list the children as modules, they will then be executed as part of the parent build process.