Skip to content

Commit e3f6416

Browse files
committed
1.1.4 (2023-08-27)
+ [enhancement] [fj-daogen-maven-plugin] Added experimental feature 'generate-lazy' plugin (should not run on m2e incremental builds
1 parent e10fa1d commit e3f6416

File tree

12 files changed

+167
-102
lines changed

12 files changed

+167
-102
lines changed

docgen/parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title" : "Mars (Fugerit DAOGEN A.P.I.)",
33
"name": "Mars",
4-
"version" : "1.1.3",
4+
"version" : "1.1.4",
55
"date" : "27/08/2023",
66
"organization" : {
77
"name" : "Fugerit Org",

docgen/release-notes.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
1.1.3 (2023-08-27)
1+
1.1.4 (2023-08-27)
2+
------------------
3+
+ [enhancement] [fj-daogen-maven-plugin] Added experimental feature 'generate-lazy' plugin (should not run on m2e incremental builds
4+
5+
1.1.3 (2023-08-27)
26
------------------
37
+ [fix] [fj-daogen-base] fix to overrideProperties handling in DaogeFacade.generate(InputStream, Properties)
48

fj-daogen-base/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-daogen</artifactId>
10-
<version>1.1.3</version>
10+
<version>1.1.4</version>
1111
</parent>
1212

1313
<name>fj-daogen-base</name>

fj-daogen-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-daogen</artifactId>
10-
<version>1.1.3</version>
10+
<version>1.1.4</version>
1111
</parent>
1212

1313
<packaging>maven-plugin</packaging>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package org.fugerit.java.daogen.maven;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.util.Properties;
6+
7+
import org.apache.maven.plugin.AbstractMojo;
8+
import org.apache.maven.plugin.MojoExecutionException;
9+
import org.apache.maven.plugins.annotations.Parameter;
10+
import org.fugerit.java.core.lang.helpers.StringUtils;
11+
import org.fugerit.java.daogen.base.config.DaogenCatalogConstants;
12+
import org.fugerit.java.daogen.base.config.DaogenFacade;
13+
14+
/**
15+
*
16+
* <p>Convenience plugin for dao generation.</p>
17+
*
18+
* @since 1.1.4
19+
*/
20+
public abstract class AbstractMojoGenerate extends AbstractMojo {
21+
22+
public static final String PARAM_DAOGEN_CONFIG = "daogen.config";
23+
24+
public static final String PARAM_GENERATED_SOURCE_HELPER = "generated.source.helper";
25+
26+
/**
27+
* <p>The path to 'daogen-config.xml'</p>
28+
*
29+
* <p>If it is a file, it is recommended to set it to the full path, for instance :
30+
* <code>file://${project.basedir}/src/main/daogen/daogen-config.xml</code></p>
31+
*
32+
* @since 1.1.0
33+
*/
34+
@Parameter(property = "daogenConfig", required = true, alias = PARAM_DAOGEN_CONFIG )
35+
protected String daogenConfig;
36+
37+
/**
38+
* <p>The generation source base directory, overrides <code>'base-src-folder'</code> daogen general property.</p>
39+
*
40+
* <p>It is recommended to set it to the full path, for instance : <code>file://${project.basedir}</code></p>
41+
*
42+
* @since 1.1.0
43+
*/
44+
@Parameter(property = "genBaseDir", required = true, alias = DaogenCatalogConstants.GEN_PROP_BASE_SRC_FOLDER )
45+
protected String genBaseDir;
46+
47+
/**
48+
* <p>Overrides <code>'src-mvn-generated-sources'</code> daogen general property.</p>
49+
*
50+
* <p>It represents the generation source directory for maven generated sources
51+
* (for instance 'target/generated-sources/daogen'),
52+
* relative to <code>'base-src-folder'</code></p>
53+
*
54+
* @since 1.1.1
55+
*/
56+
@Parameter(property = "generatedSourceHelper", required = false, alias = DaogenCatalogConstants.GEN_PROP_SRC_MVN_GENERATED )
57+
protected String generatedSourceHelper;
58+
59+
/**
60+
* <p>Overrides <code>'generator-catalog'</code> daogen general property.</p>
61+
*
62+
* <p>If it is a file, it is recommended to set it to the full path, for instance :
63+
* <code>file://${project.basedir}/src/main/daogen/generator-catalog.xml</code></p>
64+
*
65+
* @since 1.1.1
66+
*/
67+
@Parameter(property = "generatorCatalog", required = false, alias = DaogenCatalogConstants.GEN_PROP_GENERATOR_CATALOG )
68+
protected String generatorCatalog;
69+
70+
/**
71+
* <p>Overrides <code>'decorator-catalog'</code> daogen general property.</p>
72+
*
73+
* <p>If it is a file, it is recommended to set it to the full path, for instance :
74+
* <code>file://${project.basedir}/src/main/daogen/decorator-catalog.xml</code></p>
75+
*
76+
* @since 1.1.1
77+
*/
78+
@Parameter(property = "decoratorCatalog", required = false, alias = DaogenCatalogConstants.GEN_PROP_DECORATOR_CATALOG )
79+
protected String decoratorCatalog;
80+
81+
private void addProperty( Properties overrideProperties, String key, String value ) {
82+
if ( StringUtils.isNotEmpty(value) ) {
83+
getLog().info( "override property, key : "+key+", value : "+value );
84+
overrideProperties.setProperty(key, value);
85+
}
86+
}
87+
88+
public void execute() throws MojoExecutionException {
89+
getLog().info( "using parameter "+PARAM_DAOGEN_CONFIG+" : "+this.daogenConfig );
90+
File file = new File( this.daogenConfig );
91+
try {
92+
getLog().info( "daogen config path : "+file.getCanonicalPath() );
93+
Properties overrideProperties = new Properties();
94+
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_BASE_SRC_FOLDER, this.genBaseDir);
95+
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_SRC_MVN_GENERATED, this.generatedSourceHelper);
96+
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_GENERATOR_CATALOG, this.generatorCatalog);
97+
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_DECORATOR_CATALOG, this.decoratorCatalog);
98+
try ( FileInputStream fis = new FileInputStream( file ) ) {
99+
DaogenFacade.generate( fis, overrideProperties );
100+
}
101+
} catch (Exception e) {
102+
throw new MojoExecutionException( "Error generating code : "+e, e );
103+
}
104+
}
105+
106+
}

fj-daogen-maven-plugin/src/main/java/org/fugerit/java/daogen/maven/MojoDump.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import org.apache.maven.plugins.annotations.Mojo;
88
import org.apache.maven.plugins.annotations.Parameter;
99

10+
/**
11+
* This is just a stub for now. It will be implemented in the near future
12+
*/
1013
@Mojo( name = "dump")
1114
public class MojoDump extends AbstractMojo {
1215

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
package org.fugerit.java.daogen.maven;
22

3-
import java.io.File;
4-
import java.io.FileInputStream;
5-
import java.util.Properties;
6-
7-
import org.apache.maven.plugin.AbstractMojo;
8-
import org.apache.maven.plugin.MojoExecutionException;
93
import org.apache.maven.plugins.annotations.Mojo;
10-
import org.apache.maven.plugins.annotations.Parameter;
11-
import org.fugerit.java.core.lang.helpers.StringUtils;
12-
import org.fugerit.java.daogen.base.config.DaogenCatalogConstants;
13-
import org.fugerit.java.daogen.base.config.DaogenFacade;
144

155
/**
166
*
@@ -21,93 +11,12 @@
2111
* <p>Many parameters override 'daogen-config.xml' general properties
2212
* (in this case they always have an alias with the same name of the property they override.</p>
2313
*
14+
* <p>NOTE: if using eclipse and the build are too slow, considering using the {@link MojoGenerateLazy} plugin,
15+
* it is the same as this plugin bug run on goal generate-lazy and m2e lifecycle is configured to run only on full builds.</p>
16+
*
2417
*/
2518
@Mojo( name = "generate" )
26-
public class MojoGenerate extends AbstractMojo {
27-
28-
public static final String PARAM_DAOGEN_CONFIG = "daogen.config";
29-
19+
public class MojoGenerate extends AbstractMojoGenerate {
3020

31-
public static final String PARAM_GENERATED_SOURCE_HELPER = "generated.source.helper";
32-
33-
/**
34-
* <p>The path to 'daogen-config.xml'</p>
35-
*
36-
* <p>If it is a file, it is recommended to set it to the full path, for instance :
37-
* <code>file://${project.basedir}/src/main/daogen/daogen-config.xml</code></p>
38-
*
39-
* @since 1.1.0
40-
*/
41-
@Parameter(property = "daogenConfig", required = true, alias = PARAM_DAOGEN_CONFIG )
42-
protected String daogenConfig;
43-
44-
/**
45-
* <p>The generation source base directory, overrides <code>'base-src-folder'</code> daogen general property.</p>
46-
*
47-
* <p>It is recommended to set it to the full path, for instance : <code>file://${project.basedir}</code></p>
48-
*
49-
* @since 1.1.0
50-
*/
51-
@Parameter(property = "genBaseDir", required = true, alias = DaogenCatalogConstants.GEN_PROP_BASE_SRC_FOLDER )
52-
protected String genBaseDir;
53-
54-
/**
55-
* <p>Overrides <code>'src-mvn-generated-sources'</code> daogen general property.</p>
56-
*
57-
* <p>It represents the generation source directory for maven generated sources
58-
* (for instance 'target/generated-sources/daogen'),
59-
* relative to <code>'base-src-folder'</code></p>
60-
*
61-
* @since 1.1.1
62-
*/
63-
@Parameter(property = "generatedSourceHelper", required = false, alias = DaogenCatalogConstants.GEN_PROP_SRC_MVN_GENERATED )
64-
protected String generatedSourceHelper;
65-
66-
/**
67-
* <p>Overrides <code>'generator-catalog'</code> daogen general property.</p>
68-
*
69-
* <p>If it is a file, it is recommended to set it to the full path, for instance :
70-
* <code>file://${project.basedir}/src/main/daogen/generator-catalog.xml</code></p>
71-
*
72-
* @since 1.1.1
73-
*/
74-
@Parameter(property = "generatorCatalog", required = false, alias = DaogenCatalogConstants.GEN_PROP_GENERATOR_CATALOG )
75-
protected String generatorCatalog;
76-
77-
/**
78-
* <p>Overrides <code>'decorator-catalog'</code> daogen general property.</p>
79-
*
80-
* <p>If it is a file, it is recommended to set it to the full path, for instance :
81-
* <code>file://${project.basedir}/src/main/daogen/decorator-catalog.xml</code></p>
82-
*
83-
* @since 1.1.1
84-
*/
85-
@Parameter(property = "decoratorCatalog", required = false, alias = DaogenCatalogConstants.GEN_PROP_DECORATOR_CATALOG )
86-
protected String decoratorCatalog;
87-
88-
private void addProperty( Properties overrideProperties, String key, String value ) {
89-
if ( StringUtils.isNotEmpty(value) ) {
90-
getLog().info( "override property, key : "+key+", value : "+value );
91-
overrideProperties.setProperty(key, value);
92-
}
93-
}
94-
95-
public void execute() throws MojoExecutionException {
96-
getLog().info( "using parameter "+PARAM_DAOGEN_CONFIG+" : "+this.daogenConfig );
97-
File file = new File( this.daogenConfig );
98-
try {
99-
getLog().info( "daogen config path : "+file.getCanonicalPath() );
100-
Properties overrideProperties = new Properties();
101-
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_BASE_SRC_FOLDER, this.genBaseDir);
102-
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_SRC_MVN_GENERATED, this.generatedSourceHelper);
103-
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_GENERATOR_CATALOG, this.generatorCatalog);
104-
this.addProperty(overrideProperties, DaogenCatalogConstants.GEN_PROP_DECORATOR_CATALOG, this.decoratorCatalog);
105-
try ( FileInputStream fis = new FileInputStream( file ) ) {
106-
DaogenFacade.generate( fis, overrideProperties );
107-
}
108-
} catch (Exception e) {
109-
throw new MojoExecutionException( "Error generating code : "+e, e );
110-
}
111-
}
11221

11322
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.fugerit.java.daogen.maven;
2+
3+
import org.apache.maven.plugins.annotations.Mojo;
4+
5+
/**
6+
*
7+
* <p>Convenience plugin for the <code>DaogenFacade.generate()</code> method in module 'fj-daogen-base'.</p>
8+
*
9+
* <p>Required parameter are 'daogenConfig' and 'genBaseDir'.</p>
10+
*
11+
* <p>Many parameters override 'daogen-config.xml' general properties
12+
* (in this case they always have an alias with the same name of the property they override.</p>
13+
*
14+
* <p>The difference between this and daogen:generate plugin is only that this plugin is configured
15+
* in the eclipse (m2e) lifecycle to not run only during incremental build. (experimental feature)</p>
16+
*
17+
* <p>NOTE: it can be recommended in some scenarios, like on a workstation not powerful enough.</p>
18+
*
19+
*/
20+
@Mojo( name = "generate-lazy" )
21+
public class MojoGenerateLazy extends AbstractMojoGenerate {
22+
23+
24+
}

fj-daogen-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<lifecycleMappingMetadata>
22
<pluginExecutions>
3+
<!-- configurazione for mojo:generate, will run all builds. -->
34
<pluginExecution>
45
<pluginExecutionFilter>
56
<goals>
@@ -14,5 +15,23 @@
1415
</execute>
1516
</action>
1617
</pluginExecution>
18+
<!--
19+
configurazione for mojo:generate-lazy, will not run on incremental builds.
20+
NOTE: it can be recommended in some scenarios, like on a workstation not powerful enough.
21+
-->
22+
<pluginExecution>
23+
<pluginExecutionFilter>
24+
<goals>
25+
<goal>compile</goal>
26+
<goal>generate-lazy</goal>
27+
</goals>
28+
</pluginExecutionFilter>
29+
<action>
30+
<execute>
31+
<runOnIncremental>false</runOnIncremental>
32+
<runOnConfiguration>true</runOnConfiguration>
33+
</execute>
34+
</action>
35+
</pluginExecution>
1736
</pluginExecutions>
1837
</lifecycleMappingMetadata>

fj-daogen-sample/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.fugerit.java</groupId>
99
<artifactId>fj-daogen</artifactId>
10-
<version>1.1.3</version>
10+
<version>1.1.4</version>
1111
</parent>
1212

1313
<name>fj-daogen-sample</name>

0 commit comments

Comments
 (0)