lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Epheser (JIRA)" <>
Subject [jira] Updated: (SOLR-1888) Annotated beans source generation with maven plugin
Date Thu, 22 Apr 2010 15:51:50 GMT


Matthias Epheser updated SOLR-1888:


> Annotated beans source generation with maven plugin
> ---------------------------------------------------
>                 Key: SOLR-1888
>                 URL:
>             Project: Solr
>          Issue Type: New Feature
>          Components: clients - java
>    Affects Versions: 1.5
>         Environment: java, maven
>            Reporter: Matthias Epheser
>             Fix For: 1.5
>         Attachments:
> As I stumbled over a lot of copy pasting while creating java annotated beans representing
a schema.xml, i decided to make a shortcut and create a maven plugin.
> Think about it as source generation similar to castor/jaxb code generation from an xsd.
You just point to a schema.xml and connect to the generate-sources phase. This leads to a
java bean in target/generated-sources/solr that contains all fields from the schema well annotated.

> The mapping reads the <fields> section and maps field="string" to solr.StringField
to java.lang String etc. Multivalured fields generate lists, dynamic fields Maps. Currently
the code generation is plain simple, just a fileWriter with some intends. The getValidJavaName(String
name) may act more professional than now.
> Just install the plugin contained in the zip using mvn install and connect it to an existing
solrj project:
> {{
> <plugin>
> 	     <groupId>org.apache.solr</groupId>
> 	     <artifactId>maven-solr-plugin</artifactId>
> 	     <configuration>
> 	       <schemaFile>test-data/solr/conf/schema.xml</schemaFile>
> 	       <qualifiedName>org.test.MyBean</qualifiedName>
> 	     </configuration>
> 	     <executions>
>           <execution>
>             <phase>generate-sources</phase>
>             <goals>
>               <goal>generate</goal>
>             </goals>
>           </execution>
>         </executions>
>  </plugin>
> }}
> The generated fiels will be automatically added to the classpath after the first run
of mvn generate/compile. So just execute mvn eclipse:eclipse once after that. After every
change in the schema, generate again and your bean will be updated and fields and getters
and setters will be present.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message