Skip to content

Java library that allows you to define autogenerated resources in Java.

License

Notifications You must be signed in to change notification settings

exasol/autogenerated-resource-verifier-java

Repository files navigation

Autogenerated Resource Verifier for Java

Build Status Maven Central – Autogenerated resource verifier

Quality Gate Status

Security Rating Reliability Rating Maintainability Rating Technical Debt

Code Smells Coverage Duplicated Lines (%) Lines of Code

This Java library allows you to automatically create resources in Java.

Usage

Define the content of your document in your test source code:

public class MyReportGenerator {

    public static void main(final String[] args) {
        new AutogeneratedResourceVerifier().verifyResource(Path.of(args[0]), new MyReport());
    }

    private static class MyReport implements AutogeneratedResource {
        @Override
        public String generateContent() {
            StringBuilder report;

            //build your report here

            return report.toString();
        }

        @Override
        public Path getPathOfGeneratedFile() {
            return Path.of("doc", "generated", "myReport.md");
        }
    }
}

Run From Maven:

You can add the execution of your generator to the maven build using the maven-execution-plugin. To do so add the following lines to your pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>validate-capabilities-report</id>
            <goals>
                <goal>java</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <mainClass>com.example.MyReportGenerator</mainClass> <!-- Add your class here -->
                <classpathScope>test</classpathScope>
                <systemProperties>
                    <systemProperty>
                        <key>projectDir</key>
                        <value>${project.basedir}</value>
                    </systemProperty>
                </systemProperties>
            </configuration>
        </execution>
    </executions>
</plugin>

Now you can run the validation using mvn package.

The verifier can also fix the generated resource. To do so, run:

mvn package -DfixAutogeneratedResources=true

Additional Information