Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
Make build system support submodules (#22)
Browse files Browse the repository at this point in the history
* Add submodule support to build system

* Remove publishing support

* Update readme

* Update README.md

* Add documentation for how the build system was changed
  • Loading branch information
JacobJBublitz committed Dec 22, 2018
1 parent 5643fd5 commit e17e6c9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 90 deletions.
67 changes: 29 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,58 @@
This repository contains code that is shared between applications and robots
that are created by FRC Team 2910, Jack in the Bot. The repository itself is
currently split into two parts: common and robot. The common library contains
code that does not depend on FIRST's wpilib, meaning it can run as a part of
desktop applications. The robot library contains code that depends on wpilib
code that does not depend on FIRST's WPILib, meaning it can run as a part of
desktop applications. The robot library contains code that depends on WPILib
and should only be ran on robots.

## How to use in another project

Currently, FRC Team 2910 does not have a system for hosting maven dependencies,
this means to use the libraries, the libraries must be built and installed to
the local maven repository.

To install locally on Windows run `gradlew publishToMavenLocal`.

While in on Linux or macOS run `./gradlew publishToMavenLocal`.

In order to use the locally-installed libraries, add `mavenLocal()` to the
repositories block in your `build.gradle` file.

```gradle
repositories {
...
mavenLocal()
...
}
```
The common library is imported into a project by using
[Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). In
order to add this project as a submodule run `git submodule add
https://github.com/FRCTeam2910/Common.git jester` in your project's root
directory. This will clone this repository into the directory `jester`.

### Using the Common library

A dependency on the common library can be created by adding the following to your `build.gradle` file.
A dependency on the common library can be created by adding the following to
your `build.gradle` file:
```gradle
dependencies {
...
compile group: 'org.frcteam2910.common', name: 'common', version: '0.1.0'
compile project(':jester')
...
}
```
The following also needs to be added to your `settings.gradle` file:
```gradle
include ':jester'
```

### Using the Robot library

Using the robot library is a little more complicated. In order for the library
to not crash at runtime, the following dependencies need to be added to your
`build.gradle` file.
A dependency on the robot library can be created by adding the following to
your `build.gradle` file:
```gradle
dependencies {
plugins {
...
compile wpilib()
compile ctre()
compile navx()
id 'edu.wpi.first.GradleRIO' version '<GRADLERIO_VERSION>'
...
}
```

> NOTE: `ctreLegacy()` cannot be used
After that, the robot library can be added.
```gradle
...
dependencies {
...
compile group: 'org.frcteam2910.common', name: 'robot', version: '0.1.0
compile project(':jester:robot')
...
}
```
Replace `<GRADLERIO_VERSION>` with the version of GradleRIO you want to use.

> NOTE: The common library does not need to be an explicit dependency because
> it is a dependency of the robot library.
> NOTE: The common library does not need to be explicitly used because it is a
> dependency of the robot library.
The following also needs to be added to your `settings.gradle` file:
```gradle
include ':jester'
include ':jester:robot'
```
50 changes: 26 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
/*
* The following block allows us to be used as a submodule. If we are the root
* project we want to specify a version of GradleRIO to use, however, when we
* are not the root project (i.e. a submodule in a robot) let the parent
* project specify what version of GradleRIO to use by not adding GradleRIO to
* the plugin classpath.
*/
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}

dependencies {
if (rootProject == project) {
classpath 'gradle.plugin.edu.wpi.first:GradleRIO:2019.0.0-alpha-3'
}
}
}

plugins {
id 'eclipse'
id 'java'
id 'maven-publish'
}

sourceCompatibility = '1.8'
Expand All @@ -18,27 +37,10 @@ dependencies {
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
}

task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}

task javadocJar(type: Jar) {
from javadoc
classifier 'javadoc'
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
// Only add a wrapper block if we are the root project
if (rootProject == project) {
wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '4.10.3'
}
}

wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '4.10.3'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
27 changes: 3 additions & 24 deletions robot/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
plugins {
id 'edu.wpi.first.GradleRIO' version '2019.0.0-alpha-3'
id 'eclipse'
id 'edu.wpi.first.GradleRIO'
id 'java'
id 'maven-publish'
}

sourceCompatibility = '1.8'
Expand All @@ -19,25 +17,6 @@ dependencies {
compile navx()
compile ctre()

compile project(':')
}

task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier 'sources'
}

task javadocJar(type: Jar) {
from javadoc
classifier 'javadoc'
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
// Depend on the common library
compile project.parent
}
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
rootProject.name = 'common'

include 'robot'

enableFeaturePreview('STABLE_PUBLISHING')

0 comments on commit e17e6c9

Please sign in to comment.