diff --git a/src/genjava/templates/genjava_project/build.gradle.in b/src/genjava/templates/genjava_project/build.gradle.in
index 20681fb..920270a 100644
--- a/src/genjava/templates/genjava_project/build.gradle.in
+++ b/src/genjava/templates/genjava_project/build.gradle.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 %(author)s
+ * Copyright (C) 2014, 2018 %(author)s
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
@@ -55,6 +55,30 @@ task generateSources (type: JavaExec) {
     tasks.compileJava.source outputs.files
 }
 
+task docsJar(type: Jar, dependsOn: 'javadoc') {
+  description = 'Archive JavaDoc for %(project_name)s'
+  from javadoc.destinationDir
+  classifier = 'javadoc'
+}
+
+task sourceJar(type: Jar, dependsOn: 'classes') {
+  description = 'Archive Source files for %(project_name)s'
+  from sourceSets.main.allSource
+  classifier = 'sources'
+}
+
+publishing {
+  publications {
+    mavenJava(MavenPublication) {
+      // compiled classes jar is published to maven by default
+      // also publish -sources.jar
+      artifact sourceJar
+      // also publish -javadoc.jar
+      artifact docsJar
+    }
+  }
+}
+
 dependencies {
     compile 'org.ros.rosjava_bootstrap:message_generation:[0.2,0.3)'
     %(msg_dependencies)s