Skip to content

Commit cdab360

Browse files
committed
Merge pull request elastic#184 from rjernst/update_to_gradle
Build: Switch mapper attachments to gradle
2 parents 16674bd + 835994a commit cdab360

20 files changed

+160
-780
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
/.local-execution-hints.log
1313
/.local-*-execution-hints.log
1414
/eclipse-build/
15+
build/
16+
generated-resources/
17+
.gradle/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You need to install a version matching your Elasticsearch version:
3535
To build a `SNAPSHOT` version, you need to build it with Maven:
3636

3737
```bash
38-
mvn clean install
38+
gradle clean assemble
3939
plugin --install mapper-attachments \
4040
--url file:target/releases/elasticsearch-mapper-attachments-X.X.X-SNAPSHOT.zip
4141
```

build.gradle

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import org.elasticsearch.gradle.ElasticsearchProperties
21+
22+
buildscript {
23+
repositories {
24+
mavenCentral()
25+
maven {
26+
name 'sonatype-snapshots'
27+
url 'http://oss.sonatype.org/content/repositories/snapshots/'
28+
}
29+
jcenter()
30+
}
31+
dependencies {
32+
classpath 'org.elasticsearch.gradle:build-tools:3.0.0-SNAPSHOT'
33+
}
34+
}
35+
apply plugin: 'idea'
36+
apply plugin: 'eclipse'
37+
apply plugin: 'elasticsearch.esplugin'
38+
39+
esplugin {
40+
description 'The mapper attachments plugin adds the attachment type to Elasticsearch using Apache Tika.'
41+
classname 'org.elasticsearch.plugin.mapper.attachments.MapperAttachmentsPlugin'
42+
}
43+
44+
group = 'org.elasticsearch.plugin'
45+
version = ElasticsearchProperties.version
46+
ext.luceneVersion = ElasticsearchProperties.luceneVersion
47+
repositories {
48+
mavenCentral()
49+
maven {
50+
name 'sonatype-snapshots'
51+
url 'http://oss.sonatype.org/content/repositories/snapshots/'
52+
}
53+
if (luceneVersion.contains('-snapshot')) {
54+
String revision = (luceneVersion =~ /\d\.\d\.\d-snapshot-(\d+)/)[0][1]
55+
maven {
56+
name 'lucene-snapshots'
57+
url "http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}"
58+
}
59+
}
60+
}
61+
62+
dependencies {
63+
compile('org.apache.tika:tika-parsers:1.10') {
64+
// TODO: is all of edu.ucar incompatibile with apache2 license? if so, we can exclude the group?
65+
// Not Apache2 License compatible
66+
exclude group: 'edu.ucar', module: 'netcdf'
67+
exclude group: 'edu.ucar', module: 'cdm'
68+
exclude group: 'edu.ucar', module: 'httpservices'
69+
exclude group: 'edu.ucar', module: 'grib'
70+
exclude group: 'edu.ucar', module: 'netcdf4'
71+
exclude group: 'com.uwyn', module: 'jhighlight'
72+
// ES core already has these
73+
exclude group: 'commons-logging', module: 'commons-logging-api'
74+
}
75+
}
76+
77+
compileJava.options.compilerArgs << '-Xlint:-cast,-deprecation,-rawtypes'
78+
79+
forbiddenPatterns {
80+
exclude '**/*.docx'
81+
exclude '**/*.pdf'
82+
}

pom.xml

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/main/assemblies/plugin.xml

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/main/java/org/elasticsearch/index/mapper/attachment/AttachmentMapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.tika.language.LanguageIdentifier;
2727
import org.apache.tika.metadata.Metadata;
2828
import org.elasticsearch.Version;
29+
import org.elasticsearch.common.collect.Iterators;
2930
import org.elasticsearch.common.io.stream.StreamInput;
3031
import org.elasticsearch.common.logging.ESLogger;
3132
import org.elasticsearch.common.logging.ESLoggerFactory;
@@ -58,7 +59,7 @@
5859
* }
5960
* }
6061
* </pre>
61-
* <p/>
62+
* <p>
6263
* _content_length = Specify the maximum amount of characters to extract from the attachment. If not specified, then the default for
6364
* tika is 100,000 characters. Caution is required when setting large values as this can cause memory issues.
6465
*/
@@ -624,8 +625,9 @@ public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMapping
624625
}
625626

626627
@Override
628+
@SuppressWarnings("unchecked")
627629
public Iterator<Mapper> iterator() {
628-
List<FieldMapper> extras = Arrays.asList(
630+
List<Mapper> extras = Arrays.asList(
629631
contentMapper,
630632
dateMapper,
631633
titleMapper,
@@ -635,7 +637,7 @@ public Iterator<Mapper> iterator() {
635637
contentTypeMapper,
636638
contentLengthMapper,
637639
languageMapper);
638-
return CollectionUtils.concat(super.iterator(), extras.iterator());
640+
return Iterators.concat(super.iterator(), extras.iterator());
639641
}
640642

641643
@Override

src/main/java/org/elasticsearch/index/mapper/attachment/RegisterAttachmentType.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/org/elasticsearch/plugin/mapper/attachments/AttachmentsIndexModule.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/org/elasticsearch/plugin/mapper/attachments/MapperAttachmentsPlugin.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@
1919

2020
package org.elasticsearch.plugin.mapper.attachments;
2121

22-
import org.elasticsearch.common.inject.Module;
23-
import org.elasticsearch.common.settings.Settings;
22+
import org.elasticsearch.index.IndexService;
23+
import org.elasticsearch.index.mapper.attachment.AttachmentMapper;
2424
import org.elasticsearch.plugins.Plugin;
2525

26-
import java.util.Collection;
27-
import java.util.Collections;
28-
29-
/**
30-
*
31-
*/
3226
public class MapperAttachmentsPlugin extends Plugin {
3327

3428
@Override
@@ -42,7 +36,7 @@ public String description() {
4236
}
4337

4438
@Override
45-
public Collection<Module> indexModules(Settings indexSettings) {
46-
return Collections.<Module>singletonList(new AttachmentsIndexModule());
39+
public void onIndexService(IndexService indexService) {
40+
indexService.mapperService().documentMapperParser().putTypeParser("attachment", new AttachmentMapper.TypeParser());
4741
}
4842
}

src/main/resources/es-plugin.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)