Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Build: Switch mapper attachments to gradle
Browse files Browse the repository at this point in the history
This change switches the plugin to use gradle as the build system, and
updates the master branch to track elasticsearch master.
  • Loading branch information
rjernst committed Nov 6, 2015
1 parent 16674bd commit 867f496
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 744 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
/.local-execution-hints.log
/.local-*-execution-hints.log
/eclipse-build/
build/
generated-resources/
.gradle/
83 changes: 83 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import org.elasticsearch.gradle.ElasticsearchProperties

buildscript {
repositories {
mavenCentral()
maven {
name 'sonatype-snapshots'
url 'http://oss.sonatype.org/content/repositories/snapshots/'
}
jcenter()
}
dependencies {
classpath 'org.elasticsearch.gradle:build-tools:3.0.0-SNAPSHOT'
}
}
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'elasticsearch.esplugin'

esplugin {
description 'The mapper attachments plugin adds the attachment type to Elasticsearch using Apache Tika.'
classname 'org.elasticsearch.plugin.mapper.attachments.MapperAttachmentsPlugin'
}

project.group = 'org.elasticsearch'
project.version = ElasticsearchProperties.version
project.ext.luceneVersion = ElasticsearchProperties.luceneVersion
repositories {
mavenCentral()
maven {
name 'sonatype-snapshots'
url 'http://oss.sonatype.org/content/repositories/snapshots/'
}
if (luceneVersion.contains('-snapshot')) {
String revision = (luceneVersion =~ /\d\.\d\.\d-snapshot-(\d+)/)[0][1]
maven {
name 'lucene-snapshots'
url "http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}"
}
}
}

dependencies {
compile('org.apache.tika:tika-parsers:1.10') {
// TODO: is all of edu.ucar incompatibile with apache2 license? if so, we can exclude the group?
// Not Apache2 License compatible
exclude group: 'edu.ucar', module: 'netcdf'
exclude group: 'edu.ucar', module: 'cdm'
exclude group: 'edu.ucar', module: 'httpservices'
exclude group: 'edu.ucar', module: 'grib'
exclude group: 'edu.ucar', module: 'netcdf4'
exclude group: 'com.uwyn', module: 'jhighlight'
// ES core already has these
exclude group: 'org.aw2.asm', module: 'asm-debug-all'
exclude group: 'commons-logging', module: 'commons-logging-api'
}
}

compileJava.options.compilerArgs << '-Xlint:-cast,-deprecation,-rawtypes'

forbiddenPatterns {
exclude '**/*.docx'
exclude '**/*.pdf'
}
118 changes: 0 additions & 118 deletions pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.tika.language.LanguageIdentifier;
import org.apache.tika.metadata.Metadata;
import org.elasticsearch.Version;
import org.elasticsearch.common.collect.Iterators;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.ESLoggerFactory;
Expand Down Expand Up @@ -58,7 +59,7 @@
* }
* }
* </pre>
* <p/>
* <p>
* _content_length = Specify the maximum amount of characters to extract from the attachment. If not specified, then the default for
* tika is 100,000 characters. Caution is required when setting large values as this can cause memory issues.
*/
Expand Down Expand Up @@ -624,8 +625,9 @@ public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMapping
}

@Override
@SuppressWarnings("unchecked")
public Iterator<Mapper> iterator() {
List<FieldMapper> extras = Arrays.asList(
List<Mapper> extras = Arrays.asList(
contentMapper,
dateMapper,
titleMapper,
Expand All @@ -635,7 +637,7 @@ public Iterator<Mapper> iterator() {
contentTypeMapper,
contentLengthMapper,
languageMapper);
return CollectionUtils.concat(super.iterator(), extras.iterator());
return Iterators.concat(super.iterator(), extras.iterator());
}

@Override
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@

package org.elasticsearch.plugin.mapper.attachments;

import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.mapper.attachment.AttachmentMapper;
import org.elasticsearch.plugins.Plugin;

import java.util.Collection;
import java.util.Collections;

/**
*
*/
public class MapperAttachmentsPlugin extends Plugin {

@Override
Expand All @@ -42,7 +36,7 @@ public String description() {
}

@Override
public Collection<Module> indexModules(Settings indexSettings) {
return Collections.<Module>singletonList(new AttachmentsIndexModule());
public void onIndexService(IndexService indexService) {
indexService.mapperService().documentMapperParser().putTypeParser("attachment", new AttachmentMapper.TypeParser());
}
}
Loading

0 comments on commit 867f496

Please sign in to comment.