Compare commits
7 commits
c103a85140
...
45581b8001
Author | SHA1 | Date | |
---|---|---|---|
45581b8001 | |||
f26f687b58 | |||
98d6c5c659 | |||
b50da16e74 | |||
66f1ac9218 | |||
ecfde209af | |||
25151b4af9 |
36 changed files with 662 additions and 44 deletions
32
.github/workflows/bld.yml
vendored
Normal file
32
.github/workflows/bld.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: bld-ci
|
||||||
|
|
||||||
|
on: [ push, pull_request, workflow_dispatch ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-bld-project:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java-version: [ 17, 19, 20 ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ matrix.java-version }}
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
java-version: ${{ matrix.java-version }}
|
||||||
|
|
||||||
|
- name: Grant execute permission for bld
|
||||||
|
run: chmod +x bld
|
||||||
|
|
||||||
|
- name: Download the dependencies
|
||||||
|
run: ./bld download
|
||||||
|
|
||||||
|
- name: Run tests with bld
|
||||||
|
run: ./bld compile test
|
57
.github/workflows/pages.yml
vendored
Normal file
57
.github/workflows/pages.yml
vendored
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
name: javadocs-pages
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Runs on pushes targeting the default branch
|
||||||
|
push:
|
||||||
|
branches: ["master"]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
# Allow one concurrent deployment
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Single deploy job since we're just deploying
|
||||||
|
deploy:
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Build Javadocs
|
||||||
|
run: ./bld download clean javadoc
|
||||||
|
|
||||||
|
- name: Setup Pages
|
||||||
|
uses: actions/configure-pages@v3
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-pages-artifact@v1
|
||||||
|
with:
|
||||||
|
# Upload generated Javadocs repository
|
||||||
|
path: 'build/javadoc/'
|
||||||
|
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v1
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -53,3 +53,5 @@ atlassian-ide-plugin.xml
|
||||||
|
|
||||||
# Editor-based Rest Client
|
# Editor-based Rest Client
|
||||||
.idea/httpRequests
|
.idea/httpRequests
|
||||||
|
|
||||||
|
local.properties
|
||||||
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -7,6 +7,8 @@
|
||||||
<pattern value="rife.bld.extension.GeneratedVersionOperation" />
|
<pattern value="rife.bld.extension.GeneratedVersionOperation" />
|
||||||
<pattern value="rife.bld.extension.GeneratedVersionOperation" method="packageName" />
|
<pattern value="rife.bld.extension.GeneratedVersionOperation" method="packageName" />
|
||||||
<pattern value="rife.bld.extension.GeneratedVersionOperation" method="projectName" />
|
<pattern value="rife.bld.extension.GeneratedVersionOperation" method="projectName" />
|
||||||
|
<pattern value="rife.bld.extension.GeneratedVersionOperationBuild" />
|
||||||
|
<pattern value="rife.bld.extension.GeneratedVersionOperationBuild" method="pmd" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
|
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
69
README.md
69
README.md
|
@ -1 +1,68 @@
|
||||||
# TBD
|
# [Bld](https://rife2.com/bld) Extension to Generate Project Version Data
|
||||||
|
|
||||||
|
|
||||||
|
[](http://opensource.org/licenses/BSD-3-Clause)
|
||||||
|
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
||||||
|
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-generated-version)
|
||||||
|
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-generated-version)
|
||||||
|
[](https://github.com/rife2/bld-generated-version/actions/workflows/bld.yml)
|
||||||
|
|
||||||
|
To automatically create a generated version class using the default template in your project on compile:
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
public void compile() throws Exception {
|
||||||
|
genver();
|
||||||
|
super.compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Generates version class")
|
||||||
|
public void genver() throws Exception {
|
||||||
|
new GeneratedVersionOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
./bld compile
|
||||||
|
```
|
||||||
|
|
||||||
|
- [View Examples](https://github.com/rife2/bld-generated-version/tree/master/examples)
|
||||||
|
|
||||||
|
## Version Class Template
|
||||||
|
|
||||||
|
This is the default template:
|
||||||
|
|
||||||
|
```java
|
||||||
|
package {{v packageName/}};
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public final class {{v className/}} {
|
||||||
|
public static final String PROJECT = "{{v project/}}";
|
||||||
|
public static final Date BUILD_DATE = new Date({{v epoch/}}L);
|
||||||
|
public static final int MAJOR = {{v major/}};
|
||||||
|
public static final int MINOR = {{v minor/}};
|
||||||
|
public static final int REVISION = {{v revision/}};
|
||||||
|
public static final String QUALIFIER = "{{v qualifier/}}";
|
||||||
|
public static final String VERSION = "{{v version/}}";
|
||||||
|
|
||||||
|
private {{v className/}}() {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Custom Template
|
||||||
|
You can specified your own template using some or all of the template value tags, as follows:
|
||||||
|
|
||||||
|
```java
|
||||||
|
@BuildCommand(summary = "Generates version class")
|
||||||
|
public void genver() throws Exception {
|
||||||
|
new GeneratedVersionOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.classTemplate(new File(".", "myversion.txt"))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Please check the [GeneratedVersionOperation documentation](https://rife2.github.io/bld-generated-version/rife/bld/extension/GeneratedVersionOperation.html#method-summary) for all available configuration options.
|
||||||
|
|
55
example/.gitignore
vendored
Normal file
55
example/.gitignore
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
.gradle
|
||||||
|
.DS_Store
|
||||||
|
build
|
||||||
|
lib/bld/**
|
||||||
|
lib/compile/**
|
||||||
|
lib/runtime/**
|
||||||
|
lib/standalone/**
|
||||||
|
lib/test/**
|
||||||
|
!bld-wrapper.jar
|
||||||
|
!bld-wrapper.properties
|
||||||
|
|
||||||
|
# IDEA ignores
|
||||||
|
|
||||||
|
# User-specific
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
3
example/.idea/.gitignore
generated
vendored
Normal file
3
example/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
1
example/.idea/.name
generated
Normal file
1
example/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
bld-generated-version-example
|
29
example/.idea/app.iml
generated
Normal file
29
example/.idea/app.iml
generated
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/main" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/test" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/src/main/resources/templates" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library" scope="RUNTIME">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="library" name="compile" level="project" />
|
||||||
|
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="test" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
14
example/.idea/bld.iml
generated
Normal file
14
example/.idea/bld.iml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<output url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/bld" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/src/bld">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="bld" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
example/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
example/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="created" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
17
example/.idea/libraries/bld.xml
generated
Normal file
17
example/.idea/libraries/bld.xml
generated
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="bld">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
|
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$USER_HOME$/.rife2/dist/rife2-1.6.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
<excluded>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
</excluded>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
13
example/.idea/libraries/compile.xml
generated
Normal file
13
example/.idea/libraries/compile.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="compile">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/compile" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
example/.idea/libraries/runtime.xml
generated
Normal file
14
example/.idea/libraries/runtime.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="runtime">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/main/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/runtime" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
14
example/.idea/libraries/test.xml
generated
Normal file
14
example/.idea/libraries/test.xml
generated
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="test">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
<root url="file://$PROJECT_DIR$/src/test/resources" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/lib/test" />
|
||||||
|
</SOURCES>
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
|
||||||
|
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
|
||||||
|
</library>
|
||||||
|
</component>
|
13
example/.idea/misc.xml
generated
Normal file
13
example/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<pattern value="com.example.SampleBuild" method="genver" />
|
||||||
|
<pattern value="com.example.SampleBuild" />
|
||||||
|
</component>
|
||||||
|
<component name="PDMPlugin">
|
||||||
|
<option name="skipTestSources" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build" />
|
||||||
|
</component>
|
||||||
|
</project>
|
9
example/.idea/modules.xml
generated
Normal file
9
example/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
example/.idea/runConfigurations/Run Main.xml
generated
Normal file
9
example/.idea/runConfigurations/Run Main.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Run Main" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||||
|
<option name="MAIN_CLASS_NAME" value="com.example.SampleMain" />
|
||||||
|
<module name="app" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
13
example/.idea/runConfigurations/Run Tests.xml
generated
Normal file
13
example/.idea/runConfigurations/Run Tests.xml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Run Tests" type="JUnit" factoryName="JUnit">
|
||||||
|
<module name="app" />
|
||||||
|
<option name="PACKAGE_NAME" value="moog" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="com.example" />
|
||||||
|
<option name="METHOD_NAME" value="" />
|
||||||
|
<option name="TEST_OBJECT" value="directory" />
|
||||||
|
<dir value="$PROJECT_DIR$/src/test/java" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
6
example/.idea/vcs.xml
generated
Normal file
6
example/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
24
example/.vscode/launch.json
vendored
Normal file
24
example/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Run Main",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "com.example.SampleMain"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Run Tests",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "org.junit.platform.console.ConsoleLauncher",
|
||||||
|
"args": [
|
||||||
|
"--details=verbose",
|
||||||
|
"--scan-classpath",
|
||||||
|
"--disable-banner",
|
||||||
|
"--disable-ansi-colors",
|
||||||
|
"--exclude-engine=junit-platform-suite",
|
||||||
|
"--exclude-engine=junit-vintage"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
example/.vscode/settings.json
vendored
Normal file
15
example/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"java.project.sourcePaths": [
|
||||||
|
"src/main/java",
|
||||||
|
"src/main/resources",
|
||||||
|
"src/test/java",
|
||||||
|
"src/bld/java"
|
||||||
|
],
|
||||||
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
|
"java.project.referencedLibraries": [
|
||||||
|
"${HOME}/.rife2/dist/rife2-1.6.1.jar",
|
||||||
|
"lib/compile/*.jar",
|
||||||
|
"lib/runtime/*.jar",
|
||||||
|
"lib/test/*.jar"
|
||||||
|
]
|
||||||
|
}
|
2
example/bld
Executable file
2
example/bld
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.SampleBuild "$@"
|
4
example/bld.bat
Normal file
4
example/bld.bat
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@echo off
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.SampleBuild %*
|
BIN
example/lib/bld/bld-wrapper.jar
Normal file
BIN
example/lib/bld/bld-wrapper.jar
Normal file
Binary file not shown.
6
example/lib/bld/bld-wrapper.properties
Normal file
6
example/lib/bld/bld-wrapper.properties
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
bld.downloadExtensionJavadoc=false
|
||||||
|
bld.downloadExtensionSources=true
|
||||||
|
bld.extensions=com.uwyn.rife2:bld-generated-version:0.9.0-SNAPSHOT
|
||||||
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2,RIFE2_SNAPSHOTS
|
||||||
|
rife2.downloadLocation=
|
||||||
|
rife2.version=1.6.1
|
17
example/myversion.txt
Normal file
17
example/myversion.txt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package {{v packageName/}};
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public final class {{v className/}} {
|
||||||
|
public static final String PROJECT = "{{v project/}}";
|
||||||
|
public static final Date BUILD_DATE = new Date({{v epoch/}}L);
|
||||||
|
public static final int MAJOR = {{v major/}};
|
||||||
|
public static final int MINOR = {{v minor/}};
|
||||||
|
public static final int REVISION = {{v revision/}};
|
||||||
|
public static final String QUALIFIER = "{{v qualifier/}}";
|
||||||
|
public static final String VERSION = "{{v version/}}";
|
||||||
|
|
||||||
|
private {{v className/}}() {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
|
}
|
||||||
|
}
|
45
example/src/bld/java/com/example/SampleBuild.java
Normal file
45
example/src/bld/java/com/example/SampleBuild.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import rife.bld.BuildCommand;
|
||||||
|
import rife.bld.Project;
|
||||||
|
import rife.bld.extension.GeneratedVersionOperation;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
|
||||||
|
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
|
||||||
|
import static rife.bld.dependencies.Scope.test;
|
||||||
|
|
||||||
|
public class SampleBuild extends Project {
|
||||||
|
public SampleBuild() {
|
||||||
|
pkg = "com.example";
|
||||||
|
name = "Sample";
|
||||||
|
mainClass = "com.example.SampleMain";
|
||||||
|
version = version(1, 0, 1, "rc1");
|
||||||
|
|
||||||
|
downloadSources = true;
|
||||||
|
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||||
|
scope(test)
|
||||||
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
|
||||||
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new SampleBuild().start(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void compile() throws Exception {
|
||||||
|
genver();
|
||||||
|
super.compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Generates version class")
|
||||||
|
public void genver() throws Exception {
|
||||||
|
new GeneratedVersionOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
// .classTemplate(new File(".", "myversion.txt"))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
17
example/src/main/java/com/example/GeneratedVersion.java
Normal file
17
example/src/main/java/com/example/GeneratedVersion.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public final class GeneratedVersion {
|
||||||
|
public static final String PROJECT = "Sample";
|
||||||
|
public static final Date BUILD_DATE = new Date(1682700481013L);
|
||||||
|
public static final int MAJOR = 1;
|
||||||
|
public static final int MINOR = 0;
|
||||||
|
public static final int REVISION = 1;
|
||||||
|
public static final String QUALIFIER = "rc1";
|
||||||
|
public static final String VERSION = "1.0.1-rc1";
|
||||||
|
|
||||||
|
private GeneratedVersion() {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
|
}
|
||||||
|
}
|
22
example/src/main/java/com/example/SampleMain.java
Normal file
22
example/src/main/java/com/example/SampleMain.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class SampleMain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US);
|
||||||
|
|
||||||
|
System.out.println("-----------------------------------------------------");
|
||||||
|
|
||||||
|
System.out.println(" Version: " + GeneratedVersion.PROJECT + ' ' + GeneratedVersion.VERSION);
|
||||||
|
|
||||||
|
System.out.println(" Built on: " + sdf.format(GeneratedVersion.BUILD_DATE));
|
||||||
|
System.out.println(" Major: " + GeneratedVersion.MAJOR);
|
||||||
|
System.out.println(" Minor: " + GeneratedVersion.MINOR);
|
||||||
|
System.out.println(" Revision: " + GeneratedVersion.REVISION);
|
||||||
|
System.out.println(" Qualifier:: " + GeneratedVersion.QUALIFIER);
|
||||||
|
|
||||||
|
System.out.println("-----------------------------------------------------");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,20 @@
|
||||||
package rife.bld.extension;
|
package rife.bld.extension;
|
||||||
|
|
||||||
import rife.bld.BaseProject;
|
|
||||||
import rife.bld.BuildCommand;
|
import rife.bld.BuildCommand;
|
||||||
|
import rife.bld.Project;
|
||||||
|
import rife.bld.publish.PublishDeveloper;
|
||||||
|
import rife.bld.publish.PublishLicense;
|
||||||
|
import rife.bld.publish.PublishScm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
|
|
||||||
import static rife.bld.dependencies.Scope.compile;
|
import static rife.bld.dependencies.Scope.compile;
|
||||||
import static rife.bld.dependencies.Scope.test;
|
import static rife.bld.dependencies.Scope.test;
|
||||||
|
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
|
||||||
|
import static rife.bld.operations.TemplateType.TXT;
|
||||||
|
|
||||||
public class GeneratedVersionOperationBuild extends BaseProject {
|
public class GeneratedVersionOperationBuild extends Project {
|
||||||
public GeneratedVersionOperationBuild() {
|
public GeneratedVersionOperationBuild() {
|
||||||
pkg = "rife.bld.extension";
|
pkg = "rife.bld.extension";
|
||||||
name = "GeneratedVersionOperation";
|
name = "GeneratedVersionOperation";
|
||||||
|
@ -27,6 +31,33 @@ public class GeneratedVersionOperationBuild extends BaseProject {
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)))
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)))
|
||||||
.include(dependency("org.assertj:assertj-joda-time:2.2.0"));
|
.include(dependency("org.assertj:assertj-joda-time:2.2.0"));
|
||||||
|
|
||||||
|
precompileOperation()
|
||||||
|
.templateTypes(TXT);
|
||||||
|
|
||||||
|
javadocOperation()
|
||||||
|
.javadocOptions()
|
||||||
|
.docLint(NO_MISSING)
|
||||||
|
.link("https://rife2.github.io/rife2/")
|
||||||
|
.link("https://javadoc.io/doc/net.sourceforge.pmd/pmd-core/latest/");
|
||||||
|
|
||||||
|
publishOperation()
|
||||||
|
.repository(MAVEN_LOCAL)
|
||||||
|
// .repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
|
||||||
|
.info()
|
||||||
|
.groupId("com.uwyn.rife2")
|
||||||
|
.artifactId("bld-generated-version")
|
||||||
|
.description("bld Extension to Generate Project Version Data")
|
||||||
|
.url("https://github.com/rife2/generated-version")
|
||||||
|
.developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
|
||||||
|
.url("https://erik.thauvin.net/"))
|
||||||
|
.license(new PublishLicense().name("The Apache License, Version 2.0")
|
||||||
|
.url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
|
||||||
|
.scm(new PublishScm().connection("scm:git:https://github.com/rife2/generated-version.git")
|
||||||
|
.developerConnection("scm:git:git@github.com:rife2/generated-version.git")
|
||||||
|
.url("https://github.com/rife2/generated-version"))
|
||||||
|
.signKey(property("sign.key"))
|
||||||
|
.signPassphrase(property("sign.passphrase"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.io.File;
|
||||||
@SuppressWarnings("PMD.DataClass")
|
@SuppressWarnings("PMD.DataClass")
|
||||||
public class GeneratedVersion {
|
public class GeneratedVersion {
|
||||||
private String className;
|
private String className;
|
||||||
|
private File classFile;
|
||||||
private String packageName;
|
private String packageName;
|
||||||
private BaseProject project;
|
private BaseProject project;
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
@ -38,38 +39,46 @@ public class GeneratedVersion {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseProject getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProjectName() {
|
|
||||||
return projectName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getTemplate() {
|
|
||||||
return template;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassName(String className) {
|
public void setClassName(String className) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getClassFile() {
|
||||||
|
return classFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassFile(File classFile) {
|
||||||
|
this.classFile = classFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
public void setPackageName(String packageName) {
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseProject getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
public void setProject(BaseProject project) {
|
public void setProject(BaseProject project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProjectName() {
|
||||||
|
return projectName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setProjectName(String projectName) {
|
public void setProjectName(String projectName) {
|
||||||
this.projectName = projectName;
|
this.projectName = projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getTemplate() {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTemplate(File template) {
|
public void setTemplate(File template) {
|
||||||
this.template = template;
|
this.template = template;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,12 @@ import rife.bld.BaseProject;
|
||||||
import rife.bld.operations.AbstractOperation;
|
import rife.bld.operations.AbstractOperation;
|
||||||
import rife.resources.ResourceFinderDirectories;
|
import rife.resources.ResourceFinderDirectories;
|
||||||
import rife.template.Template;
|
import rife.template.Template;
|
||||||
|
import rife.template.TemplateConfig;
|
||||||
import rife.template.TemplateFactory;
|
import rife.template.TemplateFactory;
|
||||||
import rife.tools.FileUtils;
|
import rife.tools.FileUtils;
|
||||||
import rife.tools.exceptions.FileUtilsErrorException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -60,7 +61,8 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
template = TemplateFactory.TXT.get("version.txt");
|
template = TemplateFactory.TXT.get("version.txt");
|
||||||
} else {
|
} else {
|
||||||
var files = new ResourceFinderDirectories(new File[]{gv.getTemplate().getParentFile()});
|
var files = new ResourceFinderDirectories(new File[]{gv.getTemplate().getParentFile()});
|
||||||
template = TemplateFactory.TXT.setResourceFinder(files).get(gv.getTemplate().getName());
|
template = new TemplateFactory(TemplateConfig.TXT, "txtFiles", TemplateFactory.TXT)
|
||||||
|
.setResourceFinder(files).get(gv.getTemplate().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gv.getPackageName() == null) {
|
if (gv.getPackageName() == null) {
|
||||||
|
@ -110,29 +112,34 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTemplate(Template template, GeneratedVersion gv) {
|
public static void writeTemplate(Template template, File directory, GeneratedVersion gv) {
|
||||||
Path generatedVersionPath;
|
|
||||||
if (gv.getPackageName() != null) {
|
if (gv.getPackageName() != null) {
|
||||||
generatedVersionPath = Path.of(gv.getProject().srcMainJavaDirectory().getAbsolutePath(),
|
gv.setClassFile(Path.of(directory.getAbsolutePath(),
|
||||||
gv.getPackageName().replace(".", File.separator), gv.getClassName());
|
gv.getPackageName().replace(".", File.separator), gv.getClassName() + ".java").toFile());
|
||||||
} else {
|
} else {
|
||||||
generatedVersionPath = Path.of(gv.getProject().srcMainJavaDirectory().getAbsolutePath(),
|
gv.setClassFile(Path.of(directory.getAbsolutePath(), gv.getClassName() + ".java").toFile());
|
||||||
gv.getClassName());
|
}
|
||||||
|
|
||||||
|
if (!gv.getClassFile().getParentFile().exists()) {
|
||||||
|
var mkdirs = gv.getClassFile().getParentFile().mkdirs();
|
||||||
|
if (!mkdirs && !gv.getClassFile().getParentFile().exists() && LOGGER.isLoggable(Level.SEVERE)) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not create project package directories: {0}",
|
||||||
|
gv.getClassFile().getParent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generatedVersionPath.getParent().toFile().mkdirs()) {
|
|
||||||
try {
|
try {
|
||||||
FileUtils.writeString(template.getContent(), generatedVersionPath.toFile());
|
var updated = gv.getClassFile().exists();
|
||||||
} catch (FileUtilsErrorException e) {
|
FileUtils.writeString(template.getContent(), gv.getClassFile());
|
||||||
|
if (LOGGER.isLoggable(Level.INFO)) {
|
||||||
|
LOGGER.log(Level.INFO, "Generated version class has been {0}: {1}",
|
||||||
|
new String[]{updated ? "updated" : "created", gv.getClassFile().toString()});
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
if (LOGGER.isLoggable(Level.SEVERE)) {
|
if (LOGGER.isLoggable(Level.SEVERE)) {
|
||||||
LOGGER.log(Level.SEVERE, "Unable to write the version class file.", e);
|
LOGGER.log(Level.SEVERE, "Unable to write the version class file.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (LOGGER.isLoggable(Level.SEVERE)) {
|
|
||||||
LOGGER.severe("Could not create project package directories.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,13 +159,13 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
if (generatedVersion.getProject() == null && LOGGER.isLoggable(Level.SEVERE)) {
|
if (generatedVersion.getProject() == null && LOGGER.isLoggable(Level.SEVERE)) {
|
||||||
LOGGER.severe("A project must be specified.");
|
LOGGER.severe("A project must be specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var template = buildTemplate(generatedVersion);
|
var template = buildTemplate(generatedVersion);
|
||||||
writeTemplate(template, generatedVersion);
|
writeTemplate(template, generatedVersion.getProject().srcMainJavaDirectory(), generatedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public final class {{v className/}} {
|
public final class {{v className/}} {
|
||||||
public static final String PROJECT = "{{v project/}}";
|
public static final String PROJECT = "{{v project/}}";
|
||||||
public static final Date BUILDDATE = new Date({{v epoch/}}L);
|
public static final Date BUILD_DATE = new Date({{v epoch/}}L);
|
||||||
public static final int MAJOR = {{v major/}};
|
public static final int MAJOR = {{v major/}};
|
||||||
public static final int MINOR = {{v minor/}};
|
public static final int MINOR = {{v minor/}};
|
||||||
public static final int REVISION = {{v revision/}};
|
public static final int REVISION = {{v revision/}};
|
||||||
|
|
|
@ -18,10 +18,14 @@ package rife.bld.extension;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import rife.bld.BaseProject;
|
import rife.bld.BaseProject;
|
||||||
import rife.bld.WebProject;
|
import rife.bld.Project;
|
||||||
import rife.bld.dependencies.VersionNumber;
|
import rife.bld.dependencies.VersionNumber;
|
||||||
|
import rife.tools.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ -32,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class GeneratedVersionTest {
|
class GeneratedVersionTest {
|
||||||
private final BaseProject PROJECT = new WebProject() {
|
private final BaseProject PROJECT = new Project() {
|
||||||
@Override
|
@Override
|
||||||
public String pkg() {
|
public String pkg() {
|
||||||
return "com.example";
|
return "com.example";
|
||||||
|
@ -49,6 +53,17 @@ class GeneratedVersionTest {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void deleteOnExit(File folder) {
|
||||||
|
folder.deleteOnExit();
|
||||||
|
for (var f : Objects.requireNonNull(folder.listFiles())) {
|
||||||
|
if (f.isDirectory()) {
|
||||||
|
deleteOnExit(f);
|
||||||
|
} else {
|
||||||
|
f.deleteOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void buildTemplateCustomTest() {
|
void buildTemplateCustomTest() {
|
||||||
var gv = new GeneratedVersion();
|
var gv = new GeneratedVersion();
|
||||||
|
@ -82,4 +97,24 @@ class GeneratedVersionTest {
|
||||||
.contains("REVISION = 3").contains("QUALIFIER = \"\"").contains("VERSION = \"2.1.3\"")
|
.contains("REVISION = 3").contains("QUALIFIER = \"\"").contains("VERSION = \"2.1.3\"")
|
||||||
.contains("private GeneratedVersion");
|
.contains("private GeneratedVersion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testWriteTemplate() throws IOException {
|
||||||
|
var gv = new GeneratedVersion();
|
||||||
|
gv.setProject(PROJECT);
|
||||||
|
var t = GeneratedVersionOperation.buildTemplate(gv);
|
||||||
|
|
||||||
|
var tmpDir = Files.createTempDirectory("bldGeneratedVersion").toFile();
|
||||||
|
|
||||||
|
GeneratedVersionOperation.writeTemplate(t, tmpDir, gv);
|
||||||
|
|
||||||
|
assertThat(gv.getClassFile()).exists();
|
||||||
|
|
||||||
|
deleteOnExit(tmpDir);
|
||||||
|
|
||||||
|
var versionClass = FileUtils.readString(gv.getClassFile());
|
||||||
|
assertThat(versionClass).contains("package com.example;").contains("class GeneratedVersion")
|
||||||
|
.contains("MAJOR = 2").contains("MINOR = 1").contains("REVISION = 3")
|
||||||
|
.contains("private GeneratedVersion");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue