Maven Archetype and no extension files - maven

When creating a maven archetype with "mvn archetype:create-from-project -Darchetype.properties=", all files without extensions are ignored (Like Dockerfile for ex). How to keep these files ?
Maven version: 3.5.2

Related

Suppress maven dependency version suffix in local repository

I have a Spring Boot project that uses SAP Crystal Reports. CR is not published in Maven Central. I imported all of the CR jar files into my Maven local repository. In my projects the jars have the version appended to the jar file name. For one jar file, this causes a runtime error. How can I have that jar not have the appended Maven version?
if you build from source using Maven then you can override the artifact final name in the POM of this project
<finalName>myJar</finalName>
If you run the mvn install manually then you have control of what you store into the Maven repository
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
This is my workaround hack.
The Jar is question is never directly referenced by my project code, it is a runtime library of the Crystal Reports java runtime. I do not need it in the classpath at build time, just in the deployed file built by maven.
My Spring Boot project is deployed as a WAR file so I need to structure my Eclipse Maven project so that the Jar is placed in WEB-INF/lib as a plain web app resource. I do not specify the jar as a maven dependency.
It's a hack because the jar file IS a dependency and SHOULD be specified as a maven project dependency in the pom.xml.
This solves my immediate problem.
I blame SAP for not considering Maven for their Crystal Reports Java runtime.

M2E in VsCode (or terminal) as Apache Maven Eclipse Plugin has retired

I have to update .classpath, .project and .settings for a Maven project in VS Code. I read that mvn eclipse:eclipse has been retired and I tried that but it doesn't gives me correct files.
How can I use M2E in VScode to regenerate these files? Or, how can I use M2E from the terminal (independent of IDE)?
Reference:
Apache Maven Eclipse Plugin (RETIRED) - Introduction
maven - how to run the command mvn eclipse:eclipse - Stack Overflow

Project creation based on custom archetype leaves out folders

I created my own maven archetype in my company's maven nexus.
The archetype jar file has all the necessary folders and pom.xml in the archetype-resources folder
But when I create a project based off of the archetype, the folders all get left out and only the pom.xml remains.
How can I fix this issue?
Thanks
Just as a note, I tried to create the archetype jar in several ways:
mvn archetype:create-from-project
mvn install
mvn deploy
mvn clean compile assembly:single
I still get the same issue

Do we have to include jar files in eclipse project if we are using maven?

I am new to maven.
The POM file in maven contains all the dependencies that we need in our project.
So we don't have to externally add any JAR's to the buildpath in eclipse.Right?
That's right. Maven will download dependencies and M2Eclipse (Eclipse plugin for integrating Eclipse with Maven) will setup a build path for you.
Two Solutions - 1 Using Eclipse IDE
Install the Maven (M2E Eclipse Plugin) if you use older version of eclipse, If you download the latest eclipse.
Point your settings.xml and create a maven project from your eclipse, it is better keep Group Id as com.yourcompany.app Artifact Id as yourProjectName and Version 0.0.1-SNAPSHOT depends on your Architecture Standards set by your company. Also Packaging can be as WAR file for WebApplication, EAR file for Enterprise Application. You can find the numerous list of examples from Maven Site.
2 From Command Line
Install Maven from Apache Maven site, Would recommend to go for the latest version -apache-maven-3.3.9-bin.zip.
Set the Maven Home in the Environment Variables as shown in the below figure.
Edit Your Path variable as %MAVEN_HOME%\bin, verify your installation by using this command from your command prompt. It should display the Maven Home and Java Version, which confirms your maven successful installation.
Paste your settings.xml (C:\apache-maven-3.3.9\conf) given by your build team or Architecture team for accessing your internal repository. And keep a backup of the original settings.xml (which is default download from Maven site)
Run these commands from your command prompt.
mvn eclipse:clean -e
mvn eclipse:eclipse -e (which will automatically set your project build path as shown in the below figure)
It will resolve your compilation issues and your project is ready as an deploy-able artifact

Maven: Deploying a jar/war with built in pom.xml file

I don't have a Maven project. What I have is a jar with the pom.xml embedded in the file. When I deploy this via the Artifactory GUI, Artifactory finds the pom and deploys it with the jar. It even recognizes the groupId, artifactId, and version.
When I try using mvn deploy:deploy-file it fails. If I extract the pom, and run mvn deploy:deploy-file with the -DpomFile=pom.xml, it works. Is there a way of deploying this jar with the embedded pom via the Maven command line? Or, do I need to extract the pom.xml first?
I have not heard of the possibility to specify the pom file from archive. I think it is unlikely to be an option, because Maven itself is just a light-weight program, which runs with plugins; and it needs some configurations to run with; and all references to plugins to be used are in those files.
Consider writing an Ant script that will extract the file, run mvn deploy:deploy-file -DpomFile=pom.xml and then delete the file.
The solution looks not very nice, I know, but it should help.
This is an Artifactory feature and not standard Maven behaviour.
Keep in mind that, for example, if you use dependency:unpack-dependencies or the assembly plugin to create some sort of über jar there would be multiple pom.xml files within the jar under the /META-INF/ path so it would be very difficult to select which pom was the true pom.

Resources