0

Is there a way to find from Maven in what artifact will a given class be placed?

For some context of what I'm doing: I have a class in a Maven project that I was expecting to be present in an artifact but when I try to use that artifact in another project it doesn't compile because it doesn't find the class. I can do a search in the jar files and find where the class file is. But Maven has this information already from the configuration of the first project.

So my question is if there is any maven command or plugin that could tell me in what artifact a given class is going to be added

wi2ard
  • 1,471
  • 13
  • 24
  • I do not really understand the problem. You build an artifact from Maven project. Then the classes from that project go to that artifact. – J Fabian Meier Aug 13 '20 at 10:52
  • The problem IMO is less important, the question can be pure theoretical. But there can be factors complicating things: the class can go in the jar or the test-jar artifact, it can be excluded from the artifact [one way or another](https://stackoverflow.com/questions/30023509/i-wish-to-exclude-some-class-files-from-my-jar-i-am-using-maven-assembly-plugin) etc – wi2ard Aug 13 '20 at 11:12
  • Possibly the class is loaded from multiple jars. Welcome to jar hell. – Silviu Burcea Aug 13 '20 at 11:33

1 Answers1

0

No.

But usually, everything under src/main/java is compiled then goes to the JAR or WAR that is generated, following the package structure inside src/main/java.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • I am not sure about this. Maven has this information inside the poms... Just like the information about the dependency tree and this one can be displayed... Thanks, anyway – wi2ard Aug 13 '20 at 11:41
  • 1
    Sure, you can probably write a Maven plugin that tries to track this. – J Fabian Meier Aug 13 '20 at 11:52