# Make it easy to publish source and api documentation archives

**URL:** <https://discuss.gradle.org/t/make-it-easy-to-publish-source-and-api-documentation-archives/261>\
**Category:** Old Forum Archive\
**Created:** [November 27, 2011, 9:17pm UTC](https://discuss.gradle.org/t/make-it-easy-to-publish-source-and-api-documentation-archives/261 "2011-11-27T21:17:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adammurdoch](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/adammurdoch/32/17_2.png) [@adammurdoch](https://discuss.gradle.org/u/adammurdoch)\
**Post date:** [November 27, 2011, 9:17pm UTC](https://discuss.gradle.org/t/make-it-easy-to-publish-source-and-api-documentation-archives/261/1 "2011-11-27T21:17:00Z")

</div>

Many projects publish their source and api documentation as zip or jar archives that are published to a repository along with their jar. It would be nice to offer a declarative means of doing this.

## Implementation ideas

One approach is to extend the java plugin to add ‘sourceZip’ and ‘javadocZip’ tasks. This way, you can easily publish them in your build script:

```gradle
apply plugin: 'java' // or 'groovy' or 'scala'...
  artifacts {
    archives sourceZip, javadocZip
}

```

## Extra credit

Some ideas to build on this:

- Add support for groovydoc and scaladoc archives. \* Extend the application and [java-library](http://forums.gradle.org/gradle/topics/build_a_distribution_for_a_java_or_jvm_based_library) plugins to include the source in the distribution, when the source is to be published. \* Do the same for api documentation, so that it is included in the distribution, when the api documentation is to be published. \* Make this work with ivy repositories.

---

<div class="post-metadata">

**Author:** ![Adam\_R](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Adam\_R](https://discuss.gradle.org/u/Adam_R)\
**Post date:** [February 25, 2013, 3:31am UTC](https://discuss.gradle.org/t/make-it-easy-to-publish-source-and-api-documentation-archives/261/2 "2013-02-25T03:31:00Z")

</div>

I am going to try and complete this task as a way to get my feet wet with Gradle plugin development. I have a preliminary fix done for the java plugin: [https://github.com/AdamRoberts/gradle/commit/f23158c69315e24886082724e6a12b414e34cf6f](https://github.com/AdamRoberts/gradle/commit/f23158c69315e24886082724e6a12b414e34cf6f)

But I have some questions before I can finish the java plugin changes and start on the extra credit.

- Should there be the option to publish a jar archive also? It seems a 50/50 split on if sources are published in a zip or a jar (I am used to publishing in a jar). I know that we would not be able to easily switch from publishing “snapshots” of our source from zip to jar, you could end up with the resolved “source” artifact being out of sync with the “byte code” artifact if the wrong extension was resolved.

- How many integration tests should be written? I assume that test should be added to ‘subproject/integ-test/src/integTest/groovy/org/gradle/integtests/JavaProjectIntegrationTest.groovy’, but I am not sure to what extent tests are expected, are the integration test mainly to cover happy path, or should they check everything. From the existing tests for the “jar” archive it appears that only the happy path is tested.
