Skip to content

Commit

Permalink
Finish revamping build scripts/dokka/dependencies (InflationX#38)
Browse files Browse the repository at this point in the history
Finally got dokka working correctly/ This also updates/fixes dependencies, filters unnecessary variants/buildconfig generation, and moves internal files to a .internal package to exclude from dokka
  • Loading branch information
ZacSweers authored and jbarr21 committed Apr 2, 2019
1 parent 12c542f commit 2bbc15a
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ cache:
directories:
- $HOME/.gradle

branches:
only:
- master

env:
global:
- secure: RcG2qYr5r6qU7aIrdFaqSvrCC7HmqDdBqyACGfRz184RW7/9TOXvKTRTkX+edHMbc96ItTh2lH4A/r5T7pUCtCoy9sprMHqN24R11PJgfuoAuFkOycOXhp/gXf3wqVBjcLJ7HC+aIZB68j0E8cgU/sayKltrd6nEgv9gd94S2sZ65ObCpt3KASplh2Xe47ORwmLuEVePiPXiQ6RyETouHoPqVn8Kz36jPzZ6lyPASYU5qWRk1N/5NNB8bx1EvUk8g/IueH7B0S6GWwuFuSqrAx+bDbOimemc2tgMjG/y90PiPGupX+ZJiqpmOE0KwQC23wd06ILmf61PkljS5hPyAc7asQQQ/1LaWobkEklenbmyVvilWTWKVGrRYer5sdu47lnZwvLWqLo1lS3R1sOEc3SGy6OBg8NZMPqNaT8axpLi8kE9PA5gS3sJNQtCQzFgGkBwzdmp12afGGW3is5ZKl5B0nhrtFGBuem8y/DPsPTmK5j+zAtS1/4JoGuLDjfX8cjrZ2KcPKO89aWjg+WPZaC6ebV1+WB7RFo6bT0uQvxjKm5PDBEMZtQKY+dMPvEDzCNB7LAG5X0za/1HDwEPk2Xi1ntONtEj1LP9SG+RRvZ124+erdGtq4yn6A7X2T9dtkp8uuJOAmmE4RSlxe8SLwtK4x3aOKuok6hkkLpMSYo=
Expand Down
1 change: 1 addition & 0 deletions ViewPumpSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {

buildTypes {
debug {
matchingFallbacks = ['release']
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ buildscript {
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/" // For maven publish plugin until 0.8.0 is released
// For maven publish plugin until 0.9.0 is released
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.9.17'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.9.0-SNAPSHOT'
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed 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.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
4 changes: 0 additions & 4 deletions viewpump/Module.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Module viewpump

View inflation with pre/post-inflation interceptors.

# Package io.github.inflationx.viewpump

View inflation with pre/post-inflation interceptors.
51 changes: 29 additions & 22 deletions viewpump/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'org.jetbrains.dokka-android'
apply plugin: 'com.vanniktech.maven.publish'

group = GROUP
version = VERSION_NAME
dokka {
reportUndocumented = false
skipDeprecated = true
jdkVersion = 7
includes = ['Module.md']
packageOptions {
prefix = "io.github.inflationx.viewpump.internal"
suppress = true
}
externalDocumentationLink {
url = new URL("https://developer.android.com/reference/")
packageListUrl =
new URL("https://developer.android.com/reference/androidx/package-list")
}
}

android {
compileSdkVersion 28
Expand All @@ -14,14 +26,6 @@ android {
minSdkVersion 14
targetSdkVersion 28
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}

lintOptions {
// we don't always want to use the latest version of the support library
disable 'GradleDependency'
Expand All @@ -30,24 +34,27 @@ android {
}
libraryVariants.all {
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
it.generateBuildConfig.enabled = false
it.generateBuildConfigProvider.configure {
it.enabled = false
}
}
variantFilter { variant ->
if (variant.buildType.name == 'debug') {
variant.setIgnore(true)
}
}
}

dokka {
includeNonPublic = false
skipDeprecated = true
includes = ['Module.md']
}

dependencies {
compileOnly 'androidx.appcompat:appcompat:1.0.2'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.21'
api 'org.jetbrains.kotlin:kotlin-stdlib:1.3.21'

testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:2.9.0'
testImplementation 'org.mockito:mockito-core:2.15.0'
testImplementation 'org.assertj:assertj-core:3.11.0'
testImplementation 'org.mockito:mockito-core:2.23.0'

testImplementation 'androidx.annotation:annotation:1.0.1'
testImplementation 'androidx.annotation:annotation:1.0.2'
testImplementation 'androidx.test:runner:1.1.1'
}

apply plugin: 'com.vanniktech.maven.publish'
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package io.github.inflationx.viewpump
import android.content.Context
import android.view.View
import androidx.annotation.MainThread
import io.github.inflationx.viewpump.internal.FallbackViewCreationInterceptor
import io.github.inflationx.viewpump.internal.InterceptorChain
import io.github.inflationx.viewpump.internal.ReflectiveFallbackViewCreator

class ViewPump private constructor(
/** List of interceptors. */
Expand All @@ -26,7 +29,8 @@ class ViewPump private constructor(
private val interceptorsWithFallback: List<Interceptor> = (interceptors + FallbackViewCreationInterceptor()).toMutableList()

fun inflate(originalRequest: InflateRequest): InflateResult {
val chain = InterceptorChain(interceptorsWithFallback, 0, originalRequest)
val chain = InterceptorChain(interceptorsWithFallback, 0,
originalRequest)
return chain.proceed(originalRequest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.ContextWrapper
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import io.github.inflationx.viewpump.internal.ViewPumpActivityFactory
import kotlin.LazyThreadSafetyMode.NONE

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import io.github.inflationx.viewpump.internal.ViewPumpActivityFactory
import io.github.inflationx.viewpump.internal.getAccessibleMethod
import io.github.inflationx.viewpump.internal.invokeMethod
import io.github.inflationx.viewpump.internal.setValueQuietly
import org.xmlpull.v1.XmlPullParser
import java.lang.reflect.Field

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
@file:JvmName("-FallbackViewCreationInterceptor")
package io.github.inflationx.viewpump
package io.github.inflationx.viewpump.internal

import io.github.inflationx.viewpump.InflateResult
import io.github.inflationx.viewpump.Interceptor
import io.github.inflationx.viewpump.Interceptor.Chain

internal class FallbackViewCreationInterceptor : Interceptor {

override fun intercept(chain: Interceptor.Chain): InflateResult {
override fun intercept(chain: Chain): InflateResult {
val request = chain.request()
val viewCreator = request.fallbackViewCreator
val fallbackView = viewCreator.onCreateView(request.parent, request.name, request.context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
@file:JvmName("-InterceptorChain")
package io.github.inflationx.viewpump
package io.github.inflationx.viewpump.internal

import io.github.inflationx.viewpump.InflateRequest
import io.github.inflationx.viewpump.InflateResult
import io.github.inflationx.viewpump.Interceptor
import io.github.inflationx.viewpump.Interceptor.Chain

/**
* A concrete interceptor chain that carries the entire interceptor chain.
*/
internal class InterceptorChain(private val interceptors: List<Interceptor>, private val index: Int,
private val request: InflateRequest) : Interceptor.Chain {
private val request: InflateRequest) : Chain {

override fun request(): InflateRequest {
return request
Expand All @@ -17,7 +22,8 @@ internal class InterceptorChain(private val interceptors: List<Interceptor>, pri
}

// Call the next interceptor in the chain.
val next = InterceptorChain(interceptors, index + 1, request)
val next = InterceptorChain(interceptors, index + 1,
request)
val interceptor = interceptors[index]

return interceptor.intercept(next)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:JvmName("-ReflectionUtils")
package io.github.inflationx.viewpump
package io.github.inflationx.viewpump.internal

import android.util.Log

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@file:JvmName("-ReflectiveFallbackViewCreator")
package io.github.inflationx.viewpump
package io.github.inflationx.viewpump.internal

import android.content.Context
import android.util.AttributeSet
import android.view.View
import io.github.inflationx.viewpump.FallbackViewCreator

import java.lang.reflect.Constructor
import java.lang.reflect.InvocationTargetException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:JvmName("-ViewPumpActivityFactory")
package io.github.inflationx.viewpump
package io.github.inflationx.viewpump.internal

import android.content.Context
import android.util.AttributeSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import io.github.inflationx.viewpump.FallbackViewCreator;
import io.github.inflationx.viewpump.InflateRequest;
import io.github.inflationx.viewpump.InflateResult;
Expand All @@ -21,11 +15,13 @@
import io.github.inflationx.viewpump.util.TestFallbackViewCreator;
import io.github.inflationx.viewpump.util.TestPostInflationInterceptor;
import io.github.inflationx.viewpump.util.TestView;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class AnotherTestView extends View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.github.inflationx.viewpump.FallbackViewCreator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class TestView extends View {
Expand Down

0 comments on commit 2bbc15a

Please sign in to comment.