Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# EditorConfig is awesome: https://EditorConfig.org

# File generated by jbang setup@jabrena

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.html]
indent_style = space
indent_size = 4

[*.json]
indent_style = space
indent_size = 4

[*.xml]
indent_style = space
indent_size = 4

[*.java]
indent_style = space
indent_size = 4

[*.yml,*.yaml]
indent_style = space
indent_size = 2

[*.dsl]
indent_style = space
indent_size = 4
36 changes: 20 additions & 16 deletions .github/workflows/build_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: 17
- name: Install Graphviz
run: sudo apt-get -y install graphviz
- name: Gradle caches
Expand All @@ -44,7 +45,7 @@ jobs:
path: ./out
if-no-files-found: error

validate_java_11:
validate_java_17:
runs-on: ubuntu-latest
needs:
- build
Expand All @@ -56,14 +57,15 @@ jobs:
path: ./out
- name: Grant execute permission for cm
run: chmod +x ./out/bin/cm
- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: 17
- name: Execute to check if Java version is compatible
run: ./out/bin/cm

validate_java_17:
validate_java_21:
runs-on: ubuntu-latest
needs:
- build
Expand All @@ -75,14 +77,15 @@ jobs:
path: ./out
- name: Grant execute permission for cm
run: chmod +x ./out/bin/cm
- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Execute to check if Java version is compatible
run: ./out/bin/cm

validate_java_21:
validate_java_24:
runs-on: ubuntu-latest
needs:
- build
Expand All @@ -94,9 +97,10 @@ jobs:
path: ./out
- name: Grant execute permission for cm
run: chmod +x ./out/bin/cm
- name: Set up JDK 21
uses: actions/setup-java@v1
- name: Set up JDK 24
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '24'
- name: Execute to check if Java version is compatible
run: ./out/bin/cm
34 changes: 3 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,4 @@
# Compiled class file
*.class
**/target
**/out

# Build
/build
build/
.gradle/

# 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*

# IntelliJ
/.idea
.cursor/
.DS_Store
1 change: 1 addition & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java=17.0.9-graalce
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ The following examples illustrate the CLI usage.
If you want to contribute to this project you can create a fork and a pull request. The project is built with Gradle, so you can import it as Gradle project within Eclipse or IntelliJ IDEA (or any other IDE supporting Gradle).

```bash
# Use sdkman or install manually JDK 17
sdk env install

./gradlew clean build
./gradlew clean build jacocoTestReport
jwebserver -p 9000 -d "$(pwd)/build/reports/"
./gradlew clean build snapshot
java -jar build/libs/context-mapper-cli-0.1.0-SNAPSHOT.jar
```

## Contributing
Expand All @@ -100,4 +107,3 @@ Contribution is always welcome! Here are some ways how you can contribute:

## Licence
ContextMapper is released under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).

54 changes: 35 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@ plugins {
id 'nebula.release' version '19.0.10'
}

group 'org.contextmapper'
group = 'org.contextmapper'

sourceCompatibility = '11'
targetCompatibility = '11'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

repositories {
mavenCentral()
}

dependencies {
implementation "commons-cli:commons-cli:${commonsCliVersion}"
implementation "org.contextmapper:context-mapper-dsl:${cmlVersion}"
implementation "info.picocli:picocli:${picocliVersion}"

testImplementation "org.junit.jupiter:junit-jupiter-api:${jUnitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${jUnitVersion}"
testImplementation "org.assertj:assertj-core:${assertJVersion}"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jUnitVersion}"
}

application {
mainClassName = 'org.contextmapper.cli.ContextMapperCLI'
applicationName = 'context-mapper-cli'
}
startScripts {
mainClass = 'org.contextmapper.cli.ContextMapperCLI'
applicationName = 'cm'
}

javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
failOnError false
}

jar {
manifest {
attributes (
Expand All @@ -43,21 +47,25 @@ jar {
'Main-Class': 'org.contextmapper.cli.ContextMapperCLI'
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude('META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/DEPENDENCIES')
exclude('META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/services/**')
}

if (!project.hasProperty('signing.secretKeyRingFile')) {
project.ext.'signing.secretKeyRingFile' = "${rootDir}/secret-key.gpg"
}

test {
useJUnitPlatform()

testLogging {
showExceptions true
exceptionFormat "full"
showExceptions = true
exceptionFormat = "full"

showCauses true
showStackTraces true
showCauses = true
showStackTraces = true
}
}

Expand Down Expand Up @@ -146,14 +154,22 @@ signing {
sign(publishing.publications)
}

testing {
suites {
test(JvmTestSuite) {
useJUnitJupiter(jUnitVersion)
}
}
}

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

tasks.withType(CreateStartScripts).each { task ->
task.doLast {
String text = task.windowsScript.text
tasks.withType(CreateStartScripts).configureEach {
doLast {
String text = windowsScript.text
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" })
task.windowsScript.write text
windowsScript.text = text
}
}
65 changes: 65 additions & 0 deletions context_mapper_cli.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Feature: Context Mapper CLI Usage
As a user of the Context Mapper CLI
I want to be able to validate CML files and generate various outputs
So that I can effectively use the tool for my Domain-Driven Design modeling.

Background:
Given the Context Mapper CLI is installed

Scenario: Display help for the validate command
When I run the command `./cm validate -h`
Then the output should contain:
"""
Context Mapper CLI
usage: cm validate
-h,--help Prints this message.
-i,--input <arg> Path to the CML file which you want to validate.
"""

Scenario: Validate a CML file
Given a CML file named "DDD-Sample.cml" exists
When I run the command `./cm validate -i DDD-Sample.cml`
Then the CLI should validate "DDD-Sample.cml" successfully

Scenario: Display help for the generate command
When I run the command `./cm generate -h`
Then the output should contain:
"""
Context Mapper CLI
usage: cm generate
-f,--outputFile <arg> The name of the file that shall be generated
(only used by Freemarker generator, as we cannot
know the file extension).
-g,--generator <arg> The generator you want to call. Use one of the
following values: context-map (Graphical DDD
Context Map), plantuml (PlantUML class-,
component-, and state diagrams.), generic
(Generate generic text with Freemarker template)
-h,--help Prints this message.
-i,--input <arg> Path to the CML file for which you want to
generate output.
-o,--outputDir <arg> Path to the directory into which you want to
generate.
-t,--template <arg> Path to the Freemarker template you want to use.
This parameter is only used if you pass 'generic'
to the 'generator' (-g) parameter.
"""

Scenario: Generate PlantUML output
Given a CML file named "DDD-Sample.cml" exists
And an output directory named "output-directory"
When I run the command `./cm generate -i DDD-Sample.cml -g plantuml -o ./output-directory`
Then PlantUML diagrams should be generated in "./output-directory" from "DDD-Sample.cml"

Scenario: Generate Context Map output
Given a CML file named "DDD-Sample.cml" exists
And an output directory named "output-directory"
When I run the command `./cm generate -i DDD-Sample.cml -g context-map -o ./output-directory`
Then a Context Map should be generated in "./output-directory" from "DDD-Sample.cml"

Scenario: Generate arbitrary text file with Freemarker template
Given a CML file named "DDD-Sample.cml" exists
And an output directory named "output-directory"
And a Freemarker template file named "template.md.ftl"
When I run the command `./cm generate -i DDD-Sample.cml -g generic -o ./output-directory -t template.md.ftl -f glossary.md`
Then a file named "glossary.md" should be generated in "./output-directory" using "template.md.ftl" and "DDD-Sample.cml"
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ ossSnapshotRepository=https://oss.sonatype.org/content/repositories/snapshots/
ossReleaseStagingRepository=https://oss.sonatype.org/service/local/staging/deploy/maven2/

# dependency versions
jUnitVersion=5.9.1
assertJVersion=3.19.0
mockitoVersion=3.9.0
jUnitVersion=5.12.2
assertJVersion=3.27.3
mockitoVersion=5.17.0

commonsCliVersion=1.4
cmlVersion=6.12.0

picocliVersion=4.7.7
Loading