Packaging for reactor multi module build? - maven

I suppose I've made something wrong failing to find answer for basic philosophical question:
What is the correct packaging for reactor build module for multi module maven project?
I'm using pom but I don't feel it's correct since the pom artifact is used by no one:
<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>
<groupId>com.example.project</groupId>
<artifactId>reactor-build</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../config</module>
<module>../module1</module>
<module>../module2</module>
</modules>
</project>

The packaging pom is the only allowed packaging for aggregator projects, that is to say a project with modules like the one you have, and also for parent projects. From Inheritance:
The packaging type required to be pom for parent and aggregation (multi-module) projects.
Any attempt to use a different packaging will result in an error when trying to build the project, such as the following when using jar (or keeping the default):
[ERROR] 'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging.

Related

How to use smartics-jboss-modules maven plugin in maven project

We can create module.xml manually and keep it in modules folder of Jboss. But to autogenerate it, there is a plugin called smartics-jboss-modules-maven-plugin. Has anyone implemented it in maven project. My requirement is to generate module.xml and module from maven project and automatically add it to jboss modules folder. I need to know the exact steps to implement it in my project.
and inside that particular folder make sure you create a file that complies with the following model
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
</project>
As documented in here:
https://www.smartics.eu/confluence/display/SJBMMP/The+smartics+JBoss+Modules+XSD

Call hierachy of properties in pom.xml

I have a maven project with multiple nested projects. All of them do always have the same version. Untill now, if I want to increase the version, I went through all pom.xml files and changed the version number.
Now, I wanted to outsource the version to the properties tag of the parent pom.xml file. It works, for all nested projects, but not for the parent pom itself.
In which order are the attributes in the pom.xml called? I can not reference
the project version in the parent pom.xml file.
The code snippet shows the parent pom.xml
<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">
<groupId>com.my.project</groupId>
<artifactId>my.project</artifactId>
<packaging>pom</packaging>
<version>${projectVersion}</version>
<properties>
<projectVersion>1.0.0</projectVersion>
...
</properties>
<modules>
<module>my.project.service</module>
<module>my.project.db</module>
...
</modules>
I expect the pom to take the version number defined in the properties. But it failes building with the error invalid reference format
I expect the pom to take the version number defined in the properties.
But it failes building with the error invalid reference format
By running a maven goal from the parent project, maven first binds the artifact/group/version in the current build process, so it uses the version defined here :
<version>${projectVersion}</version>
I can not reference the project version in the parent pom.xml file.
In this case, you could "cheat" by creating an aggregator/multimodule project that defines a not used/fake version (1.0-NOT-USED for example) that has as unique module the parent pom. When you build the aggregator/multimodule project, you can now pass as parameter the version to use in the parent project and all its modules.
As a side note, to use a central version for a set of projects, you should use the flatten maven plugin that relieves you from the hell version management.

mvn Deployment failed: repository element was not specified in the POM

When I run mvn clean deploy on my project I get an error
Also my project in eclipse displays the following errors which I don't know if they are related to my current problem.
Project configuration not up-to-date with pom.xml
plugin configuration not covered by lifecycle configuration
In addition my eclipse doesn't seems to compile the files correctly. My SpringBoot java files aren't being compiled as java files. I can tell because if I deliberately induce syntax errors, there isn't a compilation error. This is all run on eclipse EE and is part of a maven project so I don't even know if a source folder is needed.
Also I'm displaying my main pom.xml file below and it has compilation errors on "pom" and both "&ndash"
I've tried the following solutions
Eclipse Blue, Maven: Project configuration is not up-to-date with pom.xml
Failed to resolve version for org.apache.maven.archetypes
repository element was not specified in the POM inside distributionManagement element or in -DaltDep loymentRepository=id::layout::url parameter
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.fanniemae.dfc</groupId>
<artifactId>dfc_app</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>dfc_angular</module>
<module>dfc_springBoot</module>
</modules>
<!--<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3RELEASE</version>
<relativePath/> <!– lookup parent from repository
–>
</parent>-->
</project>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dfc_app: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
mvn deploy will deploy the produced artifact to a Maven Repository.
To do so it needs the configuration to which repository it must be deployed and this is missing.
But I assume that you don't want to deploy it to a repository but just build it.
That's mvn install This will install it in your local repository.
Maybe you should start with reading the docs: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Maven version error during build

I get the following error when I am trying to build my project
Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.25.0:validate-version (default-validate-version) on project com.google.guice: Maven version 8.0.0.qualifier must have -SNAPSHOT qualifier for SNAPSHOT builds -> [Help 1]
I am not using release plugin for my build. I haven't seen this error before and not very certain about its meaning. All I am doing is changing version from in my pom from "-SNAPSHOT" to ".qualifier". Can someone help me understand what I am doing wrong? As far as I can tell I am not doing anything different from previous times I've build release version of my projects.
Here is my pom file:
<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>
<artifactId>com.google.guice</artifactId>
<!-- BEFORE -->
<version>8.0.0-SNAPSHOT</version>
<!-- NOW -->
<version>8.0.0.qualifier</version>
<build>
...
...

Automate creation of pom file dependencies based on the jar file

I have hundreds of jar files scattered across different projects that I need to create pom file dependencies files for. I'd really like to avoid manually searching for every jar file and adding the dependency manually. Is there an API I can use to accomplish this task or some other way ?
Ive tried using a generic pom as described : http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
Using this command - mvn install:install-file -Dfile=spring-webmvc-portlet-3.0.6.RELEASE -DgroupId=test -DartifactId=test -Dversion=version -Dpackaging=jar-DgeneratePom=true
But should the generated pom not match the jar file ? Or do I need to add this myself
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>version</version>
<packaging>jar-DgeneratePom=true</packaging>
<description>POM was created from install:install-file</description>
</project>
I wrote a script that generates an ivy file. It uses the jar checksums to identify the matching modules in Maven central.
https://github.com/myspotontheweb/ant2ivy
This solution could be adapted to generate a Maven POM.
You may create a bash script which uses the Maven Install plugin to produce a generic POM.
See http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html

Resources