0

I am using Eclipse and Maven to create a Maven package that is uploaded to MyGet to be consumed by other users. I would like to make it so that when my package is referenced as a dependency and therefore downloaded from MyGet, the source attachment is also downloaded.

I've seen this happen with, for example, the JOGL library - when my Maven project in Eclipse references JOGL, I end up with the following files in the ~/.m2/repository subdirectory associated with JOGL (among others):

  • jogl-all-main-2.3.2.jar
  • jogl-all-main-2.3.2-sources.jar

And in Eclipse, if I right click on the jogl-all-main-2.3.2.jar library and choose Properties, it shows the source attachment as jogl-all-main-2.3.2-sources.jar located in my .m2 folder. I don't believe that I did anything to select that file as the source attachment; I think it happened automatically.

When I upload my package to MyGet, it allows me to upload one or more jar files, but it expects each jar file to be a Maven package including a pom.xml file, so I can't upload the sources jar file to MyGet directly.

Perhaps this is a limitation of MyGet, in that it doesn't allow me to upload the sources in parallel. I'm not familiar enough with Maven to know if it's something that I need to specify in the pom.xml for my package.

udalmik
  • 7,838
  • 26
  • 40
ryanmcfall
  • 585
  • 1
  • 6
  • 20
  • Please check [this answer](https://stackoverflow.com/questions/4725668/how-to-deploy-snapshot-with-sources-and-javadoc). I believe MyGet should support standard Maven's **mvn clean javadoc:jar source:jar deploy** command – udalmik Oct 21 '20 at 19:47
  • @udalmik So are you suggesting that using `mvn` to deploy rather than MyGet's web interface will allow me to deploy the jar file containing the sources? – ryanmcfall Oct 21 '20 at 20:04
  • yes, I would try this way, with adding your MyGet repo to config – udalmik Oct 21 '20 at 22:20
  • @udalmik This seems like a good way to go. I've gotten `maven deploy` to successfully push the package up to the repository. But it's not uploading the sources / javadocs. Should I deploy these using the `deploy-file` command separately, or is there a way to make it happen automatically when the `deploy` command is executed? – ryanmcfall Oct 22 '20 at 16:44
  • @udalmik: I was able to get this to work using `mvn deploy` instead of using MyGet's GUI to upload packages. If you want to write up an answer, I will mark it as the apporoved answer. – ryanmcfall Oct 26 '20 at 19:58

1 Answers1

0

Please check this answer. I believe MyGet should support standard Maven's command:

mvn clean javadoc:jar source:jar deploy 

So please try configure your MyGet's repo as registry and upload your packages using Maven's CLI intead of MyGet's GUI.

udalmik
  • 7,838
  • 26
  • 40