You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/04/06 20:49:22 UTC

[2/2] tomee git commit: TOMEE-1541 inlined tomee.xml support for tomee maven plugins

TOMEE-1541 inlined tomee.xml support for tomee maven plugins


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ad896c6d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ad896c6d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ad896c6d

Branch: refs/heads/master
Commit: ad896c6d582dfe13f6caa685523906a0283f3240
Parents: 95a3799
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Mon Apr 6 20:49:06 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Mon Apr 6 20:49:06 2015 +0200

----------------------------------------------------------------------
 .../maven/plugins/TomEEEmbeddedMojo.java        | 23 ++++++++++++++++++--
 .../openejb/maven/plugin/AbstractTomEEMojo.java | 12 ++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ad896c6d/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
index a5eff6f..a0688dc 100644
--- a/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
+++ b/maven/tomee-embedded-maven-plugin/src/main/java/org/apache/openejb/maven/plugins/TomEEEmbeddedMojo.java
@@ -36,7 +36,9 @@ import org.apache.openejb.loader.Files;
 import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.maven.util.MavenLogStreamFactory;
+import org.apache.openejb.maven.util.XmlFormatter;
 import org.apache.openejb.util.JuliLogStreamFactory;
+import org.apache.tomee.catalina.TomEERuntimeException;
 import org.apache.tomee.embedded.Configuration;
 import org.apache.tomee.embedded.Container;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
@@ -184,6 +186,9 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
     @Parameter
     protected PlexusConfiguration inlinedServerXml;
 
+    @Parameter
+    protected PlexusConfiguration inlinedTomEEXml;
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         if (!classpathAsWar && "pom".equals(packaging)) {
@@ -215,13 +220,27 @@ public class TomEEEmbeddedMojo extends AbstractMojo {
             try {
                 FileUtils.forceMkdir(workDir);
                 serverXml = new File(workDir, "server.xml_dump");
-                FileUtils.fileWrite(serverXml, inlinedServerXml.getChild(0).toString());
+                FileUtils.fileWrite(serverXml, XmlFormatter.format(inlinedServerXml.getChild(0).toString()));
             } catch (final Exception e) {
                 throw new MojoExecutionException(e.getMessage(), e);
             }
         }
 
-        final Container container = new Container();
+        final Container container = new Container() {
+            @Override
+            public void setup(final Configuration configuration) {
+                super.setup(configuration);
+                if (inlinedTomEEXml != null && inlinedTomEEXml.getChildCount() > 0) {
+                    try {
+                        final File conf = new File(dir, "conf");
+                        FileUtils.forceMkdir(conf);
+                        FileUtils.fileWrite(new File(conf, "tomee.xml"), XmlFormatter.format(inlinedTomEEXml.getChild(0).toString()));
+                    } catch (final Exception e) {
+                        throw new TomEERuntimeException(e);
+                    }
+                }
+            }
+        };
         final Configuration config = getConfig();
         container.setup(config);
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/ad896c6d/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
index 1bb887c..09c5141 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
@@ -332,6 +332,9 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
     @Parameter
     protected PlexusConfiguration inlinedServerXml;
 
+    @Parameter
+    protected PlexusConfiguration inlinedTomEEXml;
+
     protected File deployedFile = null;
     protected RemoteServer server = null;
     protected String container = TOM_EE;
@@ -389,6 +392,15 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
                     throw new MojoExecutionException(e.getMessage(), e);
                 }
             }
+            if (inlinedTomEEXml != null && inlinedTomEEXml.getChildCount() > 0) {
+                final File tomeeXml = new File(catalinaBase, "conf/tomee.xml");
+                try {
+                    FileUtils.forceMkdir(tomeeXml.getParentFile());
+                    FileUtils.fileWrite(tomeeXml, XmlFormatter.format(inlinedTomEEXml.getChild(0).toString()));
+                } catch (final Exception e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            }
             if (!keepServerXmlAsthis) {
                 overrideAddresses();
             }