Rename files inside War file using 7zip - 7zip

I am trying to rename a few property files inside a war file using 7zip.
I don't get an error but unfortunately it does not work.
The command I am using is:
call copy /Y ..\target\myApp.war temp\webapps\myApp-test.war call 7z rn temp\webapps\myApp-gate.war -ssc #gateRenameList.txt
And the gatewayRenameList contains:
`\WEB-INF\classes\application.properties
\WEB-INF\classes\application-ignore.properties
\WEB-INF\classes\application-alternate.properties
\WEB-INF\classes\application.properties'
I could use maven and profiles (or something else) but I thought this would be faster as I want 2 almost identical war files. As these files will be deployed to a special container it's not possible to change the active profiles (we don't have access)... but I need 2 almost identical war files to deploy to 2 separate URLs/contexts.
Anyway, I just want an answer about the 7zip rename.

Related

How to copy directories into WAR using Maven?

My goal is this: I have 2 directories (not their contents but the directories themselves) which I need to get copied into both the exploded WAR directory and the packaged WAR.
Specifically, I need the following directories inside the final WAR:
${project.basedir}/web/WEB-INF/templates needs to get copied into
target/${finalName}/WEB-INF/
${project.basedir}/web/WEB-INF/classes/dao needs to get copied to
target/${finalName}/WEB-INF/classes/
So far, I haven't found any way of doing it. I've tried the resources plugin, the war plugin's webResources feature, antrun, exec-maven-plugin, etc., and each have limitations that prevent the aforementioned directories from ending up in the final WAR. In some cases the resultant directory structure ended up with too much nesting (e.g.: target/${finalName}/WEB-INF/classes/WEB-INF/classes/); in other cases nothing got copied at all, presumably because the war plugin has its own beliefs about what should and should not get copied.
As such, I'm at my wit's end. Is there any way to copy actual directories without having the war plugin question my motives? I wish I could tell Maven, "Do as I say!"

How to generate diff between two folders on Windows using command line?

We use Jenkins to deploy application files. I need copy files in a folder to a remote server via FTP using command line on Windows.
Normally only a few files in the folder are updated, and I don't want to transfer all files every time.
Is there a tool that can compare two folders and generate a new folder containing updated or new files?
Thanks.

How do I properly add source files to a jar file, using the command line?

How do I add .java files to my jar?
My classes, in the bin/ folder, are like:
aaa/b/c/program.class and /aaa/b/c/d.class
So I add a/ to the jar and set the entry point to aaa.b.c.Program.
Then I can: java -jar foo.jar
and the program runs.
If I jar up the src/aaa/* and bin/aaa/* files, it isn't able to find aaa/b/c/Program.class - I tried several ways of specifying the entry point. It seem that the path must match the package+class name.
What's the proper way to make the jar file?
It won't let me add the java and class paths to the same folders easily.
If I go to the parent folder and add the files:
jar -cef x.jar aaa.b.c.Program -C src aaa -C bin aaa
I get : : : java.util.zip.ZipException: duplicate entry: aaa/
To get them in the same folders, I can do it in two steps:
jar -cef x.jar aaa.b.c.program -C bin aaa
jar -uf x.jar -C src aaa
Is this the proper way?
If there are docs, do I put them in the same folders, too?
I searched a bunch on the web and am not finding this,
even (especially?) in the lame Oracle docs...
(I tried to get Eclipse to do it- but it won't let me leave some classes out... But I really want to do this with the command line...)
Thanks
If you want to have the compiled classes and the sources in the same folders, then you have to use two steps, a jar cf step to create the file with one set of files, and a jar uf step to add the other set of files, as in your example.
But doing this is not recommended. The recommended practice is to separate the runnable, the sources and the docs, and use a dedicated jar file for each. As you're doing something unusual, it's no surprise that there's no easy way to do it (you need two steps).

ibm-application-bnd.xml overwritten

I work on an existing Maven project with Eclipse Luna and WebSphere 8.5.5.1.
The source of the ibm-application-bnd.xml is:
D:\projects\svn\application\ear\src\main\application\META-INF\ibm-application-bnd.xml
Once a day, at a random moment, the application folder itself is overwritten with the ear-file, so the \main folder contains a binary file named application and is actually the ear file because I openend the file because I saw it had the same size as the ear (8 MB).:
D:\projects\svn\application\ear\src\main\application
The happens at least once a day, and I have the impression that Eclipse, or JRebel of WebSphere creates this file.
The result is that I have to quit Eclipse, delete the file and update from SVN to get the application folder with the binding xml back.
Any thought how to fix this?
Easy way you could stop the folder from being deleted (and perhaps also find the culprit) is to open command prompt in that directory - it won't allow the folder to be removed in that case.

How to remove entire directory from RootDirectory in ZIP extension

I have a build that needs to zip a website project. I am using TfsBuildExtensions.Activities.Compression.Zip to do this.
Unfortunately, it puts the deployed files into ..\_PublishedWebsites\ProjectName\.
So, I have tried to play around with the RemoveRoot property, in the ZIP extension.
If I use the following value:
(New DirectoryInfo(BinariesDirectory & "\_PublishedWebsites")).FullName my zip file contains the ProjectName folder and it then contains the website. Working as intended.
If I use the following value:
(New DirectoryInfo(BinariesDirectory & "\_PublishedWebsites")).GetDirectories().FirstOrDefault().FullName my zip file contains the ENTIRE folder structure, from C:\Builds\... This is definitely not what I expected.
All I want, is that instead of having a folder in my zip, I want the deployed files directly in the zip files root.
How do I do this?
Web Deploy should be your first choice for packaging web sites.
It has a built-in option for zipping the artifacts so you don't need any third-party libraries for this.

Resources