I define a URL for a Maven site by
<distributionManagement>
<site>
<id>site-nexus</id>
<url>dav:http://ik-repo1:8084/nexus/content/sites/site/${project.groupId}/${project.artifactId}/${project.version} </url>
</site>
</distributionManagement>
If I add this to my pom, the site gets deployed as expected: It can be accessed through the URL that was specified.
But, if I add this to a parent POM, subdirectories are added to this url. I guess this happens along the lines of
"If subprojects inherit the (distribution) site URL from a parent POM, they will automatically append their artifactId to form their effective deployment location. This goes for both the project url and the url defined in the element of the pom."
in https://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html .
My parent POMs are not part of a multi-module build, but are just used to share configuration for all of our projects (some hundred projects, actually). So I would like to specify a URL in the parent POM that should be used for each project as if it was specified in the POM itself (i.e. without subdirectories in the URL beyond the ${project.version} directory that I defined myself).
How can I achieve that?
It's marked as an improvement for Maven, see https://issues.apache.org/jira/browse/MNG-5951 for all the details.
Related
I have a single Git repository that contains several Maven modules, using Maven inheritance and Maven aggregation. That is, in the root directory, there is a parent POM, that defines some modules, each of which use that root POM as their parent.
<project>
…
<groupId>io.example</groupId>
<artifactId>parent</artifactId>
<version>1.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
…
<scm>
<connection>scm:git:https://bitbucket.org/example/foobar.git</connection>
<developerConnection>scm:git:https://bitbucket.org/example/foobar.git</developerConnection>
<url>https://bitbucket.org/example/foobar</url>
</scm>
…
<modules>
<module>foo</module>
<module>bar</module>
</modules>
…
I recently found out that Maven will append the module path to the <scm><url> value for each module (foo and bar above). For example, the foo submodule would get an SCM URL of https://bitbucket.org/example/foobar/foo.
So should each of my modules redeclare the <scm> section, so that the submodule POMs have the same SCM URL as the parent POM? How does the Nexus Staging Maven Plugin use this SCM information, anyway?
I have also cross-posted this at Sonatype.
Regarding your initial question in the title: It does not use it given the code provided at github. When you search for 'scm' in all .java files you have zero hits. Of course they could do some weird tricks like building the String like "s" + "c" + "m" or it is hidden in some third party dependency or...
Still I think besides an offical answer, this is the best any outsider can tell.
I am new to maven and I'm confused about the difference between the artifactId and name.
What I know is that artifactId is the name of the artifact you are creating. I know that artifactId together with the groupId is use to uniquely identifies an artifact. So what is <name> purpose in POM. like the pom below I got from a site there is an artifactId and at the same time a <name>.
<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>Multi Chapter Simple Parent Project</name>
You are correct that the artifactId helps identify the project.
The name is simply a human-readable "friendly" name. It is not required for a basic setup.
From the Maven documentation,
artifactId: The artifactId is generally the name that the project is known by. Although the groupId is important, people within the group will rarely mention the groupId in discussion ... It, along with the groupId, create a key that separates this project from every other project in the world (at least, it should :) ). Along with the groupId, the artifactId fully defines the artifact's living quarters within the repository.
The groupId, artifactId and version form a composite unique identifier (or coordinate) for this project. Each of these values has a fairly rigid naming convention that allows well organized groups, artifacts and versions.
The name is simply a readable name for the project and does not need to be unique or comply to the same conventions (so it can contain spaces and other characters).
The name is used for the project used by maven to build the artifact, while the artifact-id is used to identify the artifact that will be built.
For example:
This pom file definition for the rsts ear file:
Causes the rsts-ear project to be imported into Eclipse:
But creates the rsts_ear artifact in the nexus:
This means that the artifact-id, not the name, is referenced to include the artifact in the build as part of another artifact.
I want to build one jar that includes a child module which depends on other package of my own project.
The output one jar should include all the related class (both from jar and my own project's classes).So the child module's classes is the base classes that should be included in the output jar,and these import some classes of my own project.All the related classes in my own project should be included.
for more detail please visit How to automatically collect all related class into one jar (use maven)?
Here is what I already find:
<project>
<dependencies>
<dependency>
<scope>system</scope>
<systemPath>D:\how\to\write</systemPath>
<groupId>how.to.write</groupId>
<artifactId>how-to-write</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>java-source</type>
</dependency>
</dependencies>
</project>
The error message is : Could not find artifact how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT at specified path D:\how\to\write
the path D:\how\to\write contains my own project's classes that could support the build
Your maven dependency will look for a jar file with name how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT in D:\how\to\write directory. Since you do not have one, the build will fail.
If your own project does not use maven, then you should create a jar file and place it in D:\how\to\write location and rename it to how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT. Then your build mvn clean install will be success.
The command for creating jar file is jar cf jar-file input-file(s).
Have a look at this page on how to create a jar file
My maven distributionManagement section in my base pom.xml for the site looks like this:
<distributionManagement>
<site>
<id>main-site</id>
<name>Main Artifact Site</name>
<url>scp:/somurl/site/${project.groupId}/${project.artifactId}/${project.version}</url>
</site>
</distributionManagement>
We have a base pom.xml, which several projects inherit from. These projects, in turn, have several modules (each with their own poms).
As you can see, the url we pass takes care of uniquely identifying each project/model. Maven appends an extra artifactId after the version for each inherited pom. I would like to stop that behavior. It leaves us with url's like
http://someurl/site/com.whatever.something/some-project-parent/1.14/some-project-parent
http://someurl/site/com.whatever.something/some-project-module/1.14/some-project-parent/some-project-module
I would like for these urls to look like
http://someurl/site/com.whatever.something/some-project-parent/1.14/
http://someurl/site/com.whatever.something/some-project-module/1.14/
The solution I have found is not DRY. It involves copy/pasting this distributionManagement section into every pom.xml.
Any ideas on how to stop this behavior? Thanks in advance!
I have an existing project, MainProject. I want to convert it to a multimodule project. In Eclipse I created a parent modul, which is just a pom modul and another modul, Modul_1.
Then I moved my MainProject in parent file directory. (Actually i did not want to move in parent folder. unfortunately to make it possible that Main_project finds the parent modul, i must do that)
Works fine..
It looks like:
-->ParentModule
------>Mainproject
------>Modul_1
Modul_1 is only needed in jenkins. It means the programmers should only care about MainProject.
How should I check in the project in SVN? With the same file structure or can i check in independently in SVN?
if the mainproject doesn't refer to ParentModule, you could layout it like this :
-->ParentModule
-->MainProject
-->Modul_1
in parentmodule's pom.xml :
<modules>
<module>../MainProject</module>
<module>../Modul_1</module>
</modules>
for jekins, there are 2 ways to configure job :
checkout parent folder and point pom's location to ParentModule/pom.xml
checkout 3 svn locations to each folder for 3 projects and point pom to ParentModule/pom.xml
for eclipse , you can checkout only MainProject.