3

We made a number of releases to our nexus repository without source jars attached. I would like to backfill the source jars for these releases.

What I tried to do was

  1. checkout the tagged version that I wanted to upload sources for
  2. update the pom with the attach-sources snippet
  3. do a maven deploy

This failed with a 400 error code because the pom and artifact jar were already in the repository.

Is there any way to upload just the source jar?

Caoilte
  • 2,381
  • 1
  • 21
  • 27
  • Can you delete/rename the old version and try again? Why not release one new version with the source? (Technically its a different release with the source) – Peter Lawrey Jun 03 '11 at 15:19
  • I don't have the permissions. Releasing a new version seemed in-elegant. I don't think it's a different version. – Caoilte Jun 03 '11 at 19:21

2 Answers2

4

you should be able to do this using maven deploy-file (this has the added benefit of generating the various file sums as well), details here (you would be using, among other things, "packaging=jar" and "classifier=source").

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • 1
    Shouldn't this be "classifier=sources" (plural)? – Andrew Swan Feb 09 '17 at 22:52
  • This worked for me. A trap for young players seems to be that this goal's "repositoryId" parameter needs to be set to the ID of a entry in your settings.xml, not the ID of a repository as you might think. – Andrew Swan Feb 09 '17 at 23:36
  • 1
    This in fact works. It is a bit confusing, as the actual artifact file has to be specified as well. However, when `classifier=source` is specified, the `-Dsources=artifact-source.jar` file is uploaded first. Then the 400 error occurs, but the file is uploaded. The same is true for `-Dclassifier=javadoc`. – kap May 13 '20 at 20:18
1

I think the simplest thing would be to just upload sources jar using 'curl'. You will not even need to make any changes for that.

Alex Gitelman
  • 24,429
  • 7
  • 52
  • 49
  • This. You'll spend more time fiddling with Maven and it's documentation than it is worth. Just upload the source jars by hand. Heck, if you can get access, SCP works just fine too. – rfeak Jun 03 '11 at 18:47
  • I would love to mark that as the answer, but I'm not sure what the curl command should be. – Caoilte Jun 03 '11 at 19:22
  • @Caoilte try `curl --data-binary @target/yourpackage-version-sources.jar ` Url to post to depends on your repository. It may be http or ftp. You may need to give curl -A flag if repository does not like default agent. You will need to do some trial and error. Do `man curl`. That will work on Linux. On Windows you will need cygwin or use different tool. – Alex Gitelman Jun 03 '11 at 19:38