Bug #75335 Maven artifact for Connector/J is missing source jar
Submitted: 29 Dec 2014 21:53 Modified: 1 Jun 2015 19:27
Reporter: David Phillips Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.34 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[29 Dec 2014 21:53] David Phillips
The mysql-connector-java artifact in Maven central is missing the source jar that corresponds to the binary jar. Having the source jar allows tools like IDEs to automatically download the source. This is very useful when debugging, looking at stack traces, etc.

How to repeat:
Notice that only the .pom and .jar exist here:

Compare to the PostgreSQL driver with the -sources.jar:
[30 Dec 2014 5:51] MySQL Verification Team
Hello David Phillips,

Thank you for the report.

[30 Dec 2014 21:28] Todd Farmer
An observation:  Starting with 5.1.34, the source appears to be found in the src directory:


This is different than 5.1.33, where the source is found in the root directory, and the src directory is empty:


However, 5.1.33 appears to be an anomaly; earlier packages mirror the 5.1.34 structure, putting the source in the src directory instead of root.  So something changed in 5.1.33, but it seems to have changed *back* to previous layout in 5.1.34.

None of this entirely explains why changes happened, and it suggests we need to reconcile the request to package the source JAR in the root directory with our (non-standard?) practice of putting it in the src directory.
[7 Jan 2015 2:05] David Phillips
I can't seem to find a specification, but in order to work with standard tools such as IDEs, the artifacts need to be produced EXACTLY as if they were produced by Maven.

* The source jar must be a .jar with -sources before the .jar suffix. Example: mysql-connector-java-5.1.34-sources.jar
* There is no metadata or other way to indicate the name of the source jar or the layout. Thus, it must be named correctly according to the convention.
* The source tree inside the source jar must be in the root of the jar without any prefix and laid out in a directory structure that matches the Java package structure. In other words, it should be the same layout that javac expects, and should be 1:1 with the class files in the binary jar.

Example from the PostgreSQL driver:

$ jar tf postgresql-9.3-1102-jdbc41.jar | grep BaseResultSet

$ jar tf postgresql-9.3-1102-jdbc41-sources.jar | grep BaseResultSet

Some relevant Maven links:

[7 Jan 2015 2:14] David Phillips
Regarding a specification, I've heard that the layout of source jar content actually comes from src.zip that ships with the JDK (and has since the early days of Java).
[1 Jun 2015 19:27] Daniel So
Added the following entry to the Connector/J 5.1.36 changelog:

"The files in the Maven Central Repository for each Connector/J release have been reorganized and a source artifact (*-sources.jar) has been added, for release 5.1.21 and after."