I have a "commons" library that I install to my local repo using mvn install. That library provides common company stuff used in different, not connected projects.
So I include that library as a maven dependency. And when I run mvn package on the final projects, there have been days where I forgot that I have to explicit install the commons library to get the changes picked up during package of the implementation projects.
Is there any chance I could trigger/invoke install of a different project during package?
You will have to use Antrun maven plugin, and execute shell command using ant while running properr lifecycles of maven build.
Here you have some details on configuration
http://maven.apache.org/plugins/maven-antrun-plugin/
If repository manager or external scripting (Ant) is not an option you could tweak your project structure. You could introduce an aggregator maven project which will run modules in a predefined order:
<packaging>pom</packaging>
...
<modules>
<module>[path to commons project]/commons</module>
<module>[path to your module project]/module</module>
</modules>
So whenever you want to build your project you build this aggregator project instead.
Related
I am using Maven to use Postrgres SQL driver. Besides I am using InteliJ IDEA Ultimatre Edition, and, as I understood, Maven is included in Ultimate version initially. Correct me - all I need, is to set dependencies, and connect PostrgeSQL to Java. I am not oblige to Download Maven (except required Dependecie of course, I mean Maven as framework)? Thanks a lot!
When you are creating a new project, choose Maven. After the project is created, you will receive an empty Maven project structure with the pom.xml and a script mvnw of Maven Wrapper, which you can use (instead of mvn) to build your app.
Just add dependencies to the pom.xml and build.
The Maven Wrapper will do the work for you - download Maven into the project subdirectory and use it.
I have teamcity currently configured to use the maven mojo, to publish the gradle jar as a nexus snapshot with just the gav.
I observe that if i use the maven plugin and do a gradle install in the IDE, i am able to see the generated pom.
1) Can i use this pom to publish the jar in nexus repo in teamcity ? I know that i can do it for a pure maven build by using it's pom.
2) Is there a way to not use this pom, and istead configure teamcity build steps to publish from gradle build directly ?
Gradle can of course take care of the publication. It will leverage the build information to produce a POM file that represents best what is declared in your project.
It will then be trivial to invoke that Gradle task from the Teamcity build.
Have a look at the publishing documentation for details on how to set it up.
Suppos that repo and share module were generated from maven alfresco archetype as described here. And now it needed to install one of alvex addons. It is clear that jars/amp can be build from sources, but what to do with this? Where to put they in generated maven project to get them installed in alfresco when mvn integration-test -Pamp-to-war is executed?
That tutorial assumes two separate maven projects created using the repo archetype and the share archetype, respectively.
If you want to be able to run integration tests with multiple AMPs you may rather use the all-in-one archetype instead.
See How to use external AMP in alfresco Maven Project
If someone could help me out here it would save me a lot of time.
I maintain an open source library that gets pushed out to a sonatype repository. I make changes to that library a few times a day and push it out to the 1.0_snapshot build using mvn deploy.
Let's call it project1
I work constantly in another project that uses that library let's call it project2.
Right now, whenever i make changes to project 1 or 2, i need to first build and deploy project 1 to the repo, then build project 2 so it downloads a fresh copy of project1.jar
Project2 has Project1 as a dependency in a pom.xml:
<dependency>
<groupId>com.group</groupId>
<artifactId>project1</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
in order to build in a way where all of my changes can be tested, I have to do something like this:
mvn -f ./project1/pom.xml clean deploy
mvn -U -f ./project2/pom.xml clean package
this uploads my project1.jar to sonatype, then project2 downloads the new snapshot and builds it.
This is a simplified picture of what i'm doing on a larger scale, where my compiles take 5 minutes of up and downloads.
Question: What is the proper way to use maven so it knows to use the source of project1 in a dependency in project 2?
IDE:
install m2e in eclipse
import your both projects into workspace
from consumer project (right click > maven > enable workspace resolution)
this will put project2's classes in classpath from its target/classes instead of the actual jar
native straight maven:
You can create a maven project tree, if this two are open source project going through same build cycle it must have one already, if they are not related but related for your usecase then you can temporarily create a maven tree on top of these 2 projects and build the top parent it will build from bottom up in one command
it will find the leaf project, build it install it in maven's cache and now while building projectA it will refer it from maven's cache so no need to deploy to sonatype
You can also point project2 to build using offline mode :
mvn -o package
Then you drop the upload part of the project1 build to the remote repo.
Check the following link: Intro to repositories and How do I configure Maven for offline development?
Is there a proper way of doing this maybe through a command line? Or do I really have to modify the POM file itself? Let's say I want to install the maven war plugin into an existing project. I tried googling but I can only find the usage and not the installation to an existing project.
As documented here,
Maven is - at its heart - a plugin execution framework; all work is
done by plugins.
You must mean invoking or using a plugin than installing a plugin. You can invoke pretty much any maven plugin without updating the pom, so long as you are ok with the default configurations.
For instance, to generate a javadoc on a maven project, you could just type
mvn javadoc:javadoc
Now, coming to maven war plugin. This creates a war artifact of your project. It makes no sense to invoke it on a project, unless the project is a war project. If it is so, the packaging of the project should be war.
<packaging>war</packaging>
In this case, maven war plugin gets automatically invoked on it.
If you want to customize/configure a plugin or based on the type of plugin, you declare it in your pom (in <plugins> section and do the configurations).
You add the plugin to the POM.
Maven configuration is done via the POM; it's kind of the point--the POM defines the project.