Skip to content

Commit

Permalink
Enter Bach 2024 (#196)
Browse files Browse the repository at this point in the history
* Enter Bach 2024

* Read project version from system properties

* Fix and run document action
  • Loading branch information
sormuras authored Apr 22, 2024
1 parent ec6cafc commit 75931bb
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 205 deletions.
1 change: 1 addition & 0 deletions .bach/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out/
var/

*.class
*.jar
30 changes: 0 additions & 30 deletions .bach/bin/bach

This file was deleted.

32 changes: 0 additions & 32 deletions .bach/bin/bach.bat

This file was deleted.

Binary file removed .bach/bin/run.bach.jar
Binary file not shown.
Binary file removed .bach/bin/run.duke.jar
Binary file not shown.
23 changes: 0 additions & 23 deletions .bach/external-modules/junit@5.9.1.modules-locator.properties

This file was deleted.

63 changes: 0 additions & 63 deletions .bach/project/module-info.java

This file was deleted.

20 changes: 0 additions & 20 deletions .bach/project/project/PurejinConfigurator.java

This file was deleted.

5 changes: 5 additions & 0 deletions .bach/src/Build.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Build {
public static void main(String... args) {
Project.ofCurrentWorkingDirectory().build();
}
}
5 changes: 5 additions & 0 deletions .bach/src/Document.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Document {
public static void main(String... args) {
Project.ofCurrentWorkingDirectory().document();
}
}
95 changes: 95 additions & 0 deletions .bach/src/Project.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import java.io.File;
import java.nio.file.Path;
import java.util.List;
import run.bach.Bach;
import run.bach.ToolCall;
import run.bach.ToolRunner;
import run.bach.workflow.Builder;
import run.bach.workflow.Structure;
import run.bach.workflow.Structure.*;
import run.bach.workflow.Workflow;

record Project(Workflow workflow) implements Builder {
static final String VERSION = System.getProperty("--project-version", "11-ea");
static Project ofCurrentWorkingDirectory() {
var basics = new Basics("purejin", VERSION);
var main =
new Space(
"main",
11,
"",
declareModule("main", "se.jbee.inject"),
declareModule("main", "se.jbee.inject.action"),
declareModule("main", "se.jbee.inject.api"),
declareModule("main", "se.jbee.inject.bind"),
declareModule("main", "se.jbee.inject.bootstrap"),
declareModule("main", "se.jbee.inject.container"),
declareModule("main", "se.jbee.inject.contract"),
declareModule("main", "se.jbee.inject.convert"),
declareModule("main", "se.jbee.inject.event"),
declareModule("main", "se.jbee.lang"));
var test =
new Space(
"test",
List.of(main.name()),
0,
List.of(),
new DeclaredModules(
declareModule("test", "se.jbee.junit.assertion"),
declareModule("test", "test.examples"),
declareModule("test", "test.integration")));

return new Project(
new Workflow(
Bach.Folders.ofCurrentWorkingDirectory(),
new Structure(basics, new Spaces(main, test)),
ToolRunner.ofSystem()));
}

private static DeclaredModule declareModule(String space, String module) {
var content = Path.of(module);
return new DeclaredModule(content, content.resolve(space + "/java/module-info.java"));
}

@Override
public ToolCall classesCompilerNewJavacToolCall() {
return ToolCall.of("javac")
.add("-g")
.add("-encoding", "UTF-8")
.add("-parameters")
.add("-X" + "lint:-missing-explicit-ctor,-serial");
}

@Override
public void testerRunJUnitPlatform(ToolCall junit) {
run(junit.add("--details", "NONE").add("--disable-banner"));
}

void document() {
var main = workflow.structure().spaces().space("main");
var moduleSourcePaths = main.modules().toModuleSourcePaths();
var moduleSourcePath = String.join(File.pathSeparator, moduleSourcePaths);
var javadoc =
ToolCall.of("javadoc")
.add("-quiet")
.add("--module", main.modules().names(","))
.add("--module-source-path", moduleSourcePath)
.add("-d", workflow.folders().out("main", "api"))
.add("-no" + "timestamp")
.add("-encoding", "UTF-8")
.add("-use")
.add("-link" + "source")
.add("-X" + "doc" + "lint:-missing")
.add(
"-group",
"API",
"se.jbee.inject:se.jbee.inject.api:se.jbee.inject.bind:se.jbee.inject.lang")
.add("-group", "Container", "se.jbee.inject.bootstrap:se.jbee.inject.container")
.add(
"-group",
"Add-ons",
"se.jbee.inject.action:se.jbee.inject.event:se.jbee.inject.convert:se.jbee.inject.contract");

run(javadoc);
}
}
7 changes: 7 additions & 0 deletions .bach/src/Rebuild.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Rebuild {
public static void main(String... args) {
var project = Project.ofCurrentWorkingDirectory();
project.clean();
project.build();
}
}
1 change: 1 addition & 0 deletions .bach/src/run/bach
Submodule bach added at 743fa0
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
java: [ 17 ]
java: [ 22 ]
language: [ 'java' ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Check out sources'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: 'Set up JDK'
uses: oracle-actions/setup-java@v1
with:
Expand All @@ -37,14 +39,16 @@ jobs:
VERSION=${PROJECT_VERSION}+${SHA7}
echo "VERSION=${VERSION}" >> ${GITHUB_ENV}
- name: 'Build with Bach'
run: .bach/bin/bach --project-version 11-ea-${VERSION} build
run: java --show-version -D--project-version=${VERSION} @build
- name: 'Generate API documentation'
run: java -D--project-version=${VERSION} .bach/src/Document.java
- name: 'Report test summary'
if: always()
uses: test-summary/action@v2
with:
paths: .bach/out/test-reports/**/TEST-*.xml
- name: 'Upload build artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-build-${{ env.VERSION }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

target/
src/doc/
lib/
lib/*.jar
pom.*
*~

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".bach/src/run/bach"]
path = .bach/src/run/bach
url = https://github.com/sormuras/run.bach
10 changes: 0 additions & 10 deletions .idea/libraries/bach_external_modules.xml

This file was deleted.

10 changes: 10 additions & 0 deletions .idea/libraries/lib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/purejin.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 75931bb

Please sign in to comment.