Skip to content

Commit

Permalink
Adding solr phing
Browse files Browse the repository at this point in the history
  • Loading branch information
ngroot committed Jun 22, 2014
1 parent 4bf2a84 commit b85af6d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ A lot of the AutoPhing build files use configuration parameters to run the comma
+ [PHPLint](lib/phplint/README.md)
+ PHPMD
+ PHPUnit
+ [Solr](lib/solr/README.md)
+ [Swagger](lib/swagger/README.md)
+ [Webistrano](lib/webistrano/README.md)
+ [YUICompressor](lib/yuicompressor/README.md)
Expand Down
29 changes: 29 additions & 0 deletions lib/solr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
AutoPhing SOLR
==============

Run SOLR Api commands

## Targets ##

### solr-core-create ###
Create a (new) core in SOLR based on source configuration in your project. It will move the config to the running
solr instance.

### solr-api-core-create ###
Create a core configuration

### solr-api-core-reload ###
Reload a core configuration

### solr-api-core-unload ###
Remove a solr core

## Configuration ##

+ `solr.http.url` - The SOLR http location. Defaults to `http;//localhost:8983/solr/`
+ `solr.config.source` - The SOLR config project location (source files)
+ `solr.config.destination` - The SOLR config folder
+ `solr.core.source` - The SOLR core source configuration
+ `solr.core.name` - The SOLR core name


7 changes: 7 additions & 0 deletions lib/solr/solr.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
solr.http.url=http://localhost:8983/solr/

solr.config.root=${phing.dir}
solr.config.destination=${phing.dir}

solr.core.source=autophing-core
solr.core.name=${solr.core.source}
67 changes: 67 additions & 0 deletions lib/solr/solr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="solr" default="solr-core-reload" basedir=".">
<property file="${phing.dir.solr}/solr.properties" />

<target name="solr-core-create">
<available property="solr.core.available" file="${solr.config.destination}/${solr.core.name}" type="dir" />

<if>
<equals arg1="${solr.core.available}" arg2="true" />
<then>
<!-- Core already available. Only remove config and let it rebuild -->
<if>
<!-- It can be possible to have same source and destination. Don't remove -->
<not><equals arg1="${solr.config.source}/${solr.core.source}" arg2="${solr.config.destination}/${solr.core.name}" /></not>
<then>
<delete>
<fileset dir="${solr.config.destination}/${solr.core.name}">
<exclude name="data/**" />
</fileset>
</delete>
</then>
</if>
</then>
</if>

<!-- Copy the contents of the config to the core -->
<copy todir="${solr.config.destination}/${solr.core.name}">
<fileset dir="${solr.config.source}/${solr.core.source}">
<exclude name="data/**" />
</fileset>
</copy>

<if>
<equals arg1="${solr.core.available}" arg2="true" />
<then>
<phingcall target="solr-api-core-reload" />
</then>
<else>
<phingcall target="solr-api-core-create" />
</else>
</if>
</target>

<target name="solr-api-core-create">
<exec passthru="${passthru}" executable="curl" escape="true">
<arg line="-X" />
<arg value="GET" />
<arg value="${solr.http.url}admin/cores?action=CREATE&amp;name=${solr.core.name}&amp;instanceDir=${solr.core.name}&amp;persist=true" />
</exec>
</target>

<target name="solr-api-core-reload">
<exec passthru="${passthru}" executable="curl" escape="true">
<arg line="-X" />
<arg value="GET" />
<arg value="${solr.http.url}admin/cores?action=RELOAD&amp;core=${solr.core.name}" />
</exec>
</target>

<target name="solr-api-core-unload">
<exec passthru="${passthru}" executable="curl" escape="true">
<arg line="-X" />
<arg value="GET" />
<arg value="${solr.http.url}admin/cores?action=UNLOAD&amp;core=${solr.core.name}" />
</exec>
</target>
</project>

0 comments on commit b85af6d

Please sign in to comment.