Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 30 migrate to gradle #70

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
512 changes: 512 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Java CI with Gradle

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: Java ${{ matrix.java_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java_version: ['8']
# java_version: ['8', '11', '17']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
- name: Setup Gradle to generate and submit dependency graphs
uses: gradle/gradle-build-action@v2
with:
dependency-graph: generate-and-submit
- name: Run a build and generate the dependency graph which will be submitted post-job
run: ./gradlew clean build --info
27 changes: 0 additions & 27 deletions .github/workflows/maven.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/publish-to-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
- name: Publish package
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.classpath
.settings
.project
.gradle
workspace.xml
bin
target
build/
src/main/java/org/natty/generated/*
src/main/java/*.tokens
src/main/antlr3/org/natty/generated/DebugDateParser.g
src/main/antlr3/org/natty/generated/DebugDateWalker.g
src/main/antlr/org/natty/generated/DebugDateParser.g
src/main/antlr/org/natty/generated/DebugDateWalker.g

# IntelliJ Idea
*.iml
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Maven:
<dependency>
<groupId>io.github.natty-parser</groupId>
<artifactId>natty</artifactId>
<version>1.0.1</version>
<version>1.0.3</version>
</dependency>
```

Expand Down Expand Up @@ -50,3 +50,11 @@ Are more then welcome. Feel free to reach out (e.g. by creating an issue in this
maintainers. Tag @mccartney if no response for 2-3 days (I might have missed that).

I see this project potentially being welcoming to many, incl. quite junior and inexperienced developers, who would like to learn and contribute.

## Build

Builds are done using the gradle wrapper. All that's need is a JDK (8 or upwards) to be installed on the machine.

```shell
./gradlew build
```
61 changes: 61 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

plugins {
id 'java-library'
id 'maven-publish'
id 'antlr'

alias(libs.plugins.nebula.release)
}

repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}

dependencies {
api libs.antlr.runtime
api libs.ical4j
api libs.slf4j.api

antlr libs.antlr

testImplementation libs.slf4j.log4j12
testImplementation libs.logback.classic
testImplementation libs.junit
testImplementation libs.antlr.gunit

}

description = 'Natty Date Parser'

generateGrammarSource {

arguments += ["-visitor",
"-listener",
"-long-messages",
"-lib", "src/main/antlr/org/natty/generated/imports"
]
outputDirectory = file("${project.buildDir}/generated-src/antlr/")
source "src/main/antlr"
include "org/natty/generated/DateLexer.g"
include "org/natty/generated/DateParser.g"

}

publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc).configureEach {
options.encoding = 'UTF-8'
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
group=io.github.natty-parser

# nebula release settings
release.scope=patch
release.stage=SNAPSHOT
26 changes: 26 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
logback-classic = "1.3.14"
junit = "4.13.2"
antlr = "3.5.3"
ical4j = "3.2.14"
slf4j-api = "2.0.9"
slf4j-log4j12 = "1.7.36"

# gradle plugins
nebula-release = "18.0.5"

[libraries]
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback-classic" }
junit = { module = "junit:junit", version.ref = "junit" }
antlr-runtime = { module = "org.antlr:antlr-runtime", version.ref = "antlr" }
antlr = { module = "org.antlr:antlr", version.ref = "antlr" }
antlr-gunit = { module = "org.antlr:gunit", version.ref = "antlr" }
ical4j = { module = "org.mnode.ical4j:ical4j", version.ref = "ical4j" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-api" }
slf4j-log4j12 = { module = "org.slf4j:slf4j-log4j12", version.ref = "slf4j-log4j12" }

[plugins]
nebula-release = { id = "nebula.release", version.ref="nebula-release" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading