Skip to content

Commit

Permalink
Merge pull request #600 from hexagonkt/develop
Browse files Browse the repository at this point in the history
:Fix build script problems
  • Loading branch information
jaguililla committed Jan 17, 2023
2 parents 5dd9824 + d0c06b0 commit d76eac4
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build

on:
push:
branches-ignore: [ master ]

jobs:
build:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set Up Java
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: temurin
cache: gradle

- name: Update Site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export REMOTE="https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git"
git remote set-url origin "$REMOTE"
git config --global user.name "$GITHUB_ACTOR"
git clone "$REMOTE" --branch gh-pages build/gh-pages
./gradlew --info build
./gradlew --info -x build buildSite
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ kotlin-js-store/
node_modules/
package-lock.json
.env
.sdkmanrc

# System Files
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ task("release") {

doLast {
val release = version.toString()
val actor = System.getenv("GITHUB_ACTOR")

project.exec { commandLine = listOf("git", "config", "--global", "user.name", actor) }
project.exec { commandLine = listOf("git", "tag", "-m", "Release $release", release) }
project.exec { commandLine = listOf("git", "push", "--tags") }
}
Expand Down
89 changes: 46 additions & 43 deletions core/src/main/kotlin/com/hexagonkt/core/Ansi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,96 +8,99 @@ object Ansi {
/** Regex that matches ANSI escape sequences. */
val regex: Regex = """\u001B\[\d+?m""".toRegex()

/** Control Sequence Introducer. */
const val CSI = "\u001B["

/** Disable all options applied before. */
const val RESET = "\u001B[0m"
const val RESET = "${CSI}0m"

/** Set black as the foreground color. */
const val BLACK = "\u001B[30m"
const val BLACK = "${CSI}30m"
/** Set red as the foreground color. */
const val RED = "\u001B[31m"
const val RED = "${CSI}31m"
/** Set green as the foreground color. */
const val GREEN = "\u001B[32m"
const val GREEN = "${CSI}32m"
/** Set yellow as the foreground color. */
const val YELLOW = "\u001B[33m"
const val YELLOW = "${CSI}33m"
/** Set blue as the foreground color. */
const val BLUE = "\u001B[34m"
const val BLUE = "${CSI}34m"
/** Set magenta as the foreground color. */
const val MAGENTA = "\u001B[35m"
const val MAGENTA = "${CSI}35m"
/** Set cyan as the foreground color. */
const val CYAN = "\u001B[36m"
const val CYAN = "${CSI}36m"
/** Set white as the foreground color. */
const val WHITE = "\u001B[37m"
const val WHITE = "${CSI}37m"
/** Set back the default foreground color. */
const val DEFAULT = "\u001B[39m"
const val DEFAULT = "${CSI}39m"

/** Set black as the background color. */
const val BLACK_BG = "\u001B[40m"
const val BLACK_BG = "${CSI}40m"
/** Set red as the background color. */
const val RED_BG = "\u001B[41m"
const val RED_BG = "${CSI}41m"
/** Set green as the background color. */
const val GREEN_BG = "\u001B[42m"
const val GREEN_BG = "${CSI}42m"
/** Set yellow as the background color. */
const val YELLOW_BG = "\u001B[43m"
const val YELLOW_BG = "${CSI}43m"
/** Set blue as the background color. */
const val BLUE_BG = "\u001B[44m"
const val BLUE_BG = "${CSI}44m"
/** Set magenta as the background color. */
const val MAGENTA_BG = "\u001B[45m"
const val MAGENTA_BG = "${CSI}45m"
/** Set cyan as the background color. */
const val CYAN_BG = "\u001B[46m"
const val CYAN_BG = "${CSI}46m"
/** Set white as the background color. */
const val WHITE_BG = "\u001B[47m"
const val WHITE_BG = "${CSI}47m"
/** Set back the default background color. */
const val DEFAULT_BG = "\u001B[49m"
const val DEFAULT_BG = "${CSI}49m"

/** Set bright black as the foreground color. */
const val BRIGHT_BLACK = "\u001B[90m"
const val BRIGHT_BLACK = "${CSI}90m"
/** Set bright red as the foreground color. */
const val BRIGHT_RED = "\u001B[91m"
const val BRIGHT_RED = "${CSI}91m"
/** Set bright green as the foreground color. */
const val BRIGHT_GREEN = "\u001B[92m"
const val BRIGHT_GREEN = "${CSI}92m"
/** Set bright yellow as the foreground color. */
const val BRIGHT_YELLOW = "\u001B[93m"
const val BRIGHT_YELLOW = "${CSI}93m"
/** Set bright blue as the foreground color. */
const val BRIGHT_BLUE = "\u001B[94m"
const val BRIGHT_BLUE = "${CSI}94m"
/** Set bright magenta as the foreground color. */
const val BRIGHT_MAGENTA = "\u001B[95m"
const val BRIGHT_MAGENTA = "${CSI}95m"
/** Set bright cyan as the foreground color. */
const val BRIGHT_CYAN = "\u001B[96m"
const val BRIGHT_CYAN = "${CSI}96m"
/** Set bright white as the foreground color. */
const val BRIGHT_WHITE = "\u001B[97m"
const val BRIGHT_WHITE = "${CSI}97m"

/** Set bright black as the background color. */
const val BRIGHT_BLACK_BG = "\u001B[100m"
const val BRIGHT_BLACK_BG = "${CSI}100m"
/** Set bright red as the background color. */
const val BRIGHT_RED_BG = "\u001B[101m"
const val BRIGHT_RED_BG = "${CSI}101m"
/** Set bright green as the background color. */
const val BRIGHT_GREEN_BG = "\u001B[102m"
const val BRIGHT_GREEN_BG = "${CSI}102m"
/** Set bright yellow as the background color. */
const val BRIGHT_YELLOW_BG = "\u001B[103m"
const val BRIGHT_YELLOW_BG = "${CSI}103m"
/** Set bright blue as the background color. */
const val BRIGHT_BLUE_BG = "\u001B[104m"
const val BRIGHT_BLUE_BG = "${CSI}104m"
/** Set bright magenta as the background color. */
const val BRIGHT_MAGENTA_BG = "\u001B[105m"
const val BRIGHT_MAGENTA_BG = "${CSI}105m"
/** Set bright cyan as the background color. */
const val BRIGHT_CYAN_BG = "\u001B[106m"
const val BRIGHT_CYAN_BG = "${CSI}106m"
/** Set bright white as the background color. */
const val BRIGHT_WHITE_BG = "\u001B[107m"
const val BRIGHT_WHITE_BG = "${CSI}107m"

/** Enable bold text. */
const val BOLD = "\u001B[1m"
const val BOLD = "${CSI}1m"
/** Enable underline text. */
const val UNDERLINE = "\u001B[4m"
const val UNDERLINE = "${CSI}4m"
/** Enable blinking text. */
const val BLINK = "\u001B[5m"
const val BLINK = "${CSI}5m"
/** Enable inverse color text. */
const val INVERSE = "\u001B[7m"
const val INVERSE = "${CSI}7m"

/** Disable bold text. */
const val BOLD_OFF = "\u001B[21m"
const val BOLD_OFF = "${CSI}21m"
/** Disable underline text. */
const val UNDERLINE_OFF = "\u001B[24m"
const val UNDERLINE_OFF = "${CSI}24m"
/** Disable blinking text. */
const val BLINK_OFF = "\u001B[25m"
const val BLINK_OFF = "${CSI}25m"
/** Disable inverse color text. */
const val INVERSE_OFF = "\u001B[27m"
const val INVERSE_OFF = "${CSI}27m"
}
1 change: 1 addition & 0 deletions core/src/test/kotlin/com/hexagonkt/core/AnsiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class AnsiTest {
logger.info { "${message}${Ansi.RESET} | normal text" }
}

test("${Ansi.CSI}30m black")
test("${Ansi.BLACK}black")
test("${Ansi.RED}red")
test("${Ansi.GREEN}green")
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.warning.mode=all
org.gradle.console=plain

# Gradle
version=2.4.3
version=2.4.4
group=com.hexagonkt
description=The atoms of your platform

Expand Down Expand Up @@ -42,7 +42,7 @@ mockkVersion=1.13.3
junitVersion=5.9.2
gatlingVersion=3.9.0
jmhVersion=1.36
mkdocsMaterialVersion=9.0.4
mkdocsMaterialVersion=9.0.5
mermaidDokkaVersion=0.4.2
nativeToolsVersion=0.9.19

Expand All @@ -61,8 +61,8 @@ logbackVersion=1.4.5
jacksonVersion=2.14.1
dslJsonVersion=1.10.0

# templates_pebble
pebbleVersion=3.2.0

# templates_freemarker
freemarkerVersion=2.3.31

# templates_pebble
pebbleVersion=3.2.0
21 changes: 20 additions & 1 deletion gradle/native.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,29 @@ graalvmNative {
}

tasks.register("upx", Exec) {
group = "distribution"
description = "Compress the native executable using 'upx'."
dependsOn("nativeCompile")

final String source = "$buildDir/native/nativeCompile/${project.name}"
final String target = "$buildDir/${project.name}"
final String target = "$buildDir/native/${project.name}"
final String command = "upx $source -o $target"
commandLine(command.split(" "))

doFirst {
file(target).delete()
}
}

tasks.register("zipNative", Zip) {
group = "distribution"
description = "Compress native executable in a ZIP file."
dependsOn("upx")

final String os = System.getProperty("os.name").toLowerCase()
final String arch = System.getProperty("os.arch").toLowerCase()
from("$buildDir/native")
include(project.name)
archiveFileName.set("${project.name}-${project.version}-${os}-${arch}.zip")
destinationDirectory.set(buildDir.toPath().resolve("distributions").toFile())
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ include(
"http_server_jetty",
"http_server_netty",
"http_server_netty_epoll",
"templates_pebble",
"templates_freemarker",
"templates_pebble",

// Testing
"http_test",
Expand Down
5 changes: 5 additions & 0 deletions site/pages/gradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ This script sets up the build to add [GraalVM] configuration files for [native i
into JAR files (for library projects), and also allows to easily generate a native image for an
application.

The defined tasks are:

* upx: compress the native executable using 'upx'.
* zipNative: compress native executable in a ZIP file.

To use it you must apply the `$gradleScripts/native.gradle` script to your `build.gradle` file. It
must be applied after the Kotlin plugin.

Expand Down

0 comments on commit d76eac4

Please sign in to comment.