How to package an artifact using existing dependency artifacts? - maven-3

I have a simple project containing some WAR artifacts and one EAR artifact which bundles it together.
<modules>
<module>service1</module>
<module>service2</module>
<module>ear</module>
</modules>
If I run mvn package with that pom it works fine. The reactor recognizes the artifacts and I don't have to use the local repository.
I want to build service1 and service2 seperatly. After that I want to build ear using the build results from service1 and service2.
If I run mvn package only for ear, it searches the artifacts in the local repository and it will fail, because there are not there.
How can I tell the ear plugin to look somewhere else e.g. the target folder of the modules itself?
Background: I want to build every feature branch and don't want to mess up my local repository nor duplicate it for every branch.

Related

How can I use Artifact Deployer to copy from the archived artifacts, instead of the workspace?

We've been using Jenkins for a while, now, and have used the ArtifactDeployer plugin to copy build artifacts out of the working directory to our artifact repository fileshares.
I'm working on a new deployment promotion job, that needs to obtain the artifacts of a given build, and I thought I might use the Copy Artifact plugin. But that expects that the artifacts be saved using Jenkin's artifact archive feature, which we've not been using.
There are some nice features, in the Copy Artifact plugin - we can configure it to specify the upstream build that triggered the job, rather than having to pass a specific build number as a parameter. But to use it, we'd need to configure archive.
But we still need to copy artifacts to our artifact repository fileshares, which means we have to specify the files we want to archive twice - once in the archive config and once in the ArtifactDeployer config.
Unless we can configure the ArtifactDeployer plugin to copy the contents of the archive directory.
Is this possible?
What would be the path?

.m2 is not getting updated with latest xmlbeans jar files

I do have a jenkins job that builds XML beans jar files from the internal gitlab project and puts it on the artifactory. While having a build, this XML beans jar files are downloaded to the .m2 maven local repository. However, if this jar file exists in the .m2 repository then maven does not bother to download it from the artifactory. With being said, if there is a gitlab change, it does build it and put it on the artifactory. As there is already a jar file exist in .m2 repository, an old jar file is not being replaced with the new one. We ended up a wrong dependency to the customer with a release.
The question is , What am I doing wrong here?
mvn clean install -U
-U means maven will force update snapshot dependencies. Release dependencies can't not be updated this way.

Can the Cloud Foundry Maven Plugin Work With Multi-Module Aggregator Projects?

I have a standard multi-module maven project and I'm able to build it locally using mvn clean packagebut when I try to deploy it using $ mvn cf:update I get the following error:
[ERROR] Failed to execute goal org.cloudfoundry:cf-maven-plugin:1.0.0.M2:update (default-cli) on project <myprojectname>: An exception was caught while executing Mojo. The file or directory does not exist at '<my project directory>/target/<myprojectname>-SNAPSHOT.war'. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.cloudfoundry:cf-maven-plugin:1.0.0.M2:update
The problem is that I can't build a .war file for my parent .pom because it needs to be packaged as a pom file, or else maven will reject it. Therefore, I cannot supply the .war file cloudfoundry is looking for. Is there a setting I'm missing?
I'm currently looking into the Maven assembly plugin, but it seems like there should be a more straightforward way to push a multi-module maven project using the maven cloud foundry plugin.
Seems like your parent root either has a single parent pom file or if its a module, it only has a pom inside the target. You are not creating war file inside the target root of your project (if target even exist there). Your application is most likely having each module create their own war files inside their target folders.
At this time I don't think the cf maven plugin would support what you are looking for. could be a enhancement to add a parameter with the module that contains the war file but that is something that needs to be done!
https://github.com/cloudfoundry/vcap-java-client/blob/master/cloudfoundry-maven-plugin/src/main/java/org/cloudfoundry/maven/Update.java
I would recommend you to look into the assembly plugin (which you are already).
Let us know how it goes!

Building along with Project Dependencies in Ant

I have a Java project that is dependent on other Java projects that are siblings and there is a chain of dependencies. Each individual project has a build script written in Ant. For clarity find below a sample of the same.
EARProject depends on WebProject and EJBProject: The war file that is generated by the WebProject build and jar file that is generated by the EJBProject are needed to build the EARProject.
WebProject depends on ComponentOneProject: The jar file that is generated by the ComponentOneProject build is needed to build WebProject.
EJBProject depends on ComponentTwoProject: The jar file that is generated by the ComponentTwoProject build is needed to build EJBProject.
So, when I build the EARProject build, if the dependent war and jar have not been built yet, then it should kick-off the WebProject build and EJBProject build and if the ComponentOneProject is yet to be built, the build of ComponentOneProject needs to be kicked-off and so on.
Can someone suggest a clean method by which we can accomplish this?
Facing the same problem we at our company wrote a custom Groovy script that explores the full dependency tree ant generates the Ant build scripts based on all the .project, .classpath, .settings/* files. This wasn't as difficult as it might seem as first. This way we can build our products without (My)Eclipse on a clean CVS+JDK+Groovy virtual machine. Hope it helps..

teamcity ant multuple project build

I hope you guys can help me.
my problem is the following:
i have 2 projects that depend on each other each of them in different svn root.
what i do toady is build the first , take its artifact and copy it manually to where ever i want in second project and than run the second build.
i want to be able to run 1 build it can be either with a new ant build.xml file who will run the first build , copy its product to where ever i want it and than will run the second build.
second option run those 2 project with dependency in teamcity. i'm not sure how to do so and how to pass the first project artifact to be placed in the right folder i need it in the second project.
maybe someone know's how to do that.
thanks.
TeamCity's Artifact Dependencies seems to be the best option.
Suppose you have ProjectA and ProjectB:
Configure TeamCity to publish files from ProjectA:
Open General Settings configuration step of ProjectA.
Fill in Artifact paths field with relative paths to published files. TeamCity will collect these files after build finishes.
Build ProjectA to make sure artifacts are collected properly. Artifacts must become available on build results page (see Artifacts tab).
See documentation for artifacts for more details
Configure Artifact dependency for ProjectB:
Open Dependencies configuration step of ProjectB, add new artifact dependency
Depend on - select ProjectA
Get artifacts from: - use whatever you need. Possibly, last successful build.
Artifacts - enter artifacts paths from ProjectA. You can use popup to choose artifacts with UI.
Destination path - enter destination path, where artifacts will be copied to. Path is relative to checkout directory
See documentation for artifact dependencies for more details
Now each time you start build for ProjectB, it will download artifacts from last successful build of ProjectA. If you want these builds to start simultaneously, add Snapshot dependency (on ProjectA) to ProjectB. With snapshot dependency, each time you start ProjectB, it will first trigger ProjectA, wait for ProjectA build to finish and (if has artifact dependency on "last successful build" of ProjectA) download fresh artifacts.

Resources