Tomáš Zato
Tomáš Zato

Reputation: 53226

What does the "com" mean in Maven group id? Is it necessary?

In a school project, we are supposed to use maven enabled project. Maven is a great system for managing dependencies, so I'm quite happy I'll finally learn to use it.

However I already started project as Netbeans project and I'm now struggling how to reconfigure it. When creating the project IDE advised me to call it com.myname. This resulted in redundant empty folder com/myname/{sources start here}. Windows explorer isn't as smart as GitHub and doesn't skip empty folder which makes it very annoying.

I'm strongly considering that I'll call the project just myname. Is that valid? What are the risks of breaking this convention? Where did this convention come from and what does com abbreviation mean?

Upvotes: 2

Views: 5009

Answers (4)

dildeepak
dildeepak

Reputation: 1389

Well, it just a Java Convention. Ideally com refers to Commercial, which is used for commercial purpose.

You can use anything instead of com, like org. or edu.

   <groupId>org.codehaus.mojo</groupId>
    <artifactId>parent</artifactId>
    <version>1.0</version>

But going forward in your future, you will certainly need to follow the same code structure. So, how about practicing from college project itself.

Upvotes: 1

Jens Schauder
Jens Schauder

Reputation: 81970

com is part of a reverse domain. So if your domain is

somecompany.com your maven artefacts should be named com.somecompany.awesomeThingy

This makes sure we don't get name clashes when I publish my

com.someothercompany.awesomeThingy

This is also the naming convention for java packages.

All this doesn't really matter as long as your maven repos are private. Once you intend to publish artifacts to maven central though, there are rules enforcing that you name artifacts using a domain you control.

And of course there are other TLDs around, so org, de and many more are options too.

Upvotes: 5

Jesper
Jesper

Reputation: 206896

It's just part of a Java package name.

Package names in Java look like domain names, but in reverse order. For example if someone is working for "somecompany.com" then he or she will usually use the package name com.somecompany.someproduct.

This is just the convention in the Java world. It's not required to adhere to this convention.

Upvotes: 1

meskobalazs
meskobalazs

Reputation: 16031

Of course it is valid. Eclipse recommends this, because it usally makes sense for an organization. For a school project, not so much.

Anyway, this is a common convention in the Java world, you should get used to it :)

Upvotes: 1

Related Questions