Changeset 757

Show
Ignore:
Timestamp:
14/11/08 14:27:26 (2 months ago)
Author:
bruno
Message:

Introduce Tanuki service wrapper:

  • the binaries and common config are made part of the kauri dist (produced by maven assembly:assembly)
  • project specific config is generated by the kauri-package-plugin

Not yet tested on Windows (need to fix my vmware first).

Added some more stuff to kauri-package-plugin like inclusion of log config, readme's, ...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dist/dist-assembly.xml

    r745 r757  
    5151      <outputDirectory>/bin/</outputDirectory> 
    5252    </file> 
     53    <file> 
     54      <source>target/classes/service-wrapper-common.conf</source> 
     55      <outputDirectory>/wrapper/conf</outputDirectory> 
     56    </file> 
     57    <file> 
     58      <source>src/main/wrapper/README.txt</source> 
     59      <outputDirectory>wrapper/README.txt</outputDirectory> 
     60    </file> 
    5361  </files> 
    5462 
     
    6775      --> 
    6876    </fileSet> 
     77    <fileSet> 
     78      <directory>src/main/wrapper/lib</directory> 
     79      <outputDirectory>/wrapper/lib</outputDirectory> 
     80      <useDefaultExcludes>true</useDefaultExcludes> 
     81    </fileSet> 
     82    <fileSet> 
     83      <directory>src/main/wrapper/bin</directory> 
     84      <outputDirectory>/wrapper/bin</outputDirectory> 
     85      <useDefaultExcludes>true</useDefaultExcludes> 
     86      <fileMode>755</fileMode> 
     87    </fileSet> 
    6988  </fileSets> 
    7089 
  • trunk/tools/kauri-package-plugin/src/main/java/org/kauriproject/tools/plugin/packaging

    • Property svn:mergeinfo set
  • trunk/tools/kauri-package-plugin/src/main/java/org/kauriproject/tools/plugin/packaging/AbstractPackageMojo.java

    r753 r757  
    1 package org.kauriproject.tools.plugin.webapp
     1package org.kauriproject.tools.plugin.packaging
    22 
    33import org.apache.maven.project.MavenProjectBuilder; 
     
    9898    protected void determineKauriVersion() throws MojoExecutionException { 
    9999        String pomPropsPath = "META-INF/maven/org.kauriproject/kauri-package-plugin/pom.properties"; 
    100         InputStream is = KauriWebappMojo.class.getClassLoader().getResourceAsStream(pomPropsPath); 
     100        InputStream is = getClass().getClassLoader().getResourceAsStream(pomPropsPath); 
    101101        if (is == null) { 
    102102            throw new MojoExecutionException("Could not find the resource containing the Kauri version information at " + pomPropsPath); 
     
    139139            destFos.close(); 
    140140        } catch (Throwable t) { 
    141             throw new MojoExecutionException("Failed to copy file from " + fromFile + " to " + toFile); 
     141            throw new MojoExecutionException("Failed to copy file from " + fromFile + " to " + toFile, t); 
     142        } 
     143    } 
     144 
     145    protected void copyResource(String path, File toFile) throws MojoExecutionException { 
     146        String fullPath = "org/kauriproject/tools/plugin/packaging/" + path; 
     147        InputStream is = getClass().getClassLoader().getResourceAsStream(fullPath); 
     148        if (is == null) 
     149            throw new MojoExecutionException("Classpath resource does not exist: " + fullPath); 
     150 
     151        try { 
     152            OutputStream os = new FileOutputStream(toFile); 
     153            byte[] buffer = new byte[8012]; 
     154            int read; 
     155            while ((read = is.read(buffer)) != -1) { 
     156                os.write(buffer, 0, read); 
     157            } 
     158            is.close(); 
     159            os.close(); 
     160        } catch (Throwable t) { 
     161            throw new MojoExecutionException("Failed to copy classpath resource " + path + " to file " + toFile, t); 
    142162        } 
    143163    } 
     
    247267    } 
    248268 
     269    protected void setExecutable(File file) throws MojoExecutionException { 
     270        // rough check to see if it's a unix-type system 
     271        if (System.getProperty("path.separator").equals(":")) { 
     272            try { 
     273                Process process = Runtime.getRuntime().exec(new String[] {"chmod", "u+x", file.getAbsolutePath()}); 
     274                process.waitFor(); 
     275                int exitValue = process.exitValue(); 
     276                if (exitValue != 0) { 
     277                    getLog().warn("Could not make the following file executable, you might want to do it yourself: " + file.getAbsolutePath()); 
     278                } 
     279            } catch (Exception e) { 
     280                throw new MojoExecutionException("Error trying to make file executable: " + file, e); 
     281            } 
     282        } 
     283    } 
    249284} 
  • trunk/tools/kauri-package-plugin/src/main/java/org/kauriproject/tools/plugin/packaging/KauriPackageMojo.java

    r756 r757  
    1 package org.kauriproject.tools.plugin.webapp
     1package org.kauriproject.tools.plugin.packaging
    22 
    33import org.apache.maven.plugin.MojoExecutionException; 
     
    4949        } 
    5050 
    51         createRepository(allArtifacts, packageDirectory + "/repository/"); 
     51        createRepository(allArtifacts, packageDirectory + "/lib/"); 
    5252 
    5353        // 
     
    5656        getLog().info("Including the kauri.xml file."); 
    5757        copyFile(new File(kauriConfigLocation), new File(packageDirectory + "/kauri.xml")); 
     58 
     59        // 
     60        // Include the service wrapper stuff 
     61        // 
     62        addServiceWrapper(); 
     63 
     64        // 
     65        // Include logging setup 
     66        // 
     67        addLogSetup(); 
     68 
     69        // 
     70        // 
     71        // 
     72        copyResource("HOW_TO_RUN.txt", new File(packageDirectory + "/HOW_TO_RUN.txt")); 
    5873    } 
    5974 
     
    6782        } 
    6883    } 
     84 
     85    private void addServiceWrapper() throws MojoExecutionException { 
     86        new File(packageDirectory, "service").mkdirs(); 
     87 
     88        copyResource("service/service-wrapper.conf", new File(packageDirectory + "/service/service-wrapper.conf")); 
     89        copyResource("service/README.txt", new File(packageDirectory + "/service/README.txt")); 
     90 
     91        // unix scripts 
     92        File kauriServiceDest = new File(packageDirectory + "/service/kauri-service"); 
     93        copyResource("service/kauri-service", kauriServiceDest); 
     94        setExecutable(kauriServiceDest); 
     95 
     96        // windows scripts 
     97        copyResource("service/install-kauri-service.bat", new File(packageDirectory + "/service/install-kauri-service.bat")); 
     98        copyResource("service/uninstall-kauri-service.bat", new File(packageDirectory + "/service/uninstall-kauri-service.bat")); 
     99        copyResource("service/kauri-service.bat", new File(packageDirectory + "/service/kauri-service.bat")); 
     100    } 
     101 
     102    private void addLogSetup() throws MojoExecutionException { 
     103        new File(packageDirectory, "logs").mkdir(); 
     104        copyResource("kauri-log4j.properties", new File(packageDirectory + "/kauri-log4j.properties")); 
     105    } 
    69106} 
  • trunk/tools/kauri-package-plugin/src/main/java/org/kauriproject/tools/plugin/packaging/KauriWebappMojo.java

    r756 r757  
    1 package org.kauriproject.tools.plugin.webapp
     1package org.kauriproject.tools.plugin.packaging
    22 
    33import org.apache.maven.plugin.MojoExecutionException; 
  • trunk/tools/kauri-package-plugin/src/main/resources/org/kauriproject/tools/plugin/packaging

    • Property svn:mergeinfo set