Skip to content

Commit

Permalink
[#1504] include dependencies, cleanup build config, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Dec 8, 2021
1 parent e073b0d commit d99afd2
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 52 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Build
run: ./gradlew build --no-daemon

build-java-5-6-7:
build-java-6-7:
strategy:
matrix:
java-version: [ 6, 7 ]
Expand All @@ -37,21 +37,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Configure Java 8
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 8
cache: gradle

- name: Build with Java 8 once to download dependencies; HTTPS does not work with older Java versions
continue-on-error: true
uses: gradle/gradle-build-action@v2
with:
gradle-version: 1.12
build-root-directory: picocli-legacy-tests/
arguments: assemble --no-daemon

- name: Configure JDK ${{ matrix.java-version }}
uses: actions/setup-java@v2
with:
Expand Down
52 changes: 39 additions & 13 deletions picocli-legacy-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
# Picocli Legacy Tests

This project runs the tests for the main `picocli` project in a Java 5 environment.
This project builds the main `picocli` project and runs its tests in a Java 5 environment.

While the directory structure may suggest that this is a subproject of the `picocli` project, it is actually a standalone project, not a module.
## This project is for testing only
The build for this project compiles the Java source files in the `../src/java` and `../test/java` folders of the parent project, and then runs the tests.
While the directory structure may suggest that this is a subproject of the `picocli` project, it is actually a standalone project, and not included as a module in the main build.

This project does not publish any artifacts.

Note to self: do the following before running this build:
## Gradle version
This project uses an old version of Gradle (1.12); I believe this is the most recent version of Gradle that runs on Java 5. (Later versions require at least Java 6.)

## HTTPS problems on Java 5
I was unable to automate downloading the Gradle 1.12 binary via HTTPS when running the Gradle Wrapper on Java 5; there seemed to be some issue with TLS versions; I could not get HTTPS to work on Java 5.

A similar issue exists with test dependencies: while picocli itself does not have any dependencies, the test classes do have some dependencies.
Maven Central and other repositories require downloads to use HTTPS and disallow plain HTTP.
I have not been able to use HTTPS when running on Java 5.
This causes the build to fail; Gradle reports errors when trying to download test dependencies and aborts the build.

## Binaries included in project
To work around these problems, I ended up including some binaries in this project:

* the Gradle Wrapper included in this project also has a copy of the Gradle 1.12 binary distribution
* the test dependency binaries are included in the `lib` directory of this project

I realize this is uncouth, inelegant and a generally barbarous thing to do. I am a sinner, please forgive me.

## Usage
This project assumes that you have Java 5 installed.

If you have multiple versions of Java installed, then before running this build, set the `JAVA_HOME` environment variable to the directory where Java 5 is installed:

```
: (on Windows)
: start command prompt if we are running in Powershell
cmd
: ensure we are not using the OneDrive user home directory
set JAVA_OPTS=-Duser.home=C:\Users\remko\.m2\repository
: build the project once with Java 8 so that all dependencies are downloaded and cached
cd ..
gradlew assemble
cd picocli-legacy-tests
: now build the project with Java 5, 6 and 7
cd picocli-legacy-tests
set JAVA_HOME=C:\apps\jdk1.5.0_22
gradlew clean build
gradlew clean build --no-daemon
set JAVA_HOME=C:\apps\jdk1.6.0_45
gradlew clean build
gradlew clean build --no-daemon
set JAVA_HOME=C:\apps\jdk1.7.0_80
gradlew clean build --no-daemon
```

## Usage from CI Continuous Integration builds

See the `../.github/workflows/ci.yml` workflow for a concrete example, specifically the `build-java-6-7` section.
28 changes: 12 additions & 16 deletions picocli-legacy-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
group 'info.picocli'
description 'Compile and test the picocli project in legacy Java environments.'
version "$projectVersion"
version "CURRENT"

apply plugin: 'java'

repositories {
flatDir { // Java 5 has problems with HTTPS links, but Maven requires HTTPS
dirs 'lib'
}
// (BELOW LINES ARE OBSOLETE)
// do not use mavenCentral(): it uses HTTP in this old version of Gradle
// mavenCentral()
maven { url "https://repo.maven.apache.org/maven2/" }
maven { url 'https://repo.spring.io/libs-snapshot' }
//maven { url "https://repo.maven.apache.org/maven2/" }
}

configurations.all {
resolutionStrategy {
// avoid "Could not resolve junit:junit-dep:[4.9,)" caused by stefanbirkner:system-rules when building offline
force "junit:junit-dep:$junitDepVersion"
}
}
dependencies {
testCompile "junit:junit:$junitVersion",
"org.hamcrest:hamcrest-core:$hamcrestCoreVersion",
"org.fusesource.jansi:jansi:$jansiVersion",
"com.github.stefanbirkner:system-rules:$systemRulesVersion",
"pl.pragmatists:JUnitParams:1.1.1"
testCompile "junit:junit:4.12",
"org.hamcrest:hamcrest-core:1.3",
"org.fusesource.jansi:jansi:1.15", // latest Jansi compiled on Java 5
"com.github.stefanbirkner:system-rules:1.17.1" // ,
// "pl.pragmatists:JUnitParams:1.1.1" // excluded, requires Java 6
}

sourceCompatibility = 1.5
Expand All @@ -37,7 +33,7 @@ sourceSets.test.resources.srcDirs = ['../src/test/resources']
sourceSets {
test {
java {
exclude 'some/unwanted/package/**'
exclude 'picocli/ArgGroupParameterizedTest.java' // JUnitParams requires Java 6
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions picocli-legacy-tests/gradle.properties

This file was deleted.

Binary file added picocli-legacy-tests/lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added picocli-legacy-tests/lib/jansi-1.15.jar
Binary file not shown.
Binary file added picocli-legacy-tests/lib/junit-4.12.jar
Binary file not shown.
53 changes: 53 additions & 0 deletions picocli-legacy-tests/lib/junit-dep-4.11.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<packaging>pom</packaging>
<version>4.11</version>
<distributionManagement>
<relocation>
<artifactId>junit</artifactId>
<version>4.11</version>
<message>The artifact junit:junit does not contain Hamcrest anymore but declares a dependency to Hamcrest. Thus, junit:junit-dep has become obsolete.</message>
</relocation>
</distributionManagement>
<name>JUnit</name>
<url>http://junit.org</url>
<description>
JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
It is used by the developer who implements unit tests in Java.
</description>
<organization>
<name>JUnit</name>
<url>http://www.junit.org</url>
</organization>
<mailingLists>
<mailingList>
<name>JUnit Mailing List</name>
<post>junit@yahoogroups.com</post>
<archive>
http://tech.groups.yahoo.com/group/junit/
</archive>
</mailingList>
</mailingLists>
<licenses>
<license>
<name>Common Public License Version 1.0</name>
<url>http://www.opensource.org/licenses/cpl1.0.txt</url>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/KentBeck/junit.git</connection>
<developerConnection>scm:git:git@github.com:KentBeck/junit.git</developerConnection>
<url>http://github.com/KentBeck/junit/tree/master</url>
</scm>
<developers>
<developer>
<id>dsaff</id>
<name>David Saff</name>
<email>david@saff.net</email>
</developer>
</developers>
</project>
Binary file not shown.

0 comments on commit d99afd2

Please sign in to comment.