Deployment deploys twice or not at all - maven

I managed to build a Maven project in a way that makes the release deploy artifacts either double or not at all.
Since the project uses an abstract parent pom of our company it's a bit hard to post the relevant code, but I'll try.
First things first. The parent pom has the following definition:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<deployAtEnd>true</deployAtEnd>
</configuration>
</plugin>
With nothing defined in the actual project, the release will fail after these lines:
[INFO] [INFO] Uploaded to our_repo: http://acme.org/nexus/content/repositories/org.acme.project/1.0.0/org.acme.project-1.0.0-sources.jar (14 kB at 3.8 kB/s)
[INFO] [INFO] Uploading to our_repo: http://acme.org/nexus/content/repositories/org.acme.project/1.0.0/org.acme.project-1.0.0-sources.jar
Our repo doesn't like having two release JARs with the same version, so everything fails. The weird part here is that the deployment is NOT at the end. In fact the project build fails halfway through.
However if I copy the above plug-in in the project, the build will print Deploying repo:org.acme.repo:1.0.0 at end at the same position and then not deploy anothing at the end.
But I'm not even sure that's part of the problem. Still I think both builds should work exactly the same no matter where the plug-in definition is.
I found this question, which made me check the maven-source-plugin in the effective pom. However there are no duplicates there:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>...</configuration>
</execution>
</executions>
</plugin>
Nothing is defined in the maven-assembly-plugin either, so no JAR is added for deployment (suggested in this question).
It might have to do with us using Java 10 or Maven 3.5.2, though I'm honestly stumped on what to test and where to progress.
How do I fix this mess? (If you'd like more information about the build, just ask. The pom.xml is way to big to share them here.)

Inspired by that question I tried to disable the release profile, and now it works somehow. I'm not able to conjure any kind of explanation for that behavior.
Snippet for removing the release profile:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
</configuration>
</plugin>

Related

Maven dependency not found but present in mvnrepository

I created a simple web scraper with Java and Selenium. It just reads a single piece of information and writes that to a CSV file.
I'm trying to run it daily using some scheduler on Heroku. The official Heroku documentation says I need to add this to the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
But when I add it to the pom.xml, I'll get
Plugin 'org.apache.maven.plugins:maven-dependency-plugin:3.0.1' not found
even though it found in mvnrepository.com. What is happening here?
First of all, run the build again (with something like mvn clean verify) and see if you get the error again.
If so, you probably have a network/firewall issue, or you misconfigured your settings.xml (if you have one).

Cannot resolve maven dependency

I have written a custom plugin and I deploy it to an internal company repository. I have another project that uses the plugin (here is the pom.xml snippet):
<build>
<plugins>
<plugin>
<groupId>com.mycompany.mypackage</groupId>
<artifactId>json-schema-generator-main</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>json-schema-generator-main</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I deploy my custom plugin to our internal repo and my local one successfully. If I remove it from my local repo, however, when I run "mvn clean install" in the dependent project I get the following output:
[ERROR] Plugin com.mycompan.mypackage:json-schema-generator-main:1.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact com.mycompany.mypackage:json-schema-generator-main:jar:1.0.0-SNAPSHOT ->
What could be causing this behavior? I'm happy to provide more information, such as the details of my custom plugin, which uses a lot of reflection and classpath hackery to generate Json Schema text files, or it's pom.xml, but I'm not sure what would be relevant without turning this into a wall of text. As best I can tell it is correctly deployed in the repo, and this problem only occurs if you remove the custom plugin from your local repository.
Answered in comments:
I had a versioning issue in my deployment to the internal repository.
The files were not being properly named and therefore obviously could
not be found. I apologize. – Jesse Aug 14 '14 at 19:12

Xcode Maven Plugin : adding extra headers

The Xcode Maven Plugin from http://sap-production.github.io/xcode-maven-plugin/site is a nice maven plugin for people who like maven and wan't to avoid some pain with xcode dependencies, framework creation and such.
It creates and installs lib and headers in the repository.
The headers are bundled in a .tar file during the process.
For some reason, I need to edit the tar file and add a few files in it before installing.
But as I'm quite the noob regarding maven, I need some help !
How can I modify on a byproduct of Maven before it is installed ? I suppose I can write some script that add some files to the .taf, but how can I be sure it's executed prior the installation ?
#Redwarp - It's been a while since this question was asked, but I'll offer up an answer.
You can configure a Maven plug-in's goal to be executed during a particular phase in the Maven build lifecycle.
Pick a phase that's executed before the install phase. Package may be the best phase for you to edit your tar file and add your required files.
The following is just a generalized example (the focus should be on phase and goal):
<project>
...
<build>
<plugins>
<plugin>
<groupId>com.sap.prd.mobile.ios.mios</groupId>
<artifactId>xcode-maven-plugin</artifactId>
<version>1.12.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>do-something</id>
<phase>package</phase>
<configuration>
...
</configuration>
<goals>
<goal>plugin-goal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
Find the plug-ins that suit your needs and bind their goals to the appropriate Maven lifecycle phases...which there's a good chance that you have already figured out by this point.

How to execute maven plugin _after_ all module builds finish

Specifically I am trying to run maven-javadoc-plugin but whenever I change the version numbers on the parent/aggregator pom and all of the children, the first time I run the build it fails because javadoc runs first and can't find any of the new version packages from the modules because they haven't been built yet.
I usually end up having to comment javadoc out for one build and then add it back in once the packages are available in nexus for the new version. However, this likely means that I've been building javadoc on one build old source jars all the time.
I've read suggestions of putting another module in that depends on the other ones but I don't think i can get a module to build the javadoc for peer modules. Having it in the parent builds all of the javadoc for all of the modules, I just need it to happen later. Thanks. Here's my javadoc plugin config.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>generate-javadoc</id>
<phase>package</phase>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<aggregate>true</aggregate>
<links>
<link>http://java.sun.com/javase/6/docs/api</link>
<link>http://java.sun.com/javaee/5/docs/api</link>
</links>
<maxmemory>512</maxmemory>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.2</version>
</docletArtifact>
<additionalparam>
-inferrel -inferdep -outputencoding utf8 -hide
java.* -collpackages
java.util.*
-qualify -postfixpackage
-nodefontsize 9 -nodefontpackagesize 7
</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
One way to get around this problem is not to invoke javadoc plugin in the normal maven lifecycle phase; instead run it separately.
To be specific, remove <phase> tag from the above plugin definition.
Run mvn install javadoc:javadoc from parent.
This will build and install all the modules and the parent and then run javadoc on them.
Is your javadoc plugin declaration in the <build> part of your pom. You should consider moving it to the <reporting> part see this link.

disable maven release plugin defined in parent pom

I am new to maven. I have product structure as following
myWebProduct
pom.xml
coreModule
webModule
htmlTestModule
The maven release plugin is defined at the company level of pom.xml file which is parent of myWebProduct. It has set release plugin run default goals of deploy and default preparationGoals clean verify install.
I want to release product in myWebProduct level which works fine except I would like to skip release the htmlTestModule. Because deploy life cycle on htmlTestModule will cause deployment of war file to remote Tomcat servers and I don’t want this happening during release.
I tried to add following in pom.xml of the htmlTestModule.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<skip>true</skip>
<preparationGoals>clean validate</preparationGoals>
<goals>testCompile</goals>
</configuration>
</plugin>
But when running 'mvn release:perform' at myWebProduct. I have seen the deploy goal was still executed on htmlTestModule. Could anyone help with this?
And I also tried following on htmlTestModule:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>donotRunMe</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
Still, the deploy goal always executed in htmlTestModule.
Thanks
I think you're taking the wrong approach here. Let me explain.
The deploy phase of maven is not meant to mean deploy to a remote server or anything like this. This is meant to be deploy to a remote repository.
Hence I believe you shouldn't try to skip the deploy phase in your module, but un-tie the deployment to a remote Tomcat server from the deploy phase, by making it a specific goal for example.

Resources