Skip to content

Commit

Permalink
Initial implementation of code generation homework
Browse files Browse the repository at this point in the history
  • Loading branch information
arminzavada committed Nov 1, 2024
1 parent de5636a commit 912917f
Show file tree
Hide file tree
Showing 39 changed files with 1,103 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Continuous Integration
on:
push:
branches:
- '**'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: adopt
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Check phase 1
run: ./gradlew build -PhomeworkStage=1
- name: Check phase 2
run: ./gradlew build -PhomeworkStage=2
- name: Check phase 3
run: ./gradlew build -PhomeworkStage=3
- name: Check phase 4
run: ./gradlew build -PhomeworkStage=4
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*._trace
.idea/
.gradle/
build/
**/src/gen/
3 changes: 0 additions & 3 deletions README.md

This file was deleted.

1 change: 0 additions & 1 deletion VersionControl.md

This file was deleted.

18 changes: 18 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

val libs = the<LibrariesForLibs>()

dependencies {
// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.python.gradle.plugin)
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package hu.bme.mit.ase.gradle.conventions

import com.pswidersk.gradle.python.VenvTask
import org.gradle.api.tasks.Sync
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.registering

plugins {
id("hu.bme.mit.ase.gradle.conventions.jvm")
id("com.pswidersk.python-plugin")
}

val srcGenJava = "src/gen/java"

sourceSets.main {
java.srcDir(srcGenJava)
}

val installPythonPackages by tasks.registering(VenvTask::class) {
venvExec = "pip3"

args = listOf(
"install",
"jinja2",
)
}

val syncGeneratorScripts by tasks.registering(Sync::class) {
from(rootProject.layout.projectDirectory.dir("python-scripts"))
into(project.layout.buildDirectory.dir("python-scripts"))
}

val syncModels by tasks.registering(Sync::class) {
from(rootProject.layout.projectDirectory.dir("models"))
into(project.layout.buildDirectory.dir("models"))
}

val syncTemplates by tasks.registering(Sync::class) {
from(rootProject.layout.projectDirectory.dir("jinja-templates"))
into(project.layout.buildDirectory.dir("jinja-templates"))
}

val generate by tasks.registering(VenvTask::class) {
inputs.files(syncGeneratorScripts.get().outputs)
inputs.files(syncModels.get().outputs)
inputs.files(syncTemplates.get().outputs)

dependsOn(installPythonPackages)

outputs.dir(srcGenJava)
}

tasks.compileJava {
inputs.files(generate.get().outputs)
}

tasks.clean {
delete(srcGenJava)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package hu.bme.mit.ase.gradle.conventions

import org.gradle.accessors.dm.LibrariesForLibs

plugins {
`java-library`
`java-test-fixtures`
java
}

val libs = the<LibrariesForLibs>()

repositories {
mavenCentral()
}

java.toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}

tasks {
test {
useJUnitPlatform()
testLogging.showStandardStreams = true
}
}

dependencies {
implementation(libs.slf4j.api)

runtimeOnly(libs.slf4j.log4j.impl)

testImplementation(libs.junit.jupiter.core)
testImplementation(libs.junit.jupiter.params)

testRuntimeOnly(libs.junit.jupiter.engine)
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
org.gradle.parallel=true

# Change the stage here to execute additional tests!
homeworkStage=0
16 changes: 16 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
slf4j = "1.7.25"
log4j = "2.23.1"
jUnit = "5.10.0"
python-gradle-plugin = "2.7.3"

[libraries]
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
slf4j-log4j-impl = { group = "org.apache.logging.log4j", name = "log4j-slf4j-impl", version.ref = "log4j" }
junit-jupiter-core = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "jUnit" }
junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "jUnit" }
junit-jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "jUnit" }
python-gradle-plugin = { group = "com.pswidersk", name = "python-gradle-plugin", version.ref = "python-gradle-plugin" }
Loading

0 comments on commit 912917f

Please sign in to comment.