directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre-Arnaud Marcelot ...@marcelot.net>
Subject Re: Schema Index and Maven plugin was: Re: svn commit: r1038592 - in /directory/shared/trunk/ldap-schema/src/main: java/org/apache/directory/shared/ldap/schema/ldif/extractor/impl/ResourceMap.java resources/META-INF/ resources/META-INF/apacheds-schem
Date Thu, 25 Nov 2010 09:07:28 GMT
Stefan found some issue with this yesterday evening on Windows where file and path separators
are different from those used on Unix machines.

Here's an updated version of the configuration to fix these issues:
>       <plugin>
>         <artifactId>maven-antrun-plugin</artifactId>
>         <version>1.6</version>
>         <executions>
>           <execution>
>             <phase>generate-resources</phase>
>             <configuration>
>               <target>
>                 <!-- Various properties -->
>                 <property name="schema.index" value="target/classes/META-INF/apacheds-schema.index"/>
>                 <property name="schema.location" value="src${file.separator}main${file.separator}resources${file.separator}"/>
>               
>                 <!-- Listing all LDIF files under schema location -->
>                 <path id="schema.files.path">
>                   <fileset dir="${schema.location}">
>                     <include name="**/*.ldif" />
>                     <exclude name="schema-all.ldif" />
>                   </fileset>
>                 </path>
>                 <property name="schema.files" refid="schema.files.path"/>
>                 
>                 <!-- Creating the schema index file -->
>                 <echo message="${schema.files}" file="${schema.index}"/>
>                 <replace file="${schema.index}">
>                   <!-- Replace the path separator (':' on Unix, ';' on Windows) by
a new line -->
>                   <replacefilter token="${path.separator}" value="${line.separator}"/>
>                   <!-- Remove the full path of the schema location to get relative
paths for files -->
>                   <replacefilter token="${basedir}${file.separator}${schema.location}"
value=""/>
>                   <!-- Replace the file separator ('/' on Unix, '\' on Windows) by
a '/' - Useful on Windows -->
>                   <replacefilter token="${file.separator}" value="/"/>
>                 </replace>
>               </target>
>             </configuration>
>             <goals>
>               <goal>run</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>


It now works fine on both Unix and Windows machines.

Regards,
Pierre-Arnaud

On 24 nov. 2010, at 17:43, Stefan Seelmann wrote:

> Great! Many thanks Pierre-Arnaud. I always knew that the antrun plugin
> is the best Maven plugin :-)
> 
> On Wed, Nov 24, 2010 at 5:09 PM, Pierre-Arnaud Marcelot <pa@marcelot.net> wrote:
>> Yes, it is... :)
>> For the record, here's how:
>> 
>>       <plugin>
>>         <artifactId>maven-antrun-plugin</artifactId>
>>         <version>1.6</version>
>>         <executions>
>>           <execution>
>>             <phase>generate-resources</phase>
>>             <configuration>
>>               <target>
>>                 <!-- Various properties -->
>>                 <property name="schema.index"
>> value="target/classes/META-INF/apacheds-schema.index"/>
>>                 <property name="schema.location"
>> value="src/main/resources/"/>
>> 
>>                 <!-- Listing all LDIF files under schema location -->
>>                 <path id="schema.files.path">
>>                   <fileset dir="${schema.location}">
>>                     <include name="**/*.ldif" />
>>                     <exclude name="schema-all.ldif" />
>>                   </fileset>
>>                 </path>
>>                 <property name="schema.files" refid="schema.files.path"/>
>> 
>>                 <!-- Creating the schema index file -->
>>                 <echo message="${schema.files}" file="${schema.index}"/>
>>                 <replace file="${schema.index}">
>>                   <replacefilter token=":" value="${line.separator}"/>
>>                   <replacefilter token="${basedir}/${schema.location}"
>> value=""/>
>>                 </replace>
>>               </target>
>>             </configuration>
>>             <goals>
>>               <goal>run</goal>
>>             </goals>
>>           </execution>
>>         </executions>
>>       </plugin>
>> 
>> It has been committed at revision: 1038659.
>> http://svn.apache.org/viewvc?rev=1038659&view=rev
>> Regards,
>> Pierre-Arnaud
>> On 24 nov. 2010, at 16:21, Emmanuel Lecharny wrote:
>> 
>> On 11/24/10 4:10 PM, Stefan Seelmann wrote:
>> 
>> Hi guys,
>> 
>> I committed the change below. It allows to use the schema loaders in
>> 
>> embedded environments (especially in Apache Directory Studio, but
>> 
>> should also work for web applications).
>> 
>> The idea is to have a fixed-named schema index file
>> 
>> "META-INF/apacheds-schema.index" that contains all resource paths to
>> 
>> the schema LDIF files. The ResourceMap class then can read that file
>> 
>> form its class loader to get all resources. Thanks to Owen Jacobson
>> 
>> for the idea.
>> 
>> Currently the index file is in the repository. I'm going to write a
>> 
>> Maven plugin to create that file automatically during the build. The
>> 
>> Maven plugin should bind to the generate-resource phase. The
>> 
>> alternative would be to use the exec plugin that executes something
>> 
>> like
>> 
>>   find src/main/resources/schema -name "*.ldif" | sed
>> 
>> 's:src/main/resources/::'>
>> 
>> target/classes/META-INF/apacheds-schema.index
>> 
>> but that wouldn't work on Windows.
>> 
>> If anyone has a better idea how to avoid a new Maven plugin, please tell.
>> 
>> Isn't it possible to do that using a ant task in maven ?
>> 
>> 
>> --
>> Regards,
>> Cordialement,
>> Emmanuel L├ęcharny
>> www.iktek.com
>> 
>> 
>> 


Mime
View raw message