Skip to content

Commit

Permalink
Merge pull request #14 from fluz/adopt_gradle
Browse files Browse the repository at this point in the history
Gradle adoption to build cv project
  • Loading branch information
fluz committed Oct 6, 2023
2 parents 073278e + 79fecd7 commit b70bceb
Show file tree
Hide file tree
Showing 12 changed files with 575 additions and 73 deletions.
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

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ dist
.vscode/
build/
.DS_Store
.ninja_log

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
51 changes: 35 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# [START - building phase]
FROM debian:bullseye
LABEL maintainer="Fernando Luz <prof.fernando.luz@gmail.com>"

# install debian packages:
ENV DEBIAN_FRONTEND=noninteractive
RUN set -e -x; \
apt-get update; \
apt-get install -y --no-install-recommends \
pandoc ninja-build \
openjdk-17-jre \
pandoc \
texlive texlive-latex-extra texlive-plain-generic texlive-latex-recommended cm-super \
python3-yaml python3-jinja2 \
locales inkscape
Expand All @@ -17,20 +17,39 @@ RUN set -e -x; \
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen; locale-gen
ENV LC_ALL=en_US.UTF-8

# copy host to docker
ENV APP_HOME=/app
RUN ["mkdir", "${APP_HOME}"]

WORKDIR ${APP_HOME}

COPY build.ninja ${APP_HOME}
COPY README.md ${APP_HOME}
COPY fluz.yml ${APP_HOME}
COPY build_cv.sh ${APP_HOME}
COPY assets ${APP_HOME}/assets
COPY moderncvclassic ${APP_HOME}/moderncvclassic
COPY ceevee ${APP_HOME}/ceevee
COPY markdown ${APP_HOME}/markdown
COPY tools ${APP_HOME}/tools
COPY DevResume ${APP_HOME}/DevResume
COPY pandoc-bootstrap ${APP_HOME}/pandoc-bootstrap
COPY europasscv ${APP_HOME}/europasscv
COPY . ${APP_HOME}

# RUN ./gradlew tasks cvAll
# [END - building phase]



# # install debian packages:
# ENV DEBIAN_FRONTEND=noninteractive


# # copy host to docker
# RUN ["mkdir", "${APP_HOME}"]
# WORKDIR ${APP_HOME}

# # COPY build.ninja ${APP_HOME}
# COPY gradlew ${APP_HOME}
# COPY gradle ${APP_HOME}/gradle
# COPY build.gradle.kts ${APP_HOME}
# COPY settings.gradle.kts ${APP_HOME}
# # COPY README.md ${APP_HOME}
# COPY fluz.yml ${APP_HOME}
# # COPY build_cv.sh ${APP_HOME}
# COPY assets ${APP_HOME}/assets
# COPY moderncvclassic ${APP_HOME}/moderncvclassic
# COPY ceevee ${APP_HOME}/ceevee
# COPY markdown ${APP_HOME}/markdown
# COPY tools ${APP_HOME}/tools
# COPY DevResume ${APP_HOME}/DevResume
# COPY pandoc-bootstrap ${APP_HOME}/pandoc-bootstrap
# COPY europasscv ${APP_HOME}/europasscv
166 changes: 166 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.3/samples
*/

import java.nio.file.Files

tasks.register<Exec>("genMarkdown") {
logger.info("Generating Markdown CV version")
group = "CV generation"
description = "Generates Markdown CV version."

// Store target directory into a variable to avoid project reference in the configuration cache
val directory = file("build/markdown")

doFirst {
Files.createDirectories(directory.toPath())
}
commandLine("./tools/jinja2-render", "-y", "fluz.yml",
"-o", "build/markdown/cv.md",
"markdown/cv.md.jinja"
)
}

tasks.register<Exec>("genMarkdownHtml") {
logger.info("Generating Markdown HTML CV version")
group = "CV generation"
description = "Generates Markdown HTML CV version."
dependsOn("genMarkdown")

commandLine("pandoc", "-f", "markdown", "-t", "html",
"--metadata", "title='Fernando Luz'", "-s",
"--template", "pandoc-bootstrap/template.html", "--css", "pandoc-bootstrap/template.css",
"-o", "build/markdown/cv.html",
"build/markdown/cv.md")

}

tasks.register<Exec>("genMarkdownTxt") {
logger.info("Generating Markdown TXT CV version")
group = "CV generation"
description = "Generates Markdown TXT CV version."
dependsOn("genMarkdown")

commandLine("pandoc", "-f", "markdown", "-t", "plain",
"-V", "'title:Fernando Luz'", "-s",
"-o", "build/markdown/cv.txt",
"build/markdown/cv.md")

}

tasks.register<Exec>("_europassTex") {
logger.info("Generation Europass CV [tex]")
group = "CV helper"
description = "Generates Europass LaTex CV version."

// Store target directory into a variable to avoid project reference in the configuration cache
val directory = file("build/europasscv")

doFirst {
Files.createDirectories(directory.toPath())
}
commandLine("./tools/jinja2-render", "-y", "fluz.yml",
"-o", "build/europasscv/cv.tex",
"europasscv/cv.tex.jinja")

}

tasks.register<Copy>("_copyEuropassCls") {
logger.info("Generation Europass CV [pdf]")
group = "CV helper"
description = "copy necessary files to compile Europass CV Pdf"

from(file("europasscv/europasscv.cls"))
into("build/europasscv/europasscv.cls")
}

tasks.register<Exec>("genEuropassPdf") {
logger.info("Generation Europass CV [pdf]")
group = "CV generation"
description = "Generates Europass Pdf CV version."
dependsOn("_europassTex","_copyEuropassCls")

commandLine("./tools/cddo", "build/europasscv/cv.tex", "${project.rootDir}/tools/latexer")
}

tasks.register<Copy>("_copyDevResumeAssets") {
logger.info("Helper function to DevResume")
group = "CV helper"
description = "copy necessary files execute DevResume view"

from(file("Assets"))
into("build/Assets")
}

tasks.register<Exec>("genDevResume") {
logger.info("Generating DevResume")
group = "CV generation"
description = "Generates DevResume CV version."
dependsOn("_copyDevResumeAssets")

// Store target directory into a variable to avoid project reference in the configuration cache
val directory = file("build/DevResume")

doFirst {
Files.createDirectories(directory.toPath())
}
commandLine("./tools/jinja2-render", "-y", "fluz.yml",
"-o", "build/DevResume/index.html",
"DevResume/cv.html.jinja")
}

tasks.register<Exec>("genCeeVee") {
logger.info("Generating CeeVee")
group = "CV generation"
description = "Generates CeeVee CV version."

// Store target directory into a variable to avoid project reference in the configuration cache
val directory = file("build/ceevee")

doFirst {
Files.createDirectories(directory.toPath())
}
commandLine("./tools/jinja2-render", "-y", "fluz.yml",
"-o", "build/ceevee/index.html",
"ceevee/cv.html.jinja")
}

tasks.register<Exec>("_modernCVClassicTex") {
logger.info("Generating Modern CV Classic")
group = "CV helper"
description = "Generates Modern CV Classic LaTex version."

// Store target directory into a variable to avoid project reference in the configuration cache
val directory = file("build/moderncvclassic")

doFirst {
Files.createDirectories(directory.toPath())
}
commandLine("./tools/jinja2-render", "-y", "fluz.yml",
"-o", "build/moderncvclassic/cv.tex",
"moderncvclassic/cv.tex.jinja")

}

tasks.register<Exec>("genModernCVClassicPdf") {
logger.info("Generation Modern CV Classic [pdf]")
group = "CV generation"
description = "Generates Modern CV Classic Pdf version."

dependsOn("_modernCVClassicTex")

commandLine("./tools/cddo", "build/moderncvclassic/cv.tex", "${project.rootDir}/tools/latexer")
}

tasks.register("cvAll") {
logger.info("Generation All versions")
group = "CV generation"
description = "Generates all versions."

dependsOn(provider {
tasks.filter { task -> task.name.startsWith("gen") }
})
}
54 changes: 0 additions & 54 deletions build.ninja

This file was deleted.

2 changes: 1 addition & 1 deletion build_cv.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# generate cv view's
ninja -v
./gradlew tasks cvAll

# copy assets to build file
cp -r ./assets ./build/assets
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ services:
cv:
build: .
command: >
sh -cx "ninja -v
&& cp -r ./assets ./build/assets
sh -cx "./gradlew tasks cvAll
&& cp ./build/DevResume/index.html ./build/index.html
&& sed -i 's|\\.\\./|\\./|g' ./build/index.html"
volumes:
Expand Down
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 b70bceb

Please sign in to comment.