Skip to content

Commit

Permalink
feat(Release): Enable command-line releases (#108)
Browse files Browse the repository at this point in the history
* Update release docs
* Add minification
* Print the path to the command-line app JAR
  • Loading branch information
barbeau authored Apr 15, 2020
1 parent 1552fa0 commit 7e0fce2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 13 deletions.
38 changes: 29 additions & 9 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Release instructions

To create a release jar file, we use the IntelliJ artifact build feature
We create releases from the command-line using the [shadow Gradle plugin](https://github.com/johnrengelman/shadow), which creates a JAR file including all necessary dependencies.

- Go to File->Project Structure
- Select Artifacts in the left pane
- Add a new one by clicking the '+' button
- of type JAR->From modules with dependencies
- Select the Main class from cli-app module
- Place the META-INF file at the project's root
- In the output Layout, add both cli-app and in-memory-simple modules main resource directory content
### 1. Prepare for release
Change `version` in the various `build.gradle` files to remove the `-SNAPSHOT` qualifier.

For example, if the current version is `1.1.0-SNAPSHOT`, change the `version` to `1.1.0`.

### 2. Do the release

```
./gradlew shadowJar
```

The command line output will tell you where the compiled JAR file is located - for example:

>Successfully built the gtfs-validator command-line app: C:\git-projects\gtfs-validator\application\cli-app\build\libs\gtfs-validator-v1.1.0.jar
This file can then be run from the command-line with the normal Java conventions:

```
java -jar gtfs-validator-v1.1.0.jar -u https://transitfeeds.com/p/mbta/64/latest/download -z input.zip -i input -o output
```

### 3. Prepare for the next development cycle

Increment the `version` in the various `build.gradle` files and add the `-SNAPSHOT` qualifier.

For example, if the version you just released is `1.1.0`, change the `version` to `1.1.1-SNAPSHOT`.

For more details on versioning, see [Understanding Maven Version Numbers](https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855).

- Build the jar through Build->Build Artifacts

2 changes: 1 addition & 1 deletion adapter/exporter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {

implementation 'com.google.protobuf:protobuf-java:3.8.0'

implementation 'com.fasterxml.jackson.core:jackson-core:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.3'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
Expand Down
6 changes: 3 additions & 3 deletions adapter/repository/in-memory-simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ dependencies {

implementation 'commons-validator:commons-validator:1.6'

implementation 'com.fasterxml.jackson.core:jackson-core:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.3'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.10.3'

implementation 'org.apache.logging.log4j:log4j-api:2.12.1'
implementation 'org.apache.logging.log4j:log4j-core:2.12.1'
Expand Down
32 changes: 32 additions & 0 deletions application/cli-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput

plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'java'
}

group 'org.mobilitydata'
version '1.1.0-SNAPSHOT'

jar {
// Add the manifest within the JAR, using gtfs-validator as the title
manifest {
attributes('Implementation-Title': rootProject.name,
'Implementation-Version': project.version,
'Main-Class': 'org.mobilitydata.gtfsvalidator.Main',
'Multi-Release': 'true')
}
}

shadowJar {
minimize {
exclude(dependency('org.apache.logging.log4j:log4j-core'))
exclude(dependency('com.fasterxml.jackson.core:jackson-databind'))
}
// Change the JAR name from cli-app to gtfs-validator
archiveBaseName = rootProject.name
// Remove "-all" from the end of the JAR file name
archiveClassifier = null
// Add "v" to version to match previous releases
archiveVersion = "v" + project.version
}

sourceCompatibility = JavaVersion.VERSION_11

repositories {
Expand All @@ -39,3 +65,9 @@ dependencies {
implementation 'org.apache.logging.log4j:log4j-core:2.12.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
}

// Print success message with location of compiled JAR with dependencies
def out = services.get(StyledTextOutputFactory).create("output")
tasks.shadowJar.doLast {
out.style(StyledTextOutput.Style.SuccessHeader).println "Successfully built the gtfs-validator command-line app: " + archivePath
}

0 comments on commit 7e0fce2

Please sign in to comment.