Skip to content

Commit

Permalink
Basic Gradle support
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejesse committed Mar 17, 2019
1 parent 812dcc3 commit dc1e870
Show file tree
Hide file tree
Showing 56 changed files with 696 additions and 1,910 deletions.
3 changes: 2 additions & 1 deletion .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
else
echo "Deploying snapshot..."
./mvnw clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -DskipTests -B
echo "TODO: fix snapshot deployment for gradle..."
# ./mvnw clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -DskipTests -B
echo "Snapshot deployed!"
fi
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions
and style in order to keep the code as readable as possible. Please also make
sure your code compiles by running `mvn clean verify`. Checkstyle failures
sure your code compiles by running `./gradlew check`. Checkstyle failures
during compilation indicate errors in your style and can be viewed in the
`checkstyle-result.xml` file.

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.classpath
.project
.settings
.gradle
eclipsebin

bin
gen
build
out
lib
generated

target
pom.xml.*
Expand Down
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@ jdk:
- openjdk8
- openjdk11

before_install:
- mvn -N io.takari:maven:wrapper -Dmaven=3.6.0
- echo "MAVEN_OPTS='-Dmaven.repo.local=$HOME/.m2/repository -Xmx1g -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS'" > ~/.mavenrc

install:
- ./mvnw dependency:resolve -B || true

script:
- ./mvnw -DskipTests package checkstyle:check -B
- ./mvnw test javadoc:jar source:jar -B
- ./gradlew check

after_success:
- .buildscript/deploy_snapshot.sh
Expand Down
154 changes: 154 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
buildscript {
ext.versions = [
'airline': '0.8',
'android': '4.1.1.4',
'animalSniffer': '1.17',
'assertj': '3.11.0',
'bouncycastle': '1.60',
'checkstyle': '8.15',
'conscrypt': '2.0.0',
'findbugs': '3.0.2',
'guava': '27.0.1-jre',
'java': '1.8',
'jnrUnixsocket': '0.22',
'jsoup': '1.11.3',
'junit': '4.12',
'moshi': '1.8.0',
'okio': '1.17.2',
]

ext.deps = [
'airline': "io.airlift:airline:${versions.airline}",
'android': "com.google.android:android:${versions.android}",
'animalSniffer': "org.codehaus.mojo:animal-sniffer-annotations:${versions.animalSniffer}",
'assertj': "org.assertj:assertj-core:${versions.assertj}",
'bouncycastle': "org.bouncycastle:bcprov-jdk15on:${versions.bouncycastle}",
'conscrypt': "org.conscrypt:conscrypt-openjdk-uber:${versions.conscrypt}",
'guava': "com.google.guava:guava:${versions.guava}",
'jnrUnixsocket': "com.github.jnr:jnr-unixsocket:${versions.jnrUnixsocket}",
'jsoup': "org.jsoup:jsoup:${versions.jsoup}",
'jsr305': "com.google.code.findbugs:jsr305:${versions.findbugs}",
'junit': "junit:junit:${versions.junit}",
'moshi': "com.squareup.moshi:moshi:${versions.moshi}",
'okio': "com.squareup.okio:okio:${versions.okio}"
]

dependencies {
// TODO(jwilson): configure maven-publish-plugin to limit which artifacts are published.
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
}

repositories {
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id 'ru.vyarus.animalsniffer' version '1.5.0'
id 'com.github.johnrengelman.shadow' version '4.0.1'
}

allprojects {
group = GROUP
version = VERSION_NAME

repositories {
mavenCentral()
}
}

subprojects { project ->
apply plugin: 'java'
apply plugin: 'java-library'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

apply plugin: 'checkstyle'
checkstyleMain.exclude '**/CipherSuite.java'
afterEvaluate {
checkstyle {
configFile = rootProject.file('checkstyle.xml')
toolVersion "${versions.checkstyle}"
sourceSets = [project.sourceSets.main]
}
}

// Animal Sniffer confirms we don't use APIs not on both Java 8 and Android 5.
apply plugin: 'ru.vyarus.animalsniffer'
animalsniffer {
sourceSets = [sourceSets.main]
}
dependencies {
signature 'net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature'
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
}

test {
jvmArgs += "-Dlistener=okhttp3.testing.InstallUncaughtExceptionHandlerListener"
jvmArgs += "-Dokhttp.platform=platform"
}

// Add alpn-boot on Java 8 so we can use HTTP/2 without a stable API.
def alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
dependencies {
testCompile "org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion"
}
def alpnBootJar = configurations.testCompile.find { it.name.startsWith("alpn-boot-") }
test {
jvmArgs += "-Xbootclasspath/p:${alpnBootJar}"
}
}

// TODO(jwilson): configure error prone.
}

tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}

/**
* Returns the alpn-boot version specific to this OpenJDK 8 JVM, or null if this is not a Java 8 VM.
* https://github.com/xjdr/xio/blob/master/alpn-boot.gradle
*/
def alpnBootVersion() {
def javaVersion = System.getProperty("java.version")
def patchVersionMatcher = (javaVersion =~ /1\.8\.0_(\d+)(-.*)?/)
if (!patchVersionMatcher.find()) return null
def patchVersion = Integer.parseInt(patchVersionMatcher.group(1))
return alpnBootVersionForPatchVersion(javaVersion, patchVersion)
}

def alpnBootVersionForPatchVersion(String javaVersion, int patchVersion) {
switch (patchVersion) {
case 0..24:
return '8.1.0.v20141016'
case 25..30:
return '8.1.2.v20141202'
case 31..50:
return '8.1.3.v20150130'
case 51..59:
return '8.1.4.v20150727'
case 60..64:
return '8.1.5.v20150921'
case 65..70:
return '8.1.6.v20151105'
case 71..77:
return '8.1.7.v20160121'
case 78..101:
return '8.1.8.v20160420'
case 102..111:
return '8.1.9.v20160720'
case 112..120:
return '8.1.10.v20161026'
case 121..160:
return '8.1.11.v20170118'
case 161..181:
return '8.1.12.v20180117'
case 191..202:
return '8.1.13.v20181017'
default:
throw new IllegalStateException("Unexpected Java version: ${javaVersion}")
}
}
2 changes: 0 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
</module>

<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--module name="JavadocMethod"/-->
Expand Down
16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
org.gradle.jvmargs='-Dfile.encoding=UTF-8'

GROUP=com.squareup.okhttp3
VERSION_NAME=3.15.0-SNAPSHOT

POM_URL=https://github.com/square/okhttp
POM_SCM_URL=https://github.com/square/okhttp
POM_SCM_CONNECTION=scm:git:https://github.com/square/okhttp.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/square/okhttp.git

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=square
POM_DEVELOPER_NAME=Square, Inc.
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit dc1e870

Please sign in to comment.