質問

My team is new to Maven and we haven't been able to find any definitive guidance on selecting artifactIDs for our projects.

I know that the Guide to naming conventions says that artifactIDs should be

"whatever name you want with lowercase letters and no strange symbols"

but some folks in my group want to use the reverse domain name style for both groupIDs and artifactIDs.

Based on the above-mentioned guidelines plus all the examples that I've seen in the central repository I don't think it makes sense to have reverse domain style artifactIDs but I can't tell if doing so is actually invalid or merely frowned upon. I vaguely remember reading something about various repository managers not being able to deal effectively with artifactIDs that contain period (.) characters but I don't remember where I read that & I can't find it now.

What are the rules, if any, on the characters allowed in a Maven artifactID?

役に立ちましたか?

解決

As a beggining here some posts dealing with this subject :

Pointers

And on Stack Overflow !

Then, I would suggest you to NOT use groupId in you artifactId. This is redundant ;).

I quote the sonatype docs that seems to be the most relevant for your question :

Sonatype Naming Conventions

groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. eg. org.apache.maven, org.apache.commons A good way to determine the granularity of the groupId is to use the project structure. That is, if the current project is a multiple module project, it should append a new identifier to the parent's groupId. eg. org.apache.maven, org.apache.maven.plugins, org.apache.maven.reporting

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.eg. maven, commons-math

version if you distribute it then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...). Don't use dates as they are usually associated with SNAPSHOT (nightly) builds. If it's a third party artifact, you have to use their version number whatever it is, and as strange as it can look.eg. 2.0, 2.0.1, 1.3.1

So using reverse dns in you groupId AND your package name is a good pratice. Use them again in artifactId is not.

他のヒント

I would argument that the groupId is like the package name in Java where the artifactId is similar to the class name (ok not really) but I think there is a relationship to the class name. In Maven you usually give a name to a module/project which is in particular the artifactId.

Furthermore I found some hints about the artifactId here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top