Skip to content

Commit

Permalink
Disable all release variants in Glide.
Browse files Browse the repository at this point in the history
There’s no difference whatsoever in any of our configurations between
the two variants. As a result we’ve been building all of our code
and running all of our tests twice, which is slow and doesn’t add any
value. It’s a little weird to see that the jars we upload to maven are
based on ‘debug’ variants, but that should be fine since we do nothing
different for release vs debug builds.

We can’t default to the release build only because AndroidStudio and
other dev tools assume that the debug variant will be present.
  • Loading branch information
sjudd committed Jan 7, 2018
1 parent f84e461 commit 3968ccb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ subprojects { project ->
abortOnError false
}
}

android.variantFilter { variant ->
if(variant.buildType.name == 'release') {
variant.setIgnore(true)
}
}
}
}
}
Expand Down Expand Up @@ -113,7 +119,7 @@ subprojects { project ->
diffMaxViolations = 0

// Formats are listed here: https://github.com/tomasbjerre/violations-lib
def dir = projectDir.absolutePath;
def dir = projectDir.absolutePath
violations = [
["FINDBUGS", dir, ".*/findbugs/.*\\.xml\$", "Findbugs"],
["PMD", dir, ".*/pmd/.*\\.xml\$", "PMD"],
Expand Down
20 changes: 10 additions & 10 deletions glide/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def getInternalJavaProjectsForJavadoc() {
asProjects(getJavaPathsForJavadoc())
}

def getReleaseVariantAndroidProjectsForJar() {
getAndroidLibraryVariantsForJar('release')
def getAndroidProjectsForJar() {
getAndroidLibraryVariantsForJar('debug')
}

def getAndroidLibraryVariantsForJar(variantName) {
Expand Down Expand Up @@ -102,7 +102,7 @@ project.archivesBaseName = "${POM_ARTIFACT_ID}-${VERSION_NAME}"

// Generate javadocs and sources containing batched documentation and sources for all internal
// projects.
['release'].each { variantName ->
['debug'].each { variantName ->

task("${variantName}SourceJar", type: Jar) {
from getSourceFilesForVariantJar(variantName)
Expand Down Expand Up @@ -131,7 +131,7 @@ project.archivesBaseName = "${POM_ARTIFACT_ID}-${VERSION_NAME}"
// Finds dependencies of Android packages that would otherwise be
// ignored (Volley in particular)
getInternalAndroidProjectsForJavadoc().collect { Project project ->
project.file('build/intermediates/classes/release')
project.file('build/intermediates/classes/debug')
}
)
}
Expand Down Expand Up @@ -161,7 +161,7 @@ project.archivesBaseName = "${POM_ARTIFACT_ID}-${VERSION_NAME}"

jar {
from files(
getReleaseVariantAndroidProjectsForJar().collect { LibraryVariant variant ->
getAndroidProjectsForJar().collect { LibraryVariant variant ->
variant.getJavaCompiler().destinationDir
}
)
Expand All @@ -174,21 +174,21 @@ jar {

(getInternalAndroidProjectsForJar() + getInternalAndroidProjectsForJavadoc()).each {
project ->
releaseJavadoc.dependsOn(project.tasks.compileReleaseSources)
jar.dependsOn(project.tasks.compileReleaseSources)
debugJavadoc.dependsOn(project.tasks.compileDebugSources)
jar.dependsOn(project.tasks.compileDebugSources)
}

(getInternalJavaProjectsForJar() + getInternalJavaProjectsForJavadoc()).each {
project ->
releaseJavadoc.dependsOn(project.tasks.compileJava)
debugJavadoc.dependsOn(project.tasks.compileJava)
jar.dependsOn(project.tasks.compileJava)
}

artifacts {
archives releaseJavadocJar {
archives debugJavadocJar {
classifier 'javadoc'
}
archives releaseSourceJar {
archives debugSourceJar {
classifier 'sources'
}
}
2 changes: 1 addition & 1 deletion scripts/travis_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ set -e
-x :samples:gallery:build \
-x :samples:imgur:build \
-x :samples:svg:build \
-x testReleaseUnitTest --parallel
--parallel
16 changes: 8 additions & 8 deletions scripts/upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ afterEvaluate { project ->
def isAndroidProject = project.plugins.hasPlugin('com.android.application') || project.plugins.hasPlugin('com.android.library')

if (isAndroidProject) {
def releaseVariants = project.android.libraryVariants.findAll {
it.buildType.name.equalsIgnoreCase('release')
def variants = project.android.libraryVariants.findAll {
it.buildType.name.equalsIgnoreCase('debug')
}

def getAndroidSdkDirectory = project.android.sdkDirectory

def getAndroidJar = "${getAndroidSdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar"

task androidJavadocs(type: Javadoc, dependsOn: assembleRelease) {
source = releaseVariants.collect { it.javaCompile.source }
task androidJavadocs(type: Javadoc, dependsOn: assembleDebug) {
source = variants.collect { it.javaCompile.source }
classpath = files(
getAndroidJar,
project.file("build/intermediates/classes/release")
project.file("build/intermediates/classes/debug")
)
doFirst {
classpath += files(releaseVariants.collect { it.javaCompile.classpath.files })
classpath += files(variants.collect { it.javaCompile.classpath.files })
}
options {
links("http://docs.oracle.com/javase/7/docs/api/")
Expand Down Expand Up @@ -174,8 +174,8 @@ afterEvaluate { project ->
baseName "${JAR_PREFIX}${project.name}${JAR_POSTFIX}"
}

task androidLibraryJar(type: Jar, dependsOn: compileReleaseJavaWithJavac /* == variant.javaCompile */) {
from compileReleaseJavaWithJavac.destinationDir
task androidLibraryJar(type: Jar, dependsOn: compileDebugJavaWithJavac /* == variant.javaCompile */) {
from compileDebugJavaWithJavac.destinationDir
exclude '**/R.class'
exclude '**/BuildConfig.class'
exclude '**/R$*.class'
Expand Down

0 comments on commit 3968ccb

Please sign in to comment.