Skip to content

Commit

Permalink
SOLR-15603: Add an option to activate Gradle build cache, build task …
Browse files Browse the repository at this point in the history
…cleanups (apache#277)
  • Loading branch information
alextu committed Sep 6, 2021
1 parent 812de21 commit c3bef8c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
10 changes: 6 additions & 4 deletions gradle/documentation/render-javadoc.gradle
Expand Up @@ -188,11 +188,13 @@ configure(subprojects) {
}
}

@CacheableTask
class RenderJavadocTask extends DefaultTask {
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
@SkipWhenEmpty
SourceDirectorySet srcDirSet;

@OutputDirectory
File outputDir

Expand Down Expand Up @@ -258,10 +260,10 @@ class RenderJavadocTask extends DefaultTask {
public void render() {
def srcDirs = srcDirSet.srcDirs.findAll { dir -> dir.exists() }
def optionsFile = project.file("${getTemporaryDir()}/javadoc-options.txt")

// create the directory, so relative link calculation knows that it's a directory:
outputDir.mkdirs();

def opts = []
opts << [ '-overview', project.file("${srcDirs[0]}/overview.html") ]
opts << [ '-sourcepath', srcDirs.join(File.pathSeparator) ]
Expand Down Expand Up @@ -336,7 +338,7 @@ class RenderJavadocTask extends DefaultTask {
}
}
}

// Add offline links.
allOfflineLinks.each { url, dir ->
// Some sanity check/ validation here to ensure dir/package-list or dir/element-list is present.
Expand Down
5 changes: 5 additions & 0 deletions gradle/generation/local-settings.gradle
Expand Up @@ -55,6 +55,11 @@ org.gradle.jvmargs=-Xmx3g \\
org.gradle.parallel=true
org.gradle.priority=normal
# This setting enables local task output caches. This will speed up
# your local builds in most cases but will also consume disk space in your
# gradle home. See SOLR-15603 for details.
# org.gradle.caching=true
# Silence gradle warnings. We'll deal with them when we upgrade the wrapper.
org.gradle.warning.mode=none
Expand Down
9 changes: 7 additions & 2 deletions gradle/validation/check-broken-links.gradle
Expand Up @@ -29,22 +29,27 @@ configure(project(':solr:documentation')) {
check.dependsOn checkBrokenLinks
}

@CacheableTask
class CheckBrokenLinksTask extends DefaultTask {

// wraps input directory location in DirectoryProperty so as to lazily evaluate 'docroot' property
// (see gradle/documentation/documentation.gradle)
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
final DirectoryProperty docsDir = project.objects.directoryProperty()
.fileProvider(project.providers.provider { project.docroot })

@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
File script = project.rootProject.file("dev-tools/scripts/checkJavadocLinks.py")

@OutputFile
Provider<RegularFile> outputFile = project.layout.buildDirectory.file('check-broken-links-output.txt')

@TaskAction
def check() {
def outputFile = project.file("${getTemporaryDir()}/check-broken-links-output.txt")
def result
outputFile.withOutputStream { output ->
outputFile.get().asFile.withOutputStream { output ->
result = project.exec {
executable project.externalTool("python3")
ignoreExitValue = true
Expand Down
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Expand Up @@ -145,6 +145,8 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)

Other Changes
----------------------
* SOLR-15603: Add an option to activate Gradle build cache, build task cleanups (Alexis Tual, Dawid Weiss)

* SOLR-14656: Autoscaling framework removed (Ishan Chattopadhyaya, noble, Ilan Ginzburg)

* SOLR-14616: CDCR support removed (Ishan Chattopadhyaya)
Expand Down
11 changes: 7 additions & 4 deletions solr/solr-ref-guide/build.gradle
Expand Up @@ -184,6 +184,7 @@ ext {
group "Documentation"
description "Builds the ${details.desc}"

outputs.cacheIf { true }
inputs.dir contentDir
outputs.dir htmlDir

Expand Down Expand Up @@ -215,20 +216,22 @@ check.dependsOn checkLocalJavadocLinksSite, checkSite
// Hook site building to assemble.
assemble.dependsOn buildSite

class PrepareSources extends DefaultTask {
@CacheableTask
abstract class PrepareSources extends DefaultTask {
// Original Source files we'll be syncing <b>FROM</b>
@InputDirectory
final DirectoryProperty srcDir = project.objects.directoryProperty()
@PathSensitive(PathSensitivity.RELATIVE)
abstract DirectoryProperty getSrcDir()

// Destination folder.
@OutputDirectory
final DirectoryProperty outDir = project.objects.directoryProperty()
abstract DirectoryProperty getOutDir()

/**
* Task specific props (lazy provider)
*/
@Input
final MapProperty<String, String> props = project.objects.mapProperty(String, String)
abstract MapProperty<String, String> getProps()

public PrepareSources() {
// setup 'dependsOn classes, configurations.depVer' here
Expand Down

0 comments on commit c3bef8c

Please sign in to comment.