Skip to content

Commit

Permalink
Migrate to Gradle (#1159)
Browse files Browse the repository at this point in the history
* Start gradle root

* Clean up test API ambiguities

These don't compile in gradle anymore and the team[] warns

* Exclude .gradle dirs in git

* Set up moshi module

* Set up moshi-adapters

* Add repositories to subprojects

* Set target/source compatibility

* Set up examples

* Fix location of reflect/test dir

* Set up moshi-kotlin

* Set up code gen

* Opportunistic update code gen deps

* Fix up with code gen

* Set up kotlin tests

* Update snapshots

* Update travis build

* Configure checkstyle

* Cache gradle

* Finish fixing up checkstyle

* Now disable checkstyle until we can fix them all :|

* Update contributing

* Fix tests in codegen

* Remove unnecessary annotation

* Remove maven stuff!

* Suppress warning

* Remove jcenter

* Consolidate dependencies

* Revert "Clean up test API ambiguities"

This reverts commit 3ead69b.

* Fix incap dep

* Opportunistically fix some small kotlinpoet deprecations

* Automatically apply the stdlib to all kotlin projects

* Opportunistic move to opt-in and remove unnecessary annotations

The kotlin maven plugin didn't handle these well in the IDE, gradle does

* Fix Type doc warning

* Fix okio version

* Fix dokka support

* Fix copypasta

* Use new snapshot

* Kotlin 1.4.0
  • Loading branch information
ZacSweers authored Aug 27, 2020
1 parent 24c0c49 commit 4dd4a9d
Show file tree
Hide file tree
Showing 48 changed files with 899 additions and 1,643 deletions.
2 changes: 1 addition & 1 deletion .buildscript/deploy_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ 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" -Dmaven.test.skip=true
./gradlew uploadArchives
echo "Snapshot deployed!"
fi
9 changes: 0 additions & 9 deletions .buildscript/settings.xml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ classes
obj

.DS_Store

.gradle
117 changes: 0 additions & 117 deletions .mvn/wrapper/MavenWrapperDownloader.java

This file was deleted.

Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties

This file was deleted.

10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: java
jdk:
- openjdk8

script:
- ./gradlew build check

after_success:
- .buildscript/deploy_snapshot.sh

Expand All @@ -18,6 +21,11 @@ branches:
notifications:
email: false

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

cache:
directories:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ 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 `./mvnw 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.
failing project's `build/reports/checkstyle` directory.

Before your code can be accepted into the project you must also sign the
[Individual Contributor License Agreement (CLA)][1].
Expand Down
29 changes: 29 additions & 0 deletions adapters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2020 Square, Inc.
*
* 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
*
* https://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.
*/

plugins {
`java-library`
id("com.vanniktech.maven.publish")
}

dependencies {
compileOnly(Dependencies.jsr305)
api(project(":moshi"))

testCompileOnly(Dependencies.jsr305)
testImplementation(Dependencies.Testing.junit)
testImplementation(Dependencies.Testing.assertj)
}
20 changes: 20 additions & 0 deletions adapters/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2020 Square, Inc.
#
# 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
#
# https://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.
#

POM_NAME=Moshi Adapters
POM_ARTIFACT_ID=moshi-adapters
POM_PACKAGING=jar
AUTOMATIC_MODULE_NAME=com.squareup.moshi.adapters
52 changes: 0 additions & 52 deletions adapters/pom.xml

This file was deleted.

89 changes: 89 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2020 Square, Inc.
*
* 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
*
* https://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.
*/
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import org.gradle.jvm.tasks.Jar

buildscript {
dependencies {
classpath(kotlin("gradle-plugin", version = Dependencies.Kotlin.version))
}
}

plugins {
id("com.vanniktech.maven.publish") version "0.11.1" apply false
id("org.jetbrains.dokka") version "0.10.1" apply false
}

subprojects {
repositories {
mavenCentral()
@Suppress("UnstableApiUsage")
exclusiveContent {
forRepository {
maven {
name = "JCenter"
setUrl("https://jcenter.bintray.com/")
}
}
filter {
includeModule("org.jetbrains.dokka", "dokka-fatjar")
}
}
}

// apply(plugin = "checkstyle")
// configure<CheckstyleExtension> {
// toolVersion = "8.28"
// configFile = rootProject.file("checkstyle.xml")
// }
// tasks.withType<Checkstyle>().configureEach {
// exclude("**/Iso8601Utils.java")
// }

pluginManager.withPlugin("java-library") {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}

// Configure publishing
pluginManager.withPlugin("com.vanniktech.maven.publish") {
configure<MavenPublishPluginExtension> {
useLegacyMode = false
nexus {
groupId = "com.squareup"
}
}

// Configure automatic-module-name, but only for published modules
@Suppress("UnstableApiUsage")
val automaticModuleName = providers.gradleProperty("AUTOMATIC_MODULE_NAME")
.forUseAtConfigurationTime()
if (automaticModuleName.isPresent) {
val name = automaticModuleName.get()
tasks.withType<Jar>().configureEach {
manifest {
attributes("Automatic-Module-Name" to name)
}
}
}
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
dependencies.add("api", Dependencies.Kotlin.stdlib)
}
}
23 changes: 23 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2020 Square, Inc.
*
* 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
*
* https://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.
*/

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
Loading

1 comment on commit 4dd4a9d

@johnjohndoe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.