Rename set of files using some patterns in maven - maven

I need to rename set of files in maven without using Maven-Antrun-plugin in a single execution or command.
I have many property files with same suffix ab_bc.properties,de_bc.properties,etc and I need to replace the suffix to some other name like ab_BR.properties,de_BR.properties.
Is there any plugin available to do the same in Maven?
I tried Maven-assmbly plugin and copy-rename plugin but adding lot of files makes it more complex.

You can give this plugin a try or have a look on workarounds with the Maven Assembly plugin, see related question here.
Hope that helps :)

Related

How to download dependencies using Bazel?

I am new to Bazel. I need to download external dependency jar files using Bazel. Where to configure to download external jar files. I tried to add jar files in BUILD and WORKSPACE files , but not working.
Workspace file
maven_server(name="myserver",url="https://mvnrepository.com/artifact/org.apache.flink/flink-java")
maven_jar(name="flink-java",artifact="org.apache.flink:filnk-java:jar:1.2.0",server="myserver")
bind(name="flink-java",actual="#flink-java//jar")
Build file
java_binary(
name="read_files",
srcs = glob(["ReadFiles.java"]),
main_class="com.ibm.cdo.gts.contracts.pipeline.preprocess.ReadFiles",
deps=["//external:flink-java"],
)
The logical mistake you have there is that the workspace name (flink-java) is illegal see here and here. What is needed is to change the - to _ in maven_jar and of course the reference in the bind.
maven_jar(name="flink_java",artifact="org.apache.flink:flink-java:jar:1.2.0")
bind(name="flink-java",actual="#flink_java//jar")
Two more mistakes you had in the above were:
In the artifact coordinates you wrote filnk-java when you needed flink-java
The mvnrepository URL you used doesn't seem to be legal. I tried a few variants but couldn't get it to work. Additionally from the site they seem to link downloads to Maven Central itself so I'm not sure they server the jars. Having said that since Bazel fallbacks to Maven Central I just omitted the maven_server and the build passes. If you need help with the maven_server part and you need to use a private Maven repository please double check the URL first.
PS: It would have really helped if you added to your question the Bazel outputs since I needed to create my own workspace to know what were the problems you encountered.

Set permissions on tar created by maven assembly plugin

With the Maven assembly plugin I know I can set the permissions of the files contained within my tar such as here. However can I use the plugin to set the permissions of the tar itself?
Maybe I should just the ant plugin but this is a little messy
I haven't tested this, but you might be able to use "exec-maven-plugin" to do this.
How to change permission of jar packaged by maven? I am using maven assembly plugin
"Use maven:exec plugin to execute chmod"
So the idea is that you would add another plugin to the pom.xml file that sets the permission on the tar itself.
The only drawback that I see is that you have to have the name of the file in the plugin xml code in the pom file. That's fine as I have that listed in in the maven-assembly-plugin. But the file extension is found in assembly.xml (.zip, or .tar-gz), so if you change the file extension in assembly.xml, you would have to remember to change it in the pom.xml file. Not a big hassle, but it might be easy to miss on your first review.

Manipulating __artifactId__ during file generation by maven archetype

Building a Maven archetype where files are generated using _artifactId_. archetype.xml looks like:
<sources>
<source>src/main/java/__artifactId__.java</source>
<source>src/main/java/__artifactId__CommandExecutor.java</source>
<source>src/main/java/__artifactId__EventListener.java</source>
</sources>
Generating a project using this archetype can lead to Java file names that do not follow the naming convention such as sample-plugin.java and sample-pluginCommandExecutor.java.
How can I make sure _artifactId_ is converted to appropriate Java file name, such as SamplePlugin.java and SamplePluginCommandExecutor.java.
I'm not an archetype expert, in fact I just did it once but
faced with a very similar problem.
I was not able to find a way to customize file or directory names
in any way, I mean use one of the archetype parameters and transform
it.
So there are 2 kinds of solution I used
Add a new archetype parameter where you specify the class name
Use a standard Name (like ArtifactClass.java) and then create an maven profile (enabled if this file is present) with an ant script that changes the name (just remember inside your files you can use velocity to customize it)
Hope it helps
tonio

Configuring Maven to support creation of .exe installer

I am currently using Maven 3 and have a really simple .ism file for InstallShield 2012.
My pom.xml creates a .jar file which is the only file used by the .ism. I can do something like this:
C:>IsCmdBld.exe -p "c:\InstallShield Projects\Simple.ism" -r "COMP" -y "1.0"
This is of outside of my POM, but I would like to use the version info in the POM and other metadata to in the installer creation.
I'm aware no specific InstallShield plug-in does not exist for Maven, but I'm wondering if there is a way to get Maven to help out by calling the command block above, or something similar?
You could use the exec-maven-plugin and pass in the ${project.version} as part of your execution call.
Otherwise if there is an anttask for InstallShield you could use that with the antrun plugin.
While the question was asked way in the past, and I haven't had access to InstallShield for a year now, I did happen to work on a Maven plugin to introduce things that you want to achieve.
https://github.com/tptak/installshield-maven-plugin
I could continue work on this to some extent if I had a licence

Maven: Execute custom code during assembly

We are using the assembly plugin to build a zip package.
I would like to execute some custom java code during the execution of the Maven Assembly plugin. The java app should have access to the structure of the assembly but before the zip file is built. So, files which should go into the zip might possibly be modified/added/removed.
How would I configure that?
Cheers
Jonas
I do not think executing Java code is possible. Try getting along with exclusion patterns for file removal and maven filters for file modifications.
http://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html

Resources