65654

Maven: No primary artifact to install, installing attached artifacts instead

Question:

I have a <em>parent</em> Maven POM that looks like this (the oss-parent can be seen <a href="https://raw.github.com/skunkiferous/oss-parent/master/pom.xml" rel="nofollow">here</a>):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.blockwithme</groupId> <artifactId>oss-parent</artifactId> <version>0.0.5</version> </parent> <groupId>com.blockwithme</groupId> <artifactId>xtend-contrib-parent</artifactId> <version>0.0.3</version> <packaging>pom</packaging> <inceptionYear>2013</inceptionYear> <name>Xtend Contrib Parent</name> <dependencies> <dependency> <groupId>org.eclipse.xtend</groupId> <artifactId>org.eclipse.xtend.lib</artifactId> </dependency> <dependency> <groupId>org.eclipse.xtend</groupId> <artifactId>org.eclipse.xtend.core</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.xtend</groupId> <artifactId>xtend-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> </plugin> </plugins> </build> <modules> <module>base</module> <module>examples</module> </modules> </project>

With a child "base" POM that looks like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.blockwithme</groupId> <artifactId>xtend-contrib-parent</artifactId> <version>0.0.3</version> </parent> <artifactId>xtend-contrib-base</artifactId> </project>

It creates and install the child Jar in the local repo. But I would like to install the source and/or javadoc too. So I add this to the <em>parent</em> POM:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> </plugin>

But if I do that, the source and javadoc get installed, but the compiled code jar <em>stops being installed</em>, which makes no sense to me. Maven gives this warning:

[INFO] No primary artifact to install, installing attached artifacts instead.

Which does <em>not</em> appear, if I do not try to get the source installed. Adding the maven-jar-plugin plugin does not help. Nor does adding "<packaging>jar</packaging>" to the child POM.

Answer1:

You could try to change a goal for the source plugin from jar to jar-no-fork. With source:jar goal as part of the lifecycle, Maven will re-run all of the goals bound to generate-sources and its predecessors. My assumption is that there is a clean executed somewhere during that loop, erasing the main jar file. In contrast, jar-no-fork will not run the bound goals again.

Plugin configuration should therefore look like

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin>

Answer2:

My guess is it's trying to do that in the parentPom. I would not define the common plugins in your parentPom. In your parentPom, I would define the plugins (with their versions) in the pluginManagement section of the POM (not the plugins section). Then, in each child, state which plugins are used (without the version in the declaration). This will provide more control.

Recommend

  • After upgrade to Django 1.11 append_slash no longer works
  • Django: Model class user.models.Users doesn't declare an explicit app_label and isn't in a
  • Cloning a Windows Store app - What should be changed?
  • py2exe not including the modules from “includes”
  • Grails 2.1.1 - How to develop a plugin with an AstTransformer?
  • ModuleNotFoundError: No module named 'tensorflow.contrib'; 'tensorflow' is not a
  • How do I extend UserCreationForm to include email field
  • Issue loading 'dplyr' packages
  • C++ face detection/recognition implementations
  • Creating grails binary plugin results in jar file wich contains all groovy files with comments
  • Django: DRY principle and UserPassesTestMixin
  • Installing samr in in R 3.4
  • How to force Composer to download a local package?
  • Grunt watch Running “watch” task Waiting
  • How to load Q library with Require.js?
  • How do you create a Fuseki SPARQL server using the Apache Jena Java API?
  • Unzip archive in .Net CORE 1.0
  • Wrapping text in spinner android
  • Any nice way to generate a timeline view of commits from subversion?
  • Local Development, Apache vs Developer - file permissions
  • Django return user model id with L
  • Why are YouTube videos using 'youtube.com/v' not loading
  • How to access meteor package name inside package?
  • How to get latest version of a artifact on Bintray using JSONP
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • Angular2 component view does not update on value change via method
  • CakePHP ACL tutorial initDB function warnings
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Force show.bind execution
  • Unable to install Git-core+svn by MacPorts
  • error importing numpy
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Very simple C++ DLL that can be called from .net
  • Disable Enter in editText android
  • Control modification in presentation layer
  • SetUp method failed while running tests from teamcity
  • How to get icons for entities from eclipse?
  • Understanding cpu registers
  • Linking SubReports Without LinkChild/LinkMaster
  • Easiest way to encapsulate a HTML5 webpage into an android app?