You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Sami Siren (Updated) (JIRA)" <ji...@apache.org> on 2012/04/17 11:51:19 UTC
[jira] [Updated] (SOLR-1888) Annotated beans source generation with
maven plugin
[ https://issues.apache.org/jira/browse/SOLR-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sami Siren updated SOLR-1888:
-----------------------------
Component/s: (was: clients - java)
> Annotated beans source generation with maven plugin
> ---------------------------------------------------
>
> Key: SOLR-1888
> URL: https://issues.apache.org/jira/browse/SOLR-1888
> Project: Solr
> Issue Type: New Feature
> Affects Versions: 1.5
> Environment: java, maven
> Reporter: Matthias Epheser
> Fix For: 4.0
>
> Attachments: maven-solr-plugin.zip
>
>
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org