Skip to content

Commit

Permalink
Merge pull request #6 from ref-humbold/gradle
Browse files Browse the repository at this point in the history
Gradle build
  • Loading branch information
ref-humbold authored Apr 1, 2024
2 parents 1c42beb + 848ed8b commit eb1204f
Show file tree
Hide file tree
Showing 15 changed files with 642 additions and 59 deletions.
33 changes: 27 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

jobs:
build-and-test:
ant-build-and-test:
working_directory: ~/DI-Container
docker:
- image: cimg/base:stable
Expand All @@ -21,17 +21,38 @@ jobs:
command: ./ci/install_ant_junit5.sh
- run:
name: Download Dependencies
command: ant -lib ./lib resolve
command: ant resolve
- run:
name: Build
command: ant -lib ./lib build
command: ant jar
- run:
name: Test
command: ant -lib ./lib test
command: ant test
- store_test_results:
path: ./junit/result
path: ./antBuild/junit/result
gradle-build-and-test:
working_directory: ~/DI-Container
docker:
- image: cimg/base:stable
auth:
username: mydockerhub-user
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- run:
name: APT Install Java
command: sudo apt-get update && sudo apt-get install openjdk-17-jdk
- run:
name: Build
command: ./gradlew jar
- run:
name: Test
command: ./gradlew test
- store_test_results:
path: ./build/test-results/test

workflows:
main:
jobs:
- build-and-test
- ant-build-and-test
- gradle-build-and-test
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: GitHub Actions

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build-and-test:
ant-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -18,12 +18,12 @@ jobs:
- name: Download Dependencies
run: |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ant -lib ./lib resolve
ant resolve
- name: Build
run: |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ant -lib ./lib build
ant jar
- name: Test
run: |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ant -lib ./lib test
ant test
21 changes: 21 additions & 0 deletions .github/workflows/gradle-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: GitHub Actions

on: [ push, pull_request ]

jobs:
gradle-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: APT Install Java
run: |
sudo apt-get update && sudo apt-get install openjdk-17-jdk
sudo update-java-alternatives --set java-1.17.0-openjdk-amd64
- name: Build
run: |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
./gradlew jar
- name: Test
run: |
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
./gradlew test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
antBuild/
ivyLib/

.gradle
build/

.vscode
*.code-workspace

Expand Down
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,60 @@ Simple dependency injection container in Java

-----

## Dependencies

### Standard build & run

> *versions used by the author are in double parentheses and italic*
## System requirements

General:
> versions used by the author are in italics
+ Operating system \
*((Debian testing))*
*Debian testing*
+ [Java](https://www.oracle.com/technetwork/java/javase/overview/index.html) \
*((APT package `openjdk-17-jdk`, version 17 SE))*
*APT package `openjdk-17-jdk`, version 17 SE*
+ [Apache ANT](http://ant.apache.org/) \
*((APT package `ant`, version 1.10.+))*
*APT package `ant`, version 1.10.+*

### Unit testing
## Dependencies

> libraries are automatically downloaded during build process
> dependencies are automatically downloaded during build process
+ JUnit 5.+
+ AssertJ 3.+

-----

## How to build?
## How to build with ANT?

DI\_Container can be built with **Apache ANT** using **Apache Ivy** to resolve all dependencies.
Ivy and all libraries are downloaded during build, so make sure your Internet connection is working!
Ivy itself and all dependencies are downloaded during build, so make sure your Internet
connection is working!

Possible ANT targets are:

+ `ant`, `ant all` - resolve dependencies & compile source files & create jar & run all tests
+ `ant build` - compile source files & create jar
+ `ant main` - resolve dependencies & compile source files & create jar
+ `ant`, `ant build` - resolve dependencies & compile source files & create jar & run all tests
+ `ant resolve` - resolve dependencies
+ `ant jar` - compile source files & create jar
+ `ant test` - run all tests
+ `ant docs` - generate Javadoc
+ `ant rebuild` - remove additional build files & compile source files & create jar
+ `ant rebuild-main` - remove additional build files & resolve dependencies & compile source files &
create jar
+ `ant rebuild-all` - remove additional build files & resolve dependencies & compile source files &
+ `ant clean` - remove additional build files
+ `ant rebuild` - remove additional build files & resolve dependencies & compile source files &
create jar & run all tests

## How to build with Gradle?

DI\_Container can be built with **Gradle**. All dependencies are downloaded during build, so
make sure your Internet connection is working!

Possible Gradle tasks are:

+ `gradle build` - resolve dependencies & compile source files & create jar & run all tests
+ `gradle jar` - resolve dependencies & compile source files & create jar
+ `gradle test` - run all tests
+ `gradle javadoc` - generate Javadoc
+ `gradle rebuild` - remove additional build files & resolve dependencies & compile source files &
create jar & run all tests

## How to include it?

Simply add the *jar* file from the `dist` directory to your classpath.
Simply add the *jar* file to your classpath from the directory:

+ `antBuild/dist` for ANT builds
+ `build/libs` for Gradle builds
20 changes: 14 additions & 6 deletions Jenkinsfile → ant.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ pipeline {
}

parameters {
booleanParam(name: "archive", description: "Should artifacts be archived?", defaultValue: false)
booleanParam(name: "javadoc", description: "Should generate Javadoc?", defaultValue: false)
booleanParam(
name: "archive",
description: "Should artifacts be archived?",
defaultValue: false
)
booleanParam(
name: "javadoc",
description: "Should generate Javadoc?",
defaultValue: false
)
}

environment {
Expand All @@ -15,17 +23,17 @@ pipeline {
}

options {
skipDefaultCheckout(true)
skipDefaultCheckout true
timeout(time: 20, unit: "MINUTES")
buildDiscarder(logRotator(numToKeepStr: "10", artifactNumToKeepStr: "5"))
buildDiscarder logRotator(numToKeepStr: "10", artifactNumToKeepStr: "5")
timestamps()
}

stages {
stage("Preparation") {
steps {
script {
def scmEnv = checkout(scm)
def scmEnv = checkout scm
currentBuild.displayName = "${env.BUILD_NUMBER} ${scmEnv.GIT_COMMIT.take(8)}"
}
}
Expand All @@ -35,7 +43,7 @@ pipeline {
steps {
echo "#INFO: Building project"
withAnt(installation: "${env.ANT_NAME}", jdk: "${env.JDK_NAME}") {
sh "ant main"
sh "ant resolve jar"
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
plugins {
id 'java-library'
}

ext {
majorVersion = 4
minorVersion = 0
dateVersion = new Date().format('yyMMdd')
specVersion = "${majorVersion}.${minorVersion}"
jarVersion = "${majorVersion}.${minorVersion}.${dateVersion}"
vendor = 'Rafał Kaleta'
mainPackage = 'dicontainer'
}

version = project.jarVersion
archivesBaseName = project.mainPackage

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.+'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.+'
testImplementation 'org.junit.platform:junit-platform-commons:1.+'
testImplementation 'org.junit.platform:junit-platform-engine:1.+'
testImplementation 'org.junit.platform:junit-platform-launcher:1.+'
testImplementation 'org.assertj:assertj-core:3.+'
}

tasks.jar {
manifest {
attributes(
'Built-By': project.vendor,
'Specification-Title': 'Dependency Injection Container',
'Specification-Version': project.specVersion,
'Specification-Vendor': project.vendor,
'Implementation-Title': project.mainPackage,
'Implementation-Version': project.jarVersion,
'Implementation-Vendor': project.vendor
)
}
}

tasks.test {
useJUnitPlatform()
}

task rebuild {
group 'build'
description 'Deletes the build directory, assembles and tests this project.'
dependsOn 'clean', 'build'
tasks.findByName('build').mustRunAfter('clean')
}

javadoc.options.addStringOption('Xdoclint:none')
Loading

0 comments on commit eb1204f

Please sign in to comment.