Skip to content
This repository

Added Lucene to the project #12

Merged
merged 1 commit into from about 1 year ago

3 participants

Mads Hartmann Jensen Mirco Dotta Luc Bourlier
Mads Hartmann Jensen
Collaborator

The dependency has been added in maven and a goal that copies
dependencies to target/lib has been added such that we can
reference the libraries in the Eclipse classpath and the
manifest of the OSGI bundles.

I added a very basic integration test that shows that the
classpath is set up properly and that Lucene is working.

Fixes #5

org.scala.tools.eclipse.search.tests/src/org/scala/tools/eclipse/search/TestsSuite.java
... ...
@@ -0,0 +1,12 @@
  1
+package org.scala.tools.eclipse.search;
  2
+
  3
+import org.junit.runner.RunWith;
  4
+import org.junit.runners.Suite;
  5
+import org.scala.tools.eclipse.search.LuceneIntegrationTest;
  6
+
  7
+
  8
+@RunWith(Suite.class)
  9
+@Suite.SuiteClasses({
  10
+  LuceneIntegrationTest.class
  11
+})
  12
+class TestsSuite {}
2
Mirco Dotta Owner
dotta added a note February 13, 2013

This should be a .scala file. I know it's a java one in the sdt.core, but there are no good reasons for that :) (e.g., https://github.com/scala-ide/scala-ide/blob/master/org.scala-ide.sdt.debug.tests/src/scala/tools/eclipse/debug/ScalaDebugTestSuite.scala)

Mads Hartmann Jensen Collaborator
mads379 added a note February 13, 2013

Great, I'll create a Scala file instead. I got desperate and tried everything yesterday when things didn't work :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
org.scala.tools.eclipse.search.tests/src/org/scala/tools/eclipse/search/LuceneIntegrationTest.scala
((4 lines not shown))
  4
+
  5
+import org.apache.lucene.analysis.core.SimpleAnalyzer
  6
+import org.apache.lucene.document.Document
  7
+import org.apache.lucene.document.Field
  8
+import org.apache.lucene.index.DirectoryReader
  9
+import org.apache.lucene.index.IndexWriter
  10
+import org.apache.lucene.index.IndexWriterConfig
  11
+import org.apache.lucene.store.FSDirectory
  12
+import org.apache.lucene.util.Version
  13
+import org.junit.Assert._
  14
+import org.junit.Test
  15
+
  16
+class LuceneIntegrationTest {
  17
+
  18
+  @Test def integration() {
  19
+    val dir = FSDirectory.open(new File("lucene-test-dir"))
2
Mirco Dotta Owner
dotta added a note February 13, 2013

Where is this fodler going to be created? Somewhere under target?

Mads Hartmann Jensen Collaborator
mads379 added a note February 13, 2013

In the next commit I state the location explicitly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Mirco Dotta
Owner

The setup LGTM. I guess you only need to finish up the test. Good job!

Mirco Dotta
Owner

LGTM. (feel free to amends commit as needed)

Mads Hartmann Jensen Added Lucene to the project
The dependency has been added in maven and a goal that copies
dependencies to target/lib has been added such that we can
reference the libraries in the Eclipse classpath and the
manifest of the OSGI bundles.

I added a very basic integration test that shows that the
classpath is set up properly and that Lucene is working.

Fixes #5
902a329
Mads Hartmann Jensen
Collaborator

Alright, the commits have been packed together nicely :) You can just merge when you're ready

Mirco Dotta dotta merged commit 7d152c4 into from February 14, 2013
Mirco Dotta dotta closed this February 14, 2013
Luc Bourlier skyluc commented on the diff February 14, 2013
org.scala.tools.eclipse.search.tests/.classpath
@@ -4,5 +4,7 @@
4 4
 	<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
5 5
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
6 6
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
  7
+	<classpathentry kind="lib" path="/org.scala.tools.eclipse.search/target/lib/lucene-analyzers-common-4.1.0.jar"/>
  8
+	<classpathentry kind="lib" path="/org.scala.tools.eclipse.search/target/lib/lucene-core-4.1.0.jar"/>
2
Luc Bourlier Owner
skyluc added a note February 14, 2013

You shouldn't have to add the jars in this project.
The search.tests project is fragment on top of the search project/plugin, so it has access to everything the main plugin provides.

Mirco Dotta Owner
dotta added a note February 14, 2013

Right, I missed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Luc Bourlier
Owner

It is one way to do it (and it works fine).
An other solution would be to add Lucene as plugins. InstaSearch provides a version of it already wrapped as a bundle. Maybe we could you depend on them. (http://code.inf.unibz.it/instasearch/downloads/plugins/)
(The versions might not be the same)

Mads Hartmann Jensen
Collaborator

Thanks @skyluc I'll have a look at it but probably not today; I've met my quota of annoying build problems ;)

Mirco Dotta
Owner

InstaSearch provides a version of it already wrapped as a bundle.

Would this mean that we need to insatall InstaSearch to work on the scala-search project?

Luc Bourlier
Owner

Would this mean that we need to insatall InstaSearch to work on the scala-search project?

We can create our own repo containing only copy of the Lucene bundle, compile scala-search with this repo and package everything together. (% any license problem).

Then to develop scala-search, you have to install scala-search.

Mirco Dotta
Owner

It doesn't look simpler to me :)

Mads Hartmann Jensen mads379 deleted the branch February 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 14, 2013
Mads Hartmann Jensen Added Lucene to the project
The dependency has been added in maven and a goal that copies
dependencies to target/lib has been added such that we can
reference the libraries in the Eclipse classpath and the
manifest of the OSGI bundles.

I added a very basic integration test that shows that the
classpath is set up properly and that Lucene is working.

Fixes #5
902a329
This page is out of date. Refresh to see the latest.
2  org.scala.tools.eclipse.search.tests/.classpath
@@ -4,5 +4,7 @@
4 4
 	<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
5 5
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
6 6
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
  7
+	<classpathentry kind="lib" path="/org.scala.tools.eclipse.search/target/lib/lucene-analyzers-common-4.1.0.jar"/>
  8
+	<classpathentry kind="lib" path="/org.scala.tools.eclipse.search/target/lib/lucene-core-4.1.0.jar"/>
7 9
 	<classpathentry kind="output" path="target/classes"/>
8 10
 </classpath>
3  org.scala.tools.eclipse.search.tests/pom.xml
@@ -16,10 +16,11 @@
16 16
         <artifactId>tycho-surefire-plugin</artifactId>
17 17
         <configuration>
18 18
           <testSuite>${project.artifactId}</testSuite>
19  
-          <testClass>org.scala.tools.eclipse.search.SomeInterestingCodeTest</testClass>
  19
+          <testClass>org.scala.tools.eclipse.search.TestsSuite</testClass>
20 20
         </configuration>
21 21
       </plugin>
22 22
     </plugins>
23 23
   </build>
  24
+
24 25
 </project>
25 26
 
41  org.scala.tools.eclipse.search.tests/src/org/scala/tools/eclipse/search/LuceneIntegrationTest.scala
... ...
@@ -0,0 +1,41 @@
  1
+package org.scala.tools.eclipse.search
  2
+
  3
+import java.io.File
  4
+
  5
+import org.apache.lucene.analysis.core.SimpleAnalyzer
  6
+import org.apache.lucene.document.Document
  7
+import org.apache.lucene.document.Field
  8
+import org.apache.lucene.index.DirectoryReader
  9
+import org.apache.lucene.index.IndexWriter
  10
+import org.apache.lucene.index.IndexWriterConfig
  11
+import org.apache.lucene.store.FSDirectory
  12
+import org.apache.lucene.util.Version
  13
+import org.junit.Assert._
  14
+import org.junit.Test
  15
+
  16
+object LuceneIntegrationTest {
  17
+  val INDEX_DIR = new File(path("target","lucene-test-index"))
  18
+
  19
+  private def path(strings: String*) =
  20
+    strings.mkString(File.separator)
  21
+}
  22
+
  23
+class LuceneIntegrationTest {
  24
+
  25
+  import LuceneIntegrationTest._
  26
+
  27
+  @Test def integration() {
  28
+    val dir = FSDirectory.open(INDEX_DIR)
  29
+    val analyzer = new SimpleAnalyzer(Version.LUCENE_41)
  30
+    val config = new IndexWriterConfig(Version.LUCENE_41, analyzer);
  31
+    val writer = new IndexWriter(dir, config)
  32
+    val doc = new Document
  33
+    doc.add(new Field("test", "it works!", Field.Store.YES, Field.Index.NOT_ANALYZED))
  34
+    writer.addDocument(doc)
  35
+    writer.close()
  36
+    val reader = DirectoryReader.open(dir)
  37
+    val d = reader.document(0)
  38
+
  39
+    assertEquals("Should be able to store and read a document", doc.get("test"), d.get("test"))
  40
+  }
  41
+}
11  org.scala.tools.eclipse.search.tests/src/org/scala/tools/eclipse/search/TestsSuite.scala
... ...
@@ -0,0 +1,11 @@
  1
+package org.scala.tools.eclipse.search
  2
+
  3
+import org.junit.runner.RunWith
  4
+import org.junit.runners.Suite
  5
+
  6
+
  7
+@RunWith(classOf[Suite])
  8
+@Suite.SuiteClasses(Array(
  9
+  classOf[LuceneIntegrationTest]
  10
+))
  11
+class TestsSuite {}
2  org.scala.tools.eclipse.search/.classpath
@@ -4,5 +4,7 @@
4 4
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 5
 	<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
6 6
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
  7
+	<classpathentry kind="lib" path="target/lib/lucene-analyzers-common-4.1.0.jar"/>
  8
+	<classpathentry kind="lib" path="target/lib/lucene-core-4.1.0.jar"/>
7 9
 	<classpathentry kind="output" path="target/classes"/>
8 10
 </classpath>
4  org.scala.tools.eclipse.search/META-INF/MANIFEST.MF
@@ -30,4 +30,6 @@ Import-Package:
30 30
  scala.tools.eclipse;apply-aspects:=false,
31 31
  scala.tools.eclipse.contribution.weaving.jdt.ui.javaeditor.formatter;apply-aspects:=false
32 32
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
33  
-Bundle-ClassPath: .
  33
+Bundle-ClassPath: .,
  34
+ target/lib/lucene-core-4.1.0.jar,
  35
+ target/lib/lucene-analyzers-common-4.1.0.jar
4  org.scala.tools.eclipse.search/build.properties
... ...
@@ -1,7 +1,7 @@
1 1
 source.. = src/
2 2
 output.. = target/classes/
3 3
 bin.includes = META-INF/,\
4  
-               icons/,\
5 4
                .,\
6 5
                plugin.xml,\
7  
-               plugin.properties
  6
+               plugin.properties,\
  7
+               target/lib/\
48  org.scala.tools.eclipse.search/pom.xml
@@ -10,4 +10,52 @@
10 10
   <artifactId>org.scala.tools.eclipse.search</artifactId>
11 11
   <packaging>eclipse-plugin</packaging>
12 12
 
  13
+  <dependencies>
  14
+    <dependency>
  15
+      <groupId>org.apache.lucene</groupId>
  16
+      <artifactId>lucene-core</artifactId>
  17
+      <version>4.1.0</version>
  18
+    </dependency>
  19
+    <dependency>
  20
+      <groupId>org.apache.lucene</groupId>
  21
+      <artifactId>lucene-analyzers-common</artifactId>
  22
+      <version>4.1.0</version>
  23
+    </dependency>
  24
+  </dependencies>
  25
+
  26
+  <build>
  27
+    <plugins>
  28
+      <plugin>
  29
+        <groupId>org.apache.maven.plugins</groupId>
  30
+        <artifactId>maven-dependency-plugin</artifactId>
  31
+        <executions>
  32
+          <!-- copy the jar dependencies -->
  33
+          <execution>
  34
+            <id>copy</id>
  35
+            <phase>initialize</phase>
  36
+            <goals>
  37
+              <goal>copy</goal>
  38
+            </goals>
  39
+            <configuration>
  40
+              <artifactItems>
  41
+                <artifactItem>
  42
+                  <groupId>org.apache.lucene</groupId>
  43
+                  <artifactId>lucene-core</artifactId>
  44
+                  <version>4.1.0</version>
  45
+                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
  46
+                </artifactItem>
  47
+                <artifactItem>
  48
+                  <groupId>org.apache.lucene</groupId>
  49
+                  <artifactId>lucene-analyzers-common</artifactId>
  50
+                  <version>4.1.0</version>
  51
+                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
  52
+                </artifactItem>
  53
+              </artifactItems>
  54
+            </configuration>
  55
+          </execution>
  56
+        </executions>
  57
+      </plugin>
  58
+    </plugins>
  59
+  </build>
  60
+
13 61
 </project>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.