Skip to content

Commit

Permalink
Merge branch 'master' into 860_SQL_files_generation
Browse files Browse the repository at this point in the history
# Conflicts:
#	cobigen-eclipse/cobigen-eclipse-test/.classpath
  • Loading branch information
MansourD committed Jan 5, 2023
2 parents 32b5707 + 5b1a887 commit 01ff76f
Show file tree
Hide file tree
Showing 34 changed files with 565 additions and 485 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: devonfw-actions/java-maven-setup@main
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: spellcheck
on:
push:
paths:
- '**.asciidoc'
- '**.adoc'
workflow_dispatch:
jobs:
spellchecker:
Expand Down
2 changes: 1 addition & 1 deletion README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

= CobiGen (Code-based incremental Generator)

image:https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin/badge.svg[https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin] image:https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml/badge.svg?branch=master&event=push["Build Status", link="https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml"]
image:https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin/badge.svg[https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin] image:https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml/badge.svg?branch=master&event=push["Build Status", link="https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml?query=branch%3Amaster"]

== Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Path;

import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -296,4 +297,68 @@ public void generateFromArgsWithQuote() throws Exception {
assertThat(outputRootPath.resolve("docs")).exists();
}

/**
* Integration test of the generation and validation of the class path cache. The test will execute a generation twice
* this requires some cleanup.A deleted dependencies will be detected by the validating process in MavenUtil and will
* reload the needed dependency and not prevent the second generation
*
* @throws Exception test fails
*/
@Test
public void generateFromEntityTwiceToTestCache() throws Exception {

// prepare
File outputRootFile = this.tempFolder.newFolder("playground2", "rootoutput");
File openApiFile = new File(testFileRootPath + "openAPI.yml");

String args[] = new String[6];
args[0] = "generate";
args[1] = openApiFile.getAbsolutePath();
args[2] = "--out";
args[3] = outputRootFile.getAbsolutePath();
args[4] = "--increments";
args[5] = "ionic_component,OpenAPI_Docs,services";

execute(args, true);

Path rootPath = outputRootFile.toPath();
assertThat(rootPath.resolve("../../devon4ng-ionic-application-template"));

// cleanup for a second execution of generate to test the correct cache usage
File cli_config = this.tempFolder.getRoot().toPath().resolve("cobigen-test-home").toFile();
File bin = cli_config.toPath().resolve("cobigen-test-home/bin").toFile();
if (bin.exists()) {
FileUtils.deleteDirectory(bin);
}
File lib = cli_config.toPath().resolve("cobigen-test-home/lib").toFile();
if (lib.exists()) {
FileUtils.deleteDirectory(lib);
}
File license = cli_config.toPath().resolve("cobigen-test-home/LICENSE.txt").toFile();
if (license.exists()) {
FileUtils.delete(license);
}
File cli = cli_config.toPath().resolve("cli-config").toFile();
// get the saved dependencies in the cache file and delete one
for (File f : cli.listFiles()) {
if (f.getName().startsWith("pom-cp-")) {
String dependenciesFromCache = FileUtils.readFileToString(f, Charset.defaultCharset());
String osName = System.getProperty("os.name");
String[] dependenciesFromCacheArray;
if (osName.contains("Windows")) {
dependenciesFromCacheArray = dependenciesFromCache.split(";");
} else {
dependenciesFromCacheArray = dependenciesFromCache.split(":");
}
for (int i = 0; i >= 0; i--) { // reverse
if (dependenciesFromCacheArray[i].contains("javax.persistence")) {
FileUtils.delete(new File(dependenciesFromCacheArray[i])); // delete a randomly picked dependency
}
}
}
}
FileUtils.delete(cli_config.toPath().resolve("cli.tar.gz").toFile());
execute(args, true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public class CobiGenUtils {
public static CobiGen initializeCobiGen(Path templatesProject) {

registerPlugins();
CobiGen cg;
if (templatesProject != null) {
return CobiGenFactory.create(templatesProject.toUri());
cg = CobiGenFactory.create(templatesProject.toUri());
} else {
return CobiGenFactory.create();
cg = CobiGenFactory.create();
}
return cg;
}

/**
Expand All @@ -79,7 +81,7 @@ public static ClassLoader registerPlugins() {
Path rootCLIPath = getCliHomePath();
File pomFile = extractArtificialPom();

String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath());
String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath(), MavenUtil.determineMavenRepositoryPath());

Path cpFile = rootCLIPath.resolve(String.format(MavenConstants.CLASSPATH_CACHE_FILE, pomFileHash));

Expand Down
11 changes: 11 additions & 0 deletions cobigen-eclipse/cobigen-eclipse-feature/.project
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
<filteredResources>
<filter>
<id>1664574669497</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
34 changes: 0 additions & 34 deletions cobigen-eclipse/cobigen-eclipse-test/.classpath

This file was deleted.

11 changes: 11 additions & 0 deletions cobigen-eclipse/cobigen-eclipse-test/.project
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1664574669506</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions cobigen-eclipse/cobigen-eclipse-updatesite/.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1664574669516</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
54 changes: 0 additions & 54 deletions cobigen-eclipse/cobigen-eclipse/.classpath

This file was deleted.

11 changes: 11 additions & 0 deletions cobigen-eclipse/cobigen-eclipse/.project
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1664574669486</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
17 changes: 17 additions & 0 deletions cobigen-templates/templates-devon4j/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="eclipse-target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="eclipse-target/test-classes" path="eclipse-target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="eclipse-target/classes"/>
</classpath>
11 changes: 11 additions & 0 deletions cobigen-templates/templates-devon4j/.project
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1664574669524</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
2 changes: 1 addition & 1 deletion cobigen/cobigen-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<!-- Proper process reader -->
<dependency>
<groupId>org.zeroturnaround</groupId>
Expand Down
Loading

0 comments on commit 01ff76f

Please sign in to comment.