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:
None 
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
Description:
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:
http://search.maven.org/#artifactdetails%7Cmysql%7Cmysql-connector-java%7C5.1.34%7Cjar

Compare to the PostgreSQL driver with the -sources.jar:
http://search.maven.org/#artifactdetails%7Corg.postgresql%7Cpostgresql%7C9.3-1102-jdbc41%7...
[30 Dec 2014 5:51] MySQL Verification Team
Hello David Phillips,

Thank you for the report.

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

http://search.maven.org/#browse|1323038574
http://search.maven.org/#browse|2070528547

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

http://search.maven.org/#browse|2070528516
http://search.maven.org/#browse|1294409423

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
org/postgresql/core/BaseResultSet.class

$ jar tf postgresql-9.3-1102-jdbc41-sources.jar | grep BaseResultSet
org/postgresql/core/BaseResultSet.java

Some relevant Maven links:

http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-sources-javadoc.htm...
http://maven.apache.org/plugin-developers/cookbook/attach-source-javadoc-artifacts.html
http://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html
[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."