|
1 | 1 | package org.fugerit.java.doc.project.facade;
|
2 | 2 |
|
3 | 3 | import lombok.extern.slf4j.Slf4j;
|
4 |
| -import org.apache.maven.model.Dependency; |
5 |
| -import org.apache.maven.model.DependencyManagement; |
6 |
| -import org.apache.maven.model.Exclusion; |
7 |
| -import org.apache.maven.model.Model; |
| 4 | +import org.apache.maven.model.*; |
| 5 | +import org.apache.maven.plugin.lifecycle.Execution; |
| 6 | +import org.codehaus.plexus.util.xml.Xpp3Dom; |
| 7 | +import org.codehaus.plexus.util.xml.Xpp3DomBuilder; |
8 | 8 | import org.fugerit.java.core.cfg.ConfigRuntimeException;
|
| 9 | +import org.fugerit.java.core.io.helper.HelperIOException; |
| 10 | +import org.fugerit.java.core.lang.helpers.BooleanUtils; |
9 | 11 | import org.fugerit.java.core.lang.helpers.StringUtils;
|
| 12 | +import org.fugerit.java.doc.freemarker.tool.FreeMarkerTemplateSyntaxVerifier; |
10 | 13 | import org.maxxq.maven.dependency.ModelIO;
|
11 | 14 |
|
12 | 15 | import java.io.*;
|
@@ -100,11 +103,47 @@ protected static void addExtensionList( File pomFile, VenusContext context ) thr
|
100 | 103 | }
|
101 | 104 | }
|
102 | 105 | log.info( "end dependencies size : {}", model.getDependencies().size() );
|
| 106 | + // addVerifyPlugin? |
| 107 | + log.info( "addVerifyPlugin : {}", context.isAddVerifyPlugin() ); |
| 108 | + addPlugin( context, model ); |
103 | 109 | try (OutputStream pomStream = new FileOutputStream( pomFile ) ) {
|
104 | 110 | modelIO.writeModelToStream( model, pomStream );
|
105 | 111 | }
|
106 | 112 | }
|
107 | 113 |
|
| 114 | + private static void addPlugin( VenusContext context, Model model ) throws IOException { |
| 115 | + if ( context.isAddVerifyPlugin() ) { |
| 116 | + Build build = model.getBuild(); |
| 117 | + if ( build == null ) { |
| 118 | + build = new Build(); |
| 119 | + model.setBuild( build ); |
| 120 | + } |
| 121 | + List<Plugin> plugins = model.getBuild().getPlugins(); |
| 122 | + Plugin plugin = new Plugin(); |
| 123 | + plugin.setGroupId( GROUP_ID ); |
| 124 | + plugin.setArtifactId( "fj-doc-maven-plugin" ); |
| 125 | + plugin.setVersion( "${"+KEY_VERSION+"}" ); |
| 126 | + PluginExecution execution = new PluginExecution(); |
| 127 | + execution.setId( "freemarker-verify" ); |
| 128 | + execution.setPhase( "compile" ); |
| 129 | + execution.addGoal( "verify" ); |
| 130 | + plugin.getExecutions().add( execution ); |
| 131 | + String xml = "<configuration>\n" + |
| 132 | + " <templateBasePath>${project.basedir}/src/main/resources/"+context.getArtificatIdForFolder()+"/template</templateBasePath>\n" + |
| 133 | + " <generateReport>true</generateReport>\n" + |
| 134 | + " <failOnErrors>true</failOnErrors>\n" + |
| 135 | + " <reportOutputFolder>${project.build.directory}/freemarker-syntax-verify-report</reportOutputFolder>\n" + |
| 136 | + " </configuration>"; |
| 137 | + HelperIOException.apply( () -> { |
| 138 | + try ( StringReader sr = new StringReader( xml ) ) { |
| 139 | + Xpp3Dom dom = Xpp3DomBuilder.build( sr ); |
| 140 | + plugin.setConfiguration( dom ); |
| 141 | + } |
| 142 | + }); |
| 143 | + plugins.add( plugin ); |
| 144 | + } |
| 145 | + } |
| 146 | + |
108 | 147 | public static void checkDependencies( boolean force, Dependency d ) {
|
109 | 148 | if ( d.getGroupId().equals( GROUP_ID ) && d.getArtifactId().startsWith( "fj-doc") ) {
|
110 | 149 | log.warn( "fj-doc dependency found : {}", d );
|
|
0 commit comments