diff --git a/.github/workflows/build_validator.yml b/.github/workflows/build_validator.yml new file mode 100644 index 0000000..5b0607a --- /dev/null +++ b/.github/workflows/build_validator.yml @@ -0,0 +1,36 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Generate SourceCode with Gradle + run: ./gradlew generateGithubSource + - name: Build with Gradle + run: ./gradlew build diff --git a/build.gradle b/build.gradle index a3136a2..3a7923b 100644 --- a/build.gradle +++ b/build.gradle @@ -42,8 +42,8 @@ configurations { } dependencies { - builderCompile 'de.speiger:Simple-Code-Generator:1.0.5' - runtimeOnly 'de.speiger:Simple-Code-Generator:1.0.5' + builderCompile 'de.speiger:Simple-Code-Generator:1.0.6' + runtimeOnly 'de.speiger:Simple-Code-Generator:1.0.6' testImplementation 'junit:junit:4.12' testImplementation 'com.google.guava:guava-testlib:31.0.1-jre' } @@ -55,6 +55,14 @@ task generateSource(type: JavaExec) { main = 'speiger.src.builder.PrimitiveCollectionsBuilder' } +task generateGithubSource(type: JavaExec) { + group = 'internal' + description = 'Builds the sourcecode for Github Actions' + classpath = sourceSets.builder.runtimeClasspath + main = 'speiger.src.builder.PrimitiveCollectionsBuilder' + args = ['false', 'true'] +} + task forceGenerateSource(type: JavaExec) { group = 'internal' description = 'Builds the sourcecode forceful' @@ -87,8 +95,11 @@ test { } uploadArchives { - Properties props = new Properties() - props.load(new FileInputStream("$buildDir/credentials.properties")) + Properties props = new Properties() + if(file("$buildDir/credentials.properties").exists()) + { + props.load(new FileInputStream("$buildDir/credentials.properties")) + } repositories.mavenDeployer { repository(url: 'https://maven.speiger.com/repository/main') { authentication(userName: props.mavenUser, password: props.mavenPassword) diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index 212d336..efebcf5 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -29,12 +29,22 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor public PrimitiveCollectionsBuilder() { - super(Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/")); + this(false); + } + + public PrimitiveCollectionsBuilder(boolean silencedSuccess) + { + super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/")); } public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder) { - super(sourceFolder, outputFolder, dataFolder); + this(false, sourceFolder, outputFolder, dataFolder); + } + + public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder) + { + super(silencedSuccess, sourceFolder, outputFolder, dataFolder); } @Override @@ -159,10 +169,14 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor new PrimitiveCollectionsBuilder().process(false); } else if(args.length == 1) { new PrimitiveCollectionsBuilder().process(Boolean.parseBoolean(args[0])); + } else if(args.length == 2) { + new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[1])).process(Boolean.parseBoolean(args[0])); } else if(args.length == 3) { new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false); } else if(args.length == 4) { - new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3])); + new PrimitiveCollectionsBuilder(false, Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3])); + } else if(args.length == 4) { + new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[4]), Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3])); } else { System.out.println("Invalid argument count passed in"); System.exit(1);