I have Maven project with dependencies in repo and stuff. I want to "export" its sources with all dependencies so that I can successfully open it in IDE without Maven running on a machine.
When packaging project into war file, it has all dependencies packed with it.
So I want to have all that dependencies plus my sources gathered in one place, which can be opened with IDE (Eclipse or IDEA) all those libraries detected?
When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build.
Via the Maven index, you can search for dependencies, select them and add them to your pom file. To download the index, select Windows > Preferences > Maven and enable the Download repository index updates on startup option. After changing this setting, restart Eclipse. This triggers the download of the Maven index.
Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.
Try maven-dependency-plugin with goal copy-dependencies
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>
PS.
Are you aware of maven and IDE integration (for Eclipse p.e.)? Maven can generate project for particular IDE and include all dependent jars as variables (pointing to these jars in local repository), so there is no need to use copy dependecies to subfolder.
Actually, there is nothing that will create a bundle with sources and dependencies out of the box. For this, you'll need to use a combination of the some plugins.
For dependencies, the Maven 2 Dependency Plugin and its copy-dependencies
will help as pointed out by cetnar.
For sources, you might need the Maven Source Plugin and its source:aggregate
goal (or maybe the Maven Assembly Plugin and the pre-defined src
descriptor but source:aggregate
is handy for multi-modules builds).
To bind the whole thing together (and maybe unpack sources), I'd use the Maven Assembly Plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With