Skip to content

Commit

Permalink
Initial gradle build layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dweiss committed Dec 2, 2019
1 parent 71f1bc3 commit d4a9842
Show file tree
Hide file tree
Showing 89 changed files with 3,132 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore all differences in line endings for the lock file.
versions.lock text eol=lf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ __pycache__
/dev-tools/scripts/scripts.iml
.DS_Store

build/
.gradle/
.idea/
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: java

jdk:
- openjdk11

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

script:
- ./gradlew assemble --scan --stacktrace -Ptravis

49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id "base"
id "com.palantir.consistent-versions" version "1.12.4"
id "com.gradle.build-scan" version "3.0"
}

// Project version and main properties. Applies to all projects.
allprojects {
version = "9.0.0-SNAPSHOT"
}

// Include smaller chunks configuring dedicated build areas.
// Some of these intersect or add additional functionality.
// The order of inclusion of these files shouldn't matter (but may
// if the build file is incorrectly written and evaluates something
// eagerly).

// CI systems.
apply from: file('gradle/buildscan.gradle')
apply from: file('gradle/travis.gradle')

// Set up defaults and configure aspects for certain modules or functionality
// (java, tests)
apply from: file('gradle/defaults.gradle')
apply from: file('gradle/defaults-java.gradle')
apply from: file('gradle/testing/defaults-tests.gradle')
apply from: file('gradle/testing/defaults-tests-solr.gradle')
apply from: file('gradle/testing/randomization.gradle')
apply from: file('gradle/defaults-maven.gradle')

// IDE settings and specials.
apply from: file('gradle/defaults-idea.gradle')

// Additional development aids.
apply from: file('gradle/maven-local.gradle')
apply from: file('gradle/testing/per-project-summary.gradle')
apply from: file('gradle/testing/slowest-tests-at-end.gradle')
apply from: file('gradle/help.gradle')

// Ant-compatibility layer. ALL OF THESE SHOULD BE GONE at some point. They are
// here so that we can coexist with current ant build but they are indicative
// of potential problems with the build conventions, dependencies, etc.
apply from: file('gradle/ant-compat/folder-layout.gradle')
apply from: file('gradle/ant-compat/misc.gradle')
apply from: file('gradle/ant-compat/resolve.gradle')
apply from: file('gradle/ant-compat/post-jar.gradle')
apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')
apply from: file('gradle/ant-compat/artifact-naming.gradle')

52 changes: 52 additions & 0 deletions gradle.TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

The gradle build is currently missing or could use some love in the following areas:

- Apply forbiddenAPIs

- configure security policy/ sandboxing for tests (!).

- add test 'beasting' (rerunning the same suite multiple times). I'm afraid it'll be difficult
to run it sensibly because gradle doesn't offer cwd separation for the forked test runners (?)

- jar checksums, jar checksum computation and validation.
this should be done without intermediate folders (directly
on dependency sets).

- add a :helpDeps explanation to how the dependency system works (palantir plugin, lockfile) and
how to retrieve structured information about current dependencies of a given module
(in a tree-like output).

- identify and list precommit tasks so that they can be ported one by one.

- identify and port any other "check" utilities that may be called from ant.

- identify and port various "regenerate" tasks from ant builds (javacc, precompiled automata, etc.)

- add rendering of javadocs (gradlew javadoc) and attaching them to maven publications.

- fill in POM details in gradle/defaults-maven.gradle so that they reflect the previous content better
(dependencies aside).

- Add any IDE integration layers that should be added (I use IntelliJ and it imports the project
out of the box, without the need for any special tuning).

- Clean up dependencies, especially for Solr: any { transitive = false } should just explicitly
exclude whatever they don't need (and their dependencies currently declared explicitly
should be folded). Figure out which scope to import a dependency to.

- add Solr packaging for docs/* (see TODO in packaging/build.gradle; currently XSLT...)

- I didn't bother adding Solr dist/test-framework to packaging (who'd use it from a binary
distribution?)

Intentional differences:

- the back-compatibility target 'resolve' is added to gradle but it's really for informational purposes
and debugging. Packaging should be done from subcomponent configurations and dependencies,
not from source folders... "gradlew -p packaging assemble" puts together the entire Solr distribution
under packaging/build where it doesn't interfere with sources.

'resolve' for Lucene also does *not* copy test dependencies under lib/ (like ant version does).

- transitive export of certain core libraries from solr-core/ solrj (guava, etc.).

4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
systemProp.file.encoding=UTF-8

org.gradle.parallel=true
org.gradle.priority=low
15 changes: 15 additions & 0 deletions gradle/ant-compat/artifact-naming.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Stick to previous artifact names (not identical to path/ folders).
configure(subprojects.findAll { it.path.contains(':solr:contrib:') }) {
project.archivesBaseName = project.archivesBaseName.replace("-contrib-", "-")
}

// This project has a different artifact name (solr-contrib-cell). Don't know why.
configure(project(":solr:contrib:extraction")) {
archivesBaseName = "solr-cell"
}

configure(subprojects.findAll { it.path.contains(':lucene:analysis:') }) {
project.archivesBaseName = project.archivesBaseName.replace("-analysis-", "-analyzers-")
}


26 changes: 26 additions & 0 deletions gradle/ant-compat/folder-layout.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Adapt to custom folder convention.
allprojects {
plugins.withType(JavaPlugin) {
sourceSets {
main.java.srcDirs = ['src/java']
main.resources.srcDirs = ['src/resources']
test.java.srcDirs = ['src/test']
test.resources.srcDirs = ['src/test-files']
}

task copyTestResources(type: Copy) {
from('src/test') {
exclude '**/*.java'
}
into sourceSets.test.java.outputDir
}
processTestResources.dependsOn copyTestResources
}
}

// Adapt to custom 'web' folder location.
configure(project(":solr:webapp")) {
plugins.withType(WarPlugin) {
webAppDirName = "web"
}
}
42 changes: 42 additions & 0 deletions gradle/ant-compat/misc.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

// Exclude inner classes from testing.
allprojects {
tasks.withType(Test) { task ->
exclude '**/*$*'
}
}

// Exclude test classes that are not actually stand-alone tests (they're executed from other stuff).
configure(project(":lucene:replicator")) {
plugins.withType(JavaPlugin) {
test {
exclude "**/SimpleServer*"
}
}
}


// Resources from top-level project folder are looked up via getClass(). Strange.
configure(project(":lucene:benchmark")) {
plugins.withType(JavaPlugin) {
task syncConf(type: Sync) {
from('conf')
into file("${sourceSets.test.java.outputDir}/conf")
}
processTestResources.dependsOn syncConf
}
}

// lucene:replicator has httpclient dependency with transitive commons-logging:1.2 but currently
// requires 1.1.2. This commons-logging should be removed entirely and replaced with slf4j-to-*
// redirector.
configure(project(":lucene:replicator")) {
plugins.withType(JavaPlugin) {
configurations.all {
resolutionStrategy {
force 'commons-logging:commons-logging:1.1.3'
}
}
}
}

34 changes: 34 additions & 0 deletions gradle/ant-compat/post-jar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This adds a configuration and artifact to solr-core which exports "post.jar" tool.
// this should be a separate project instead (it is self-contained and classes are reused
// in many places).

configure(project(":solr:core")) {
plugins.withType(JavaPlugin) {
configurations {
postJar
}

task assemblePostJar(type: Jar) {
dependsOn classes

archiveFileName = "post.jar"
destinationDirectory = file("${buildDir}/postJar")

from(sourceSets.main.output, {
include "org/apache/solr/util/CLIO.class"
include "org/apache/solr/util/SimplePostTool*.class"
include "org/apache/solr/util/RTimer*.class"
})

manifest {
attributes("Main-Class": "org.apache.solr.util.SimplePostTool")
}
}

artifacts {
postJar assemblePostJar
}

assemble.dependsOn assemblePostJar
}
}
Loading

0 comments on commit d4a9842

Please sign in to comment.