Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

4.1 KB
Raw Blame
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

configure(rootProject) {
  def urlVersion = project.baseVersion.replace('.', '_')
  def refguideUrlVersion = project.baseVersion.replaceFirst(/^(\d+)\.(\d+).*$/, '$1_$2')

  ext {
    // NOTE: The actual dependency version isn't available at configuration time, so we use a lazy property provider to
    // supply it at execution time.
    //
    // In the case of a 'SNAPSHOT' luceneDocVersion this URL won't actually exist, but that shouldn't matter since
    // we can't release Solr pointed at a Lucene SNAPSHOT, so we won't be publishing in this state...
    luceneDocUrl = project.propertyOrDefault('lucene.javadoc.url',
        "https://lucene.apache.org/core/${-> luceneBaseVersionProvider.get().replace('.', '_')}")

    solrDocUrl = project.propertyOrDefault('solr.javadoc.url', {
      if (project.version != project.baseVersion) {
        // non-release build does not cross-link between modules.
        return null
      } else {
        // release build
        "https://solr.apache.org/docs/${urlVersion}"
      }
    }())

    solrRefguideUrl =
        project.propertyOrDefault('solr.refguide.url',
            "https://solr.apache.org/guide/solr/${refguideUrlVersion}")
  }

  task documentation() {
    group = 'documentation'
    description = 'Generate all documentation'

    dependsOn ':solr:documentation:documentation'
  }
}

// docroot will point to Lucene and Solr relative directory for each sub-project.
configure(project(':solr:documentation')) {
  ext {
    docroot = file("${buildDir}/site")

    markdownSrc = file("src/markdown")
    assets = file("src/assets")
  }

  task documentation() {
    group = 'documentation'
    description = "Generate ${project.name.capitalize()} documentation"

    dependsOn project.parent.subprojects.collect {prj ->
      prj.tasks.matching {it.name == 'renderSiteJavadoc'}
    }
    dependsOn 'changesToHtml', 'copyDocumentationAssets',
        'markdownToHtml', 'createDocumentationIndex'
  }

  // Javadoc references are validated at compile time by DocLint
  // (gradle/java/javac.gradle). Building the full documentation is costly, so
  // this project's check builds it only on CI, where it also exercises
  // references that only the javadoc tool sees, such as those in overview
  // files, and the missing-doclet checks. The gate covers this project's
  // check path only; a root check still builds the site through the ref
  // guide's checkSiteLinks task, when the ref guide is included
  // (refguide.include, on by default when a .git directory exists).
  //
  // Overview references are checked when the render tasks run. overview.html
  // is not a declared input of the render task, so in a reused workspace an
  // overview-only change can leave the task up-to-date and unchecked. A
  // fresh CI checkout runs it: the build cache is off on CI.
  if (isCIBuild) {
    check.dependsOn 'documentation'
  }

  task copyDocumentationAssets(type: Copy) {
    includeEmptyDirs = false
    from(project.assets)
    into project.docroot
  }

  configurations {
    // Not part of 'assemble': only built on demand (e.g. by the release process or the ref guide build).
    site {
      visible = false
    }
  }

  artifacts {
    site project.docroot, {
      builtBy documentation
    }
  }
}

configure(project(":solr")) {
  ext {
    docroot = project('documentation').docroot
  }
}