DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Working on an Unfamiliar Codebase
  • Front-End: Cache Strategies You Should Know
  • Redefining DevOps: The Transformative Power of Containerization
  • TDD vs. BDD: Choosing The Suitable Framework
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Gradle Goodness: Download Javadoc Files For Dependencies In IDE

Gradle Goodness: Download Javadoc Files For Dependencies In IDE

By default, sources of a dependency are downloaded and added to a project, but not Javadoc sources. Gradle can use IntelliJ IDEA and Eclipse project files to download them.

Mohammed Rahmatullah user avatar by
Mohammed Rahmatullah
·
Oct. 03, 15 · Tutorial
Like (5)
Save
Tweet
Share
17.87K Views

Join the DZone community and get the full member experience.

Join For Free

Gradle has an idea and eclipse plugin that we can use to configure IntelliJ IDEA and Eclipse project files. When we apply these plugins to our project we get extra tasks to generate and change project files. Inside our Gradle build file we get new configuration blocks to specify properties or invoke methods that will change the configuration files. One of the nice things to add is to let the IDE download Javadoc files for dependencies in our Java/Groovy projects. By default the sources for a dependency are already downloaded and added to the project, but Javadoc files are not downloaded.

In the example build file we use the idea and eclipse plugins. We also add an idea and eclipse configuration block. The place where we need to set the property downloadJavadoc is a bit different, but the end result will be the same.

// File: build.gradle
apply {
    plugin 'java'
    plugin 'idea'
    plugin 'eclipse'
}

idea {
    module {
        downloadJavadoc = true
    }
}

eclipse {
    classpath {
        downloadJavadoc = true
    }
}

repositories {
    jcenter()
}

dependencies {
    compile 'org.springframework:spring-context:4.2.1.RELEASE'
}

For example to create the correct files for IntelliJ IDEA we run the task:

<library name="Gradle: org.springframework:spring-beans:4.2.1.RELEASE">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.2.1.RELEASE/6d39786b9f7b2a79897a0a83495f30002d9f8de3/spring-beans-4.2.1.RELEASE.jar!/" />
</CLASSES>
 <JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.2.1.RELEASE/d7789802c418cd04462f0e2f00cf812912bea33d/spring-beans-4.2.1.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.2.1.RELEASE/5d017016084ccea18af667cf65e2927800967452/spring-beans-4.2.1.RELEASE-sources.jar!/" />
</SOURCES>
</library>


When we run the eclipse task all Eclipse project files are generated. If we look in the generated .classpath file we see for example that the location for the Javadoc files is added:

<classpathentry sourcepath="/Users/mrhaki/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.2.1.RELEASE/676729ef55bb886663ed5454eb61d119ef712f17/spring-context-4.2.1.RELEASE-sources.jar" kind="lib" path="/Users/mrhaki/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.2.1.RELEASE/5bf6dec08e77755c2ec913fde1b8e29083e70a76/spring-context-4.2.1.RELEASE.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Users/mrhaki/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.2.1.RELEASE/8d9edd93ea9d918b0895eb6fd4d1c69b301de449/spring-context-4.2.1.RELEASE-javadoc.jar!/"/>
</attributes>
</classpath>
Integrated development environment Javadoc intellij Dependency Gradle Download

Published at DZone with permission of Mohammed Rahmatullah. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Working on an Unfamiliar Codebase
  • Front-End: Cache Strategies You Should Know
  • Redefining DevOps: The Transformative Power of Containerization
  • TDD vs. BDD: Choosing The Suitable Framework

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: