Skip to content

Commit

Permalink
Use gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuma-t committed Mar 23, 2024
1 parent c6d12f4 commit c1ad746
Show file tree
Hide file tree
Showing 16 changed files with 960 additions and 221 deletions.
315 changes: 315 additions & 0 deletions .formatter/eclipse-formatter.xml

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions .formatter/license-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) $YEAR Works Applications Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

52 changes: 52 additions & 0 deletions .github/workflow/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]

permissions:
checks: write # for SonarQube
contents: read # for SonarQube
statuses: read # for SonarQube
pull-requests: read # for SonarQube

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: temurin
cache: gradle
- name: Cache SonarCloud packages
if: matrix.java-version >= 17
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
- name: Build and check
run: ./gradlew --no-daemon --info --stacktrace build jacocoTestReport
- name: Analyze with sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: matrix.java-version >= 17 && env.SONAR_TOKEN != ''
run: ./gradlew --no-daemon --info --stacktrace sonarqube -Dsonar.verbose=true -Dsonar.login=$SONAR_TOKEN
- uses: actions/upload-artifact@v3
if: failure()
with:
name: reports (${{ matrix.java-version }})
path: build/reports
- name: Build javadoc
run: ./gradlew --no-daemon --info javadoc
74 changes: 62 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
# Ignore Gradle project-specific cache directory
.gradle
**/build/
!src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Cache of project
.gradletasknamecache

# Eclipse Gradle plugin generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

bin
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .travis/.gitignore

This file was deleted.

33 changes: 0 additions & 33 deletions .travis/settings.xml.template

This file was deleted.

Binary file removed .travis/settings_codesigning.tar.enc
Binary file not shown.
145 changes: 145 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
plugins {
`java-library`
id("maven-publish")
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("signing")
id("jacoco")
id("org.sonarqube") version "3.4.0.2513"
id("com.diffplug.spotless") version "6.25.0"
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
testImplementation("junit:junit:4.13.2")
}

group = "com.worksap.nlp"
version = "1.2.1-SNAPSHOT"
description = "A library of TRIE structure using Double-Array"
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")

java.sourceCompatibility = JavaVersion.VERSION_1_8

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
withJavadocJar()
withSourcesJar()
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release.set(8)
}

tasks.test {
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required = true
}

}

sonarqube {
properties {
property("sonar.sourceEncoding", "UTF-8")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.organization", "worksapplications")
property("sonar.projectKey", "com.worksap.nlp.jdartsclone")
property("sonar.language", "java")
property("sonar.links.homepage", "https://github.com/WorksApplications/jdartsclone")
property("sonar.links.ci", "https://github.com/WorksApplications/jdartsclone/actions")
property("sonar.links.issue", "https://github.com/WorksApplications/jdartsclone/issues")
}
}

spotless {
encoding("UTF-8")
format("misc", {
target(".gitattributes", ".gitignore", ".md")

trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
})
java {
eclipse("4.21").configFile(".formatter/eclipse-formatter.xml")
licenseHeaderFile(".formatter/license-header")
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/WorksApplications/jdartsclone")
credentials {
username = project.findProperty("gpr.user")?.toString() ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.key")?.toString() ?: System.getenv("GITHUB_TOKEN")
}
}
}

publications {
create<MavenPublication>("mavenJava") {
pom {
url = "https://github.com/WorksApplications/jdartsclone"
name = "Darts-clone"
description = project.description

licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}

developers {
developer {
id = "kazuma-t"
name = "Kazuma TAKAOKA"
email = "takaoka_k@worksap.co.jp"
timezone = "Asia/Tokyo"
}
}

scm {
connection = "scm:git:https://github.com/WorksApplications/jdartsclone.git"
developerConnection = "scm:git:ssh://git@github.com:WorksApplications/jdartsclone.git"
url = "https://github.com/WorksApplications/jdartsclone"
}

issueManagement {
system = "Github Issues"
url = "https://github.com/WorksApplications/jdartsclone/issues"
}
}
}
}
}

nexusPublishing {
repositories {
sonatype {
username.set(project.findProperty("maven.user")?.toString() ?: System.getenv("MAVEN_USERNAME"))
password.set(project.findProperty("maven.password")?.toString() ?: System.getenv("MAVEN_USER_PASSWORD"))
}
}
}

signing {
val signingKey = project.findProperty("gpg.key")?.toString() ?: System.getenv("MAVEN_GPG_PRIVATE_KEY")
val signingPassword = project.findProperty("gpg.password")?.toString() ?: System.getenv("MAVEN_GPG_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
setRequired({ (extra["isReleaseVersion"] as Boolean) && gradle.taskGraph.hasTask("publish") })
sign(publishing.publications["mavenJava"])
}
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.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit c1ad746

Please sign in to comment.