How to modify application.conf during dist creation in Play Framework 2.3.x - jenkins

We use Jenkins to run builds for Play Framework 2.3.x project. This works fine and it creates a nice distribution packed in a zip file.
I would like that during the build to update one of the files in conf directory (for instance application.conf) and set the Jenkins build number/id in a variable so that I can always track the distribution file to the originating build.
I know it is possible to copy files to the distribution using "mappings in Universal" but I want to modify an existing file instead. This way I could then easily display the information on a page.

You could use the plain old Ant. With the Unzip Task you can unzip the created zip file. Then you can use the Replace Task to replace a string in your application.conf. And at least the Zip Task to package your project again.
For a more Scala-ish way you could use SBT Editsource.

Related

Can JENKINS create build by excluding particular files?

I am actually trying to ignore a particular file to be included in the build. Actually it is a thumb.db file which is automatically created whenever images are encountered in a folder. My solution contains the image folder. So basically, whenever the build is triggered from JENKINS, it will create the thumb.db file.
Is there any way, I can ignore the Thumb.db file from getting created via JENKINS?
I can switch off the thumb.db file from creation by switching it off from my windows, but I have to do it every time a build is created from JENKINS. So I want to ignore the thumb.db file from creation.
Below is the Job creation flow in my JENKINS from my current project:
SCM
I have used the Team Foundation Server Plugin and have mentioned my SERVER URL and PROJECT PATH
POST BUILD steps simply create the build to the staging location(folder Location)
Any help is appreciated.
Thanks,
AFAIK, on windows you can turn it off or on for the whole system and not for particular folders.
So you have to choose. On or off.
If you still want to keep it on, you'l have to handle this in your Jenkins build scripts. Remove any thumbs.db files after build is done.
If your output is an archive, make sure to exclude thumbs.db from it. All archives support an exclude flag.
I hope this helps.

Create war without manifest

I need to create a war file through ant build without a manifest file. I want the war to me created without the manifest file.
I am using tag in build.xml to create the war.
you can use <zip/> task with .war extension for destfile attribute to achieve the same result as the <war/> task (without manifest.mf).
<zip destfile="..\...\WarFile.war"basedir="..\basedir" update="true"/>
in case WarFile.war already exists, although you've written I need to create a war file , the attribute update="true" will be of use (by only updating and not overwriting the file).
All a war file is is a zip file in a specific format. That is libraries go in a particular place, class files go elsewhere, etc. The <war> task has sub-entities like <classes/> and <lib> that make configuring a war file correctly without knowing exactly where everything has to go.
However, you can correctly format the war yourself, and use <zip/>.
Why don't you want a manifest file? A manifest, if you don't specify anything, will contain nothing but the Java version used for the build, and the Ant version and won't affect the execution of your war at all.
What you can do is put useful information into the manifest. For example, we use Jenkins for our builds, and we put in the Jenkins project name and the build number which helps us understand what was included in the war.
There's no reason not to use a manifest file. And, a manifest file can contain useful information (which is accessible to the Java program too).

Msdeploy: Getting a list of files affected by checksum comparison

I have a custom .proj file in a large web project that calling msdeploy with -useChecksum option to update only modified files in my staging environment and it works fine. But I can't use msdeploy on my production environment, so, I need to make a .zip package to another team with the modified files to a manual deployment in that ambient.
My question is: can I get a list of files modified by msdeploy in your deployment process? With this I can automatically make a .zip with the same structure and files that has been modified in a build...
Some advices?
For second part , i suggest you to use InvokeProcess activity and call Zip Tool in order to compress.
this custom activity must be integrated to your build definition (Workflow)

Blackberry 5.0 - Add reference to a Java Library Project

It seems to me that what I'm trying to achieve is incredibly simple, yet is becoming incredibly painful.
I have ProjectA which is a BlackBerry Application project. I have ProjectB which is a Java library project. I want to refer to ProjectB from ProjectA. I can add a reference but when I run ProjectA, it doesn't work. I have source code for both the projects and both are compiled using Java compiler 1.4
I have tried multiple things but everything fails for some reason:
1. pre-verify.exe on ProjectB
It fails with an error "JAR file creation failed with error -1" I can see that the cod and jar files have been created but when add the jar file to ProjectA and run it, it doesn't work. Not sure if I need to add the .cod file.
2. Create new BlackBerry Library Project and reference it in ProjectA
I create a new project ProjectC and then add the jar of ProjectB to it. Then I add a reference to ProjectC in ProjectA. But I cant import classes from ProjectB
Pls suggest a way out.
I'm using Eclipse Plug-in and relying on Eclipse's build capabilities
Figured out answer myself. Publishing here in case someone stumbles upon this. Here are the steps:
Create your library and export as JAR (or download the 3rd party JAR)
Run preverify.exe on the JAR
preverify.exe -verbose -classpath "C:/Program Files/Research In Motion/BlackBerry JDE 5.0.0/lib/net_rim_api.jar" jarname.jar
If you are lucky, you won't run into any issues and you will be done. But I wasn't lucky enough. I got the below error
Error: No such file or directory. JAR file creation failed with error -1
There are two possible causes of this:
jar.exe is not added to your PATH. If so, add it (found in your JAVA
installation directory) to PATH
cvfm or -cfm option on jar.exe fails to execute. I'm not aware of the reason but the way to fix this is to use -cf option, point to the .class files but don't use the manifest file. here is an
example:
"C:\Program Files\Java\jdk1.6.0_26\bin\jar.exe" -cf "output\json-1.0.jar" tmp12996/
tmp12996 contains the preverified .class files.
You may run into different issues other than the one I've listed above.
Once jar is created from above step, make sure that it's structure is as you anticipate. One way to check is to rename the .jar to .zip, unzip it and then check it. If it is not as you need, you can change the structure and then repack it (I wouldn't do any major changes though)
Then add this newly built jar to your BlackBerry application as a reference i.e. add to Java Build Path in your eclipse and Check it in Order and Export window.
That's it! You are good to go! Run you app!
You may face error indicating that the module contains verification errors when you try to run in the simulator. One possible cause of this issue is that your library (the original JAR) contains APIs that are not compatible with J2ME or BB JRE. You may not get a compiler error when you build your library independently as it is compiled against Java 1.4 (or whatever your version is). Best to figure the issue out is to move all your code into your BB App project and then build it. That will tell you all the issues upfront. You make the changes as required and then move the code back to the library. If you don't have source code for the library you are using (like a 3rd party library), you may be out of luck! Also remember that there could be other issues than what I've hit upon and solved.
I'm documenting this at length as it has taken an awful amount of time for me to figure all this out; and to say the least, was most frustrating!
I found another solution. If you get error -1 while preverifying your JAR file, just run your library application once. Because if you don't run the application, the deliverables folder will be empty. Make sure this folder is not empty.

ANT job to invoke JDeveloper to create EAR file with specified deploy file

I was asked about the possibility of creating an ANT script that could be use to copy property files (associated to target environment), create an EAR file (perhaps using JDeveloper deploy file), and deploy that EAR file to target OC4J container.
I am asking if anyone ever successfully invoking JDeveloper automatically to create the EAR file by using specified 'deploy' file by using ANT? OR is it possible to by pass invoking JDeveloper at all. Is there any sample ANT code snippet to do so, or any information/hint that could be useful.
Thanks.
If you use ADF Business Components (BC) then you must use ojdeploy. Otherwise your BC will not get validated and your deployment will fail.
ojdeploy requires JDeveloper installation (ouch!) and will produce an EAR based on JDeveloper's deployment profiles .
(Although it's an old thread, I added something cos you never know.)
I would advise against using JDevelopers for creating an EAR file because I strongly believe that a build process must be autosufficient (i.e. as few external dependencies as possible).
Using Ant, you can simply use the Ear task (remember that the Ear task is a subtask of the Zip task, i.e. you can also use zipfileset inside the ear task).
I've never used OC4J but usually the deployment of an EAR file is just a matter of copying the file into the right directory (so a simple copy task would suffice).
Check out the ojdeploy command in the jdev\bin directory it will let you use JDeveloper's depoyment profiles from a command line.
I found that all the ant tasks used by jDeveloper are in the (default) directory: C:\Oracle\Middleware\jdeveloper\bin
I believe you can copy them to a build server and use them directly
They are the files it uses when you right click and select Deploy from the interface
You can build your own JDeveloper Deployment Profile Interpreter program and generate a Ant file from the Deployment Profile. I have done it before. Tim

Resources