On Wed, 2003-06-18 at 14:22, Konstantin Priblouda wrote:

> --- "Henning P. Schmiedehausen" <[EMAIL PROTECTED]>
> wrote:
> > Konstantin Priblouda <[EMAIL PROTECTED]> writes:
> > 
> > >Hi all, 
> > 
> > >I noticed that velocity does not provide convenient
> > >way of loading templates packed in .war files.
> > 
> > There is the jar loader, which I use all the time.
> > You roll up your
> > templates in a jar which you can then put into a
> > .war
> 
> This is not very convenient. JSP have one advantage
> over  velocity -  it's damn convenient. 
> They work from expanded war the same ways as from
> packed, just throw them in the directory and you are
> fine. 
> 
> I like to have resource loader to have the same
> flexibility. like:
> if it's a expanded behave like file resource loader,
> if not like classpath one.
> 
> And producing yet another jar to be packed is not very
> convenient if you have maven build environment. 
> ( and complicates ant setup )

If you're already using maven, rolling your templates into a jar is the
easiest thing in the world.

As you're german, I left the german remarks in. This is _straight_ from
one of my applications where I roll up the templates into a jar for
deployment and leave them unrolled for debugging and development. 

Maven is all about making things easier in a modular way. Doing things
like this, maven really shines.

BTW: The first two pattern sets are basically "just this file in a tree"
and "everything in this tree but just this file". Is there any way to
get an "inverted" file set in maven / ant? 

        Regards
                Henning


--- cut --- maven.xml --- cut ---
  <!-- ================================================================== -->
  <!-- Diese Patternsets entscheiden, welche Dateien aus dem              -->
  <!-- src/templates Verzeichnis in das Template-Jar wandern und welche   -->
  <!-- direkt in die Webapplikation / WAR kopiert werden. Muessen immer   -->
  <!-- gleich sein!                                                       -->
  <!-- ================================================================== -->

  <patternset id="template.files.include">
    <exclude name="screens/Index.vm"/>
  </patternset>

  <patternset id="template.files.exclude">
    <include name="screens/Index.vm"/>
  </patternset>

  <!-- ================================================================== -->
  <!-- Wenn das Haupt-Jar ok ist, dann auch noch das Template Jar bauen   -->
  <!-- ================================================================== -->

  <postGoal name="java:jar">
    <attainGoal name="build-template-jar"/>
  </postGoal>

  <!-- ================================================================== -->
  <!-- Rolle die Templates in einem Jar zusammen                          -->
  <!-- ================================================================== -->

  <goal name="build-template-jar" description="Erzeugt das Template Jar fuer die 
Applikation">
    <j:set var="template.jar.name" 
value="${pom.artifactId}-templates-${pom.currentVersion}"/>

    <uptodate
      property="haveTemplateJar"
      targetfile="${maven.build.dir}/${template.jar.name}.jar">
      <srcfiles dir="${maven.src.dir}/templates">
        <patternset refid="template.files.include"/>
      </srcfiles>
    </uptodate>

    <j:if test="${haveTemplateJar != 'true'}">

      <echo>Building Templates Jar: ${template.jar.name}.jar</echo>

      <mkdir dir="${maven.build.dir}"/>
      <jar jarfile="${maven.build.dir}/${template.jar.name}.jar">
        <metainf dir="${basedir}">
          <include name="LICENSE.txt"/>
        </metainf>
        <manifest>
          <attribute name="Built-By" value="${user.name}"/>
          <!-- name should be '/' separated, not '.' -->
          <section name="${maven.package}">
            <attribute name="Specification-Title"    value="${pom.artifactId}"/>
            <attribute name="Specification-Version"  value="${pom.currentVersion}"/>
            <attribute name="Specification-Vendor"   value="${pom.organization}"/>
            <attribute name="Implementation-Title"   value="${pom.package}"/>
            <attribute name="Implementation-Version" value="${pom.currentVersion}"/>
            <attribute name="Implementation-Vendor"  value="${pom.organization}"/>
          </section>
        </manifest>
        <fileset dir="${maven.src.dir}/templates">
          <patternset refid="template.files.include"/>
        </fileset>
      </jar>

    </j:if>

  </goal>

  <postGoal name="war:webapp">
   <!-- Applikations Jars einkopieren -->
   <copy todir="${webapp.build.lib}">
     <fileset dir="${maven.build.dir}">
       <include name="${template.jar.name}.jar"/>
     </fileset>
   </copy>

   <mkdir dir="${webapp.build}/templates/${pom.artifactId}"/>
   <copy todir="${webapp.build}/templates" includeEmptyDirs="no">
     <fileset dir="${maven.src.dir}/templates">
        <patternset refid="template.files.exclude"/>
     </fileset>
   </copy>
  </postGoal>
--- cut --- maven.xml --- cut ---

        Regards
                Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     [EMAIL PROTECTED]

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   [EMAIL PROTECTED]
D-91054 Buckenhof     Fax.: 09131 / 50654-20   


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to