Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project name different from artifact-Id

Tags:

eclipse

maven

m2e

When I import Maven projects from my workspace and these projects are children of a parent project, they're imported with project name exactly like the artifact-id. But when I import a parent project, the project name is just like the directory name.

Example of directory structure:

project-parent (artifactId = project-application-parent)
--web (artifactId = project-webapp)
--core (artifactId = project-core)

When I import all projects my workspace looks like this:

project-parent
project-webapp
project-core

What I want is to parent project be named like his artifact-id (project-application-parent). Is there a way to achieve this?

like image 776
Diogo Moreira Avatar asked Sep 03 '13 14:09

Diogo Moreira


People also ask

What does artifact ID mean?

artifactId is the name of the jar without version. If you created it, then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar, you have to take the name of the jar as it's distributed.

What is difference between groupId and artifact ID?

3.1.groupId – a unique base name of the company or group that created the project. artifactId – a unique name of the project. version – a version of the project.

How do you name a groupId?

The name of the groupId element has to be in lower case. Use the reverse of a domain name that can be used to uniquely identify your project. This will also help to avoid collisions between artifacts produced by different projects. Avoid using digits or special characters (that is, org.


3 Answers

When you import maven project, click on 'Advanced' panel on the bottom of the import dialog and there you can choose an alternative name template.

The default is [artifactId], but you can choose, for example, [name] which is the content of the description tag from pom.

like image 109
9ilsdx 9rvj 0lo Avatar answered Sep 28 '22 17:09

9ilsdx 9rvj 0lo


It is possible setting the projectNameTemplate property in the configuration of the maven-eclipse-plugin, as in Documentation.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>x.y</version>
  <configuration>
    <projectNameTemplate>custom-project-name</projectNameTemplate>
  </configuration>
</plugin>
like image 32
Yohji Avatar answered Sep 28 '22 19:09

Yohji


One way to rename the project is directly editing the .project file. This is a XML file located in the project folder with basic eclipse information about the project.

Just change the node (it will only affect the project name in Eclipse)

like image 32
polypiel Avatar answered Sep 28 '22 17:09

polypiel