create project from maven2 repository - maven-2

I want to create a maven2 project from artifacts in maven2 repository (POM and sources). Of course,I can create the directory structure, copy POM file and extract the sources manually. But I wonder if I can automate this task with maven.

Maybe dependency:unpack-dependencies can help you? Note, there are parameters such as classifier, copyPom, outputDirectory, type, etc that can be used to configure the content of the output.

Perhaps Maven archetype plugin can serve your need? It allows you to create an archetype, which can then be used to create a project.

Related

Convert web application project to maven project and convert corresponding .classpath file to pom.xml

Is it possible to convert project .classpath file to pom.xml after converting a simple web application project to maven project? Because if my project uses many jars and I want to convert it to maven then I will do configure->convert to maven but then it is not possible to add all the jars dependencies in pom.xml manually. So is there any tool to convert this.
First there is no tool to do such things. The problem is usually that you have a larger number of dependencies which you don't need to put into the pom.xml file, cause Maven handles transitive dependencies which means you only need to add only direct dependencies. The best thing is to look at the current projects jar files and try to find them in Maven Central and cut&paste the information form the search output into your pom. And of course test the build via Maven on command line.

Can I install several files into one artifact with Maven2 instal:install-file command

I'm developping application with JOGL2 and my favorite IDE Eclipse, also I want to use Maven2 for this purpose. Unfortunately, JOGL2 has no artifact yet. Also, I plan to deploy it as a runnable jar file.
So I want to install JOGL artifact locally : so i'll use the install:install-file command.
But I want to group several jars to make several artifacts, that is :
gluegen-rt.jar and jogl.all.jar as a single artifact named jogl.core
gluegen-rt-natives-linux-i586.jar and jogl.all-natives-linux-i586.jar as a single jar named jogl-natives-linux-i586
and so on
Is it possible ? (The official documentation does not mention the possibility or unpossibility to do so).
Thanks in advance
Install all files as usual like file:jar:version. Than create pom with pom packaging and use gluegen-rt.jar and jogl.all.jar as dependencies in it (they must be already installed). After that use new pom as dependency in your project.
maven doesn't have support for that. You would have to unpack these JAR files and repackage them together.
maven does have support for merging JAR with dependencies (http://stackoverflow.com/questions/574594) - and it's done the way I mentioned above. But you are asking about merging two arbitrary JARs, which is not possible in maven.

How to compile pom.xml without generating project in Maven?

I have pom.xml file that contains dependencies and files to checkout from svn so there is no no need to generate project. I just need these libraries and those files, so is there any way to get them without generating a project with maven directory structure?
I'm not sure from your question what do you want. If you have pom.xml file and you want to download all dependencies defined in it, you can call
mvn dependency:copy-dependencies
For more options look maven copy-dependencies task page
If you are asking how to create pom that will contain no code, but only dependencies, you can do that by specifying pom packaging.

How to convert Ant project to Maven project

How to convert a Ant project to Maven project? A sample project that would link (a Wicket project)
Thanks
The nice part of using maven is that most standard stuff works automatically once you do things the maven way. For a simple webapp:
Create a pom with groupId, artifactId and version (packaging: war)
Add the required dependencies to the pom
move the
java sources to src/main/java,
resources to src/main/resources,
webapp content to src/main/webapp,
test content to src/test/java and src/test/resources
set the compiler compliance version using the maven compiler plugin
That should get you up 'n' running.
http://www.sonatype.com/people/2009/04/how-to-convert-from-ant-to-maven-in-5-minutes/
I don't know what your ant script looks like, but assuming its a basic script for building, you will need to create a pom.xml file for your project, add your dependencies, and then build it via maven.
For anyone who lands here in future, there is an easier way to find dependencies for maven using the file hashes. So, you won't have to guess artifact versions.
As per the below article, the idea is to generate a SHA1 checksum of the dependency that you want to find the information, then do a reverse search in Nexus repository manager using that hash. For the checksum generation, you can use Microsoft's FCIV (free) utility.
https://devreads.xyz/ant-to-maven-conversion-the-painless-method/

Best way to migrate an IntelliJ project to Maven?

I have a project that uses the built-in IntelliJ build system. What's the quickest/best way to migrate the project to Maven?
What's the quickest/best way to migrate the project to Maven?
Manually. Here is what I would do (I would personally use the command line):
create a parallel (potentially multi-modules) project structure using archetype(s)
declare dependencies for the jars you're using (not all of them, you'll get some transitively)
move sources and resources to the new structure
test the build
import the project back into your IDE
IDEA understands Maven very well. Unfortunately it does not create Maven configuration for you.
You'll have to write pom.xml yourself. The complexity of this depend on the structure of you project and frameworks/libraries that you use.
For me the easiest way is to create a new project based on artifact and then copy existing source files into it. You can do this in IDEA:
File -> New project -> Create project from Scratch
Choose Maven module, Next
Check Create from Artifact: a list of available artifact will show. Choose one based on libraries/frameworks you use. You can also add one if it's not on the list (search the web).
When project setup is done, start copying sources.