How to auto create parent packages by groupId and artifactId in pom xml - maven

when creating maven projects, do a lot rework to create specified parent package.
such as:
when created maven project with groupId com.test and artifactId jpa-demo,
later only thing to create packages: com.test.jpa.demo in src/main/java.
so how to auto create these pacs?
mm. didn't find useful plugin in IntelliJ Idea.
anyone know a good idea? tks.

What you can try to use is Maven Archetypes like this:
mvn archetype:generate
in interactive mode.
https://maven.apache.org/guides/introduction/introduction-to-archetypes.html

Related

Does maven care about file names?

I am trying to install some dependencies using maven in a spring boot project.
I am looking for a jar
org.apache.maven.plugins:maven-resources-plugin:jar:3.1.0
But I wanna know if the jar file should have this name maven-resources-plugin, or if the file name is not important for maven. I mean if maven will automatically know which jar file should use.
I will appreciate any help or feedback.
That is a plugin, not a dependency as such (meaning that Maven needs it for building your project, your code doesn't need it to compile or run).
You should only have to specify the plugins groupId, artifactId and version plus any configuration in your pom.xml, and Maven knows exactly what jar to get and how to use it.
See https://maven.apache.org/plugins/maven-resources-plugin/plugin-info.html for further information.

How to run Maven Javadoc in a project with pom packaging?

I have a project that packages the delivery of a software using the assembly plugin. The packaging of the project is pom.
To make a nicer documentation i am using the dependency plugin to download the sources of the different projects and then using the javadoc plugin to generate a new documentation that merges the javadoc for the different projects into one.
The issue I am having is that maven javadoc will not run if the packaging is pom.
It complains with the message: Not executing Javadoc as the project is not a Java classpath-capable package
However, if I put packaging jar it works. Unfortunately then an empty unwanted jar file is generated.
Is there a way to get the maven javadoc to run with packaging pom?
Cheers,
Javi
The workaround I have found was to set the packaging in the pom to jar and prevent maven jar plugin to generate the jar.

Creating a Maven Project Programmatically Runtime

I have created a number of java classes using sun code model library. Now, I would like to create a maven project add those classes and upload it to a Nexus Sonatype Internal Maven Repository. Does anyone know how to create a maven project programmatically. Any help will be appreciated.
It is not really programmatically, but maven archetype can generate a project squeleton for you:
mvn archetype:generate -DgroupId={project-packaging}
-DartifactId={project-name}
-DarchetypeArtifactId=maven-archetype-quickstart
You can also run simply :
mvn archetype:generate
And choose an archetype from the list displayed.
Once done, you can put your java file in src/main/java.
https://maven.apache.org/guides/introduction/introduction-to-archetypes.html

Build,Unit test,Compile using maven

I want to some operation on my xcode project that is compile,build and unit test using the "Maven" command like "mvn clean install","mvn validate". do we need to create Pom.xml? how can we create Pom.xml
Thanks
sure, u need pom.xml. how to build your pom? you can read maven's manual:
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html

What are the difference between pom.xml and effective pom in Apache Maven?

Could somebody explain to me, what are are differences between the file pom.xml and the file effective pom.xml in an apache maven project?
The Super POM
All Maven project POMs extend the Super POM, which defines a set of defaults shared by all projects.
The Simplest POM
All Maven POMs inherit defaults from the Super POM. If you are just writing a simple project that produces a JAR from some source in src/main/java, want to run your JUnit tests in src/test/java, and want to build a project site using mvn site, you don’t have to customize anything. All you would need, in this case, is the simplest possible POM shown in The Simplest POM. This POM defines a groupId, artifactId, and version: the three required coordinates for every project.
The Effective POM
It is the merge between The Super POM and the POM from The Simplest POM.
NOTE: This info was extracted from the following link (in the link the explanation is very complete)
Maven: The Complete Reference - 3.2. The POM
You can see the difference of a pom.xml and the effective pom.xml using
mvn help:effective-pom
which is describe here.
In a multi module project you'll use a parent pom.xml for defining general settings for all modules and then in each module there will only be specific settings.
The above goal will help you analyze the resulting pom that you could of course actually use instead of the parent reference.
The whole idea is by using the generalization (super-pom) / specialization (module pom) approach there is a central place where you can specify the general configuration. This is much more efficient then having to cut&paste the general parts.
Please also note that the effective pom will add the default behavior e.g. for the jar plugin so that you can debug issues like
Maven JAR Plugin 3.0.2 Error: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them
with this approach. See also Maven `help:effective-pom` only generating for a single project, not all projects

Resources