From 0cce4366413c3bcb178ca27792648b9fc51cfb5f Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 13 Apr 2016 11:38:23 -0400 Subject: [PATCH] build: fix x-pack pom and allow installation * The found-license project is removed since it is no longer needed * The plugin-api classes have moved into the license-plugin since there is only one plugin * The license/base project publishes the proper artifactId in the pom file * The x-pack jar file is added as an artifact so that it can be installed * The x-pack pom no longer declares the packaging as `zip` * The x-pack pom uses the right artifactId for license-core * Removed disabling of installing the x-plugins artifacts * Cleaned up a use of guava in watcher (found when trying to remove guava as a compile dependency but is needed by the HTML sanitizer) * Removed the dependency on the mustache compiler since it is no longer necessary Closes elastic/elasticsearch#1987 Original commit: elastic/x-pack-elasticsearch@9d3b50b0546aec23953a2216a4cb6986beb1e99f --- build.gradle | 1 - elasticsearch/license/base/build.gradle | 5 ++ elasticsearch/license/found-plugin/.gitignore | 1 - .../license/found-plugin/build.gradle | 19 ------- .../license/plugin/LicenseModule.java | 23 -------- .../license/plugin/LicensePlugin.java | 49 ---------------- .../plugin/core/FoundLicensesService.java | 56 ------------------- elasticsearch/license/plugin-api/.gitignore | 1 - elasticsearch/license/plugin-api/build.gradle | 15 ----- elasticsearch/x-pack/build.gradle | 30 ++++++++-- .../core/AbstractLicenseeComponent.java | 0 .../license/plugin/core/LicenseState.java | 0 .../license/plugin/core/LicenseUtils.java | 0 .../license/plugin/core/Licensee.java | 0 .../license/plugin/core/LicenseeRegistry.java | 0 .../plugin/core/LicensesManagerService.java | 0 .../plugin/core/LicenseUtilsTests.java | 0 .../attachment/EmailAttachmentsParser.java | 4 +- 18 files changed, 33 insertions(+), 171 deletions(-) delete mode 100644 elasticsearch/license/found-plugin/.gitignore delete mode 100644 elasticsearch/license/found-plugin/build.gradle delete mode 100644 elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicenseModule.java delete mode 100644 elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java delete mode 100644 elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/core/FoundLicensesService.java delete mode 100644 elasticsearch/license/plugin-api/.gitignore delete mode 100644 elasticsearch/license/plugin-api/build.gradle rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/LicenseUtils.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/LicenseeRegistry.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/main/java/org/elasticsearch/license/plugin/core/LicensesManagerService.java (100%) rename elasticsearch/{license/plugin-api => x-pack/license-plugin}/src/test/java/org/elasticsearch/license/plugin/core/LicenseUtilsTests.java (100%) diff --git a/build.gradle b/build.gradle index 8259389125a..2b2100cc188 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,6 @@ subprojects { // we must not publish to sonatype until we have set up x-plugins to only publish the parts we want to publish! project.afterEvaluate { if (project.plugins.hasPlugin('com.bmuschko.nexus') && project.nexus.repositoryUrl.startsWith('file://') == false) { - install.enabled = false uploadArchives.enabled = false } } diff --git a/elasticsearch/license/base/build.gradle b/elasticsearch/license/base/build.gradle index 815a4a8e09c..6263d20cd4e 100644 --- a/elasticsearch/license/base/build.gradle +++ b/elasticsearch/license/base/build.gradle @@ -11,3 +11,8 @@ jar { baseName = 'license-core' } +modifyPom { + project { + artifactId 'license-core' + } +} diff --git a/elasticsearch/license/found-plugin/.gitignore b/elasticsearch/license/found-plugin/.gitignore deleted file mode 100644 index ab956abf6f9..00000000000 --- a/elasticsearch/license/found-plugin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/eclipse-build/ diff --git a/elasticsearch/license/found-plugin/build.gradle b/elasticsearch/license/found-plugin/build.gradle deleted file mode 100644 index 577ed689782..00000000000 --- a/elasticsearch/license/found-plugin/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -apply plugin: 'elasticsearch.esplugin' -esplugin { - name 'found-plugin' - description 'Internal Elasticsearch Licensing Plugin for Found' - classname 'org.elasticsearch.license.plugin.LicensePlugin' -} - -dependencies { - compile project(':x-plugins:elasticsearch:license:plugin-api') - testCompile project(':x-plugins:elasticsearch:license:licensor') -} - -// no tests -test.enabled = false -integTest.enabled = false - -dependencyLicenses.enabled = false - -compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked" diff --git a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicenseModule.java b/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicenseModule.java deleted file mode 100644 index 626049a8e53..00000000000 --- a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicenseModule.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.license.plugin; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.license.core.LicenseVerifier; -import org.elasticsearch.license.plugin.core.FoundLicensesService; -import org.elasticsearch.license.plugin.core.LicenseeRegistry; -import org.elasticsearch.license.plugin.core.LicensesManagerService; - -public class LicenseModule extends AbstractModule { - - @Override - protected void configure() { - bind(LicenseVerifier.class).asEagerSingleton(); - bind(LicenseeRegistry.class).to(FoundLicensesService.class); - bind(LicensesManagerService.class).to(FoundLicensesService.class); - } - -} \ No newline at end of file diff --git a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java b/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java deleted file mode 100644 index 82367bfad0a..00000000000 --- a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/LicensePlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.license.plugin; - -import org.elasticsearch.common.component.LifecycleComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.license.plugin.core.FoundLicensesService; -import org.elasticsearch.plugins.Plugin; - -import java.util.ArrayList; -import java.util.Collection; - -public class LicensePlugin extends Plugin { - - public static final String NAME = "license"; - - @Inject - public LicensePlugin(Settings settings) { - } - - @Override - public String name() { - return NAME; - } - - @Override - public String description() { - return "Internal Elasticsearch Licensing Plugin"; - } - - @Override - public Collection> nodeServices() { - Collection> services = new ArrayList<>(); - services.add(FoundLicensesService.class); - return services; - } - - @Override - public Collection nodeModules() { - Collection modules = new ArrayList(); - modules.add(new LicenseModule()); - return modules; - } -} diff --git a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/core/FoundLicensesService.java b/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/core/FoundLicensesService.java deleted file mode 100644 index ff824c5dca2..00000000000 --- a/elasticsearch/license/found-plugin/src/main/java/org/elasticsearch/license/plugin/core/FoundLicensesService.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.license.plugin.core; - -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.Singleton; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.license.core.License; - -import java.util.Collections; -import java.util.List; - -@Singleton -public class FoundLicensesService extends AbstractLifecycleComponent implements LicenseeRegistry, - LicensesManagerService { - - @Inject - public FoundLicensesService(Settings settings) { - super(settings); - } - - /** - * {@inheritDoc} - */ - @Override - public void register(Licensee licensee) { - licensee.onChange(new Licensee.Status(License.OperationMode.PLATINUM, LicenseState.ENABLED)); - } - - @Override - protected void doStart() throws ElasticsearchException { - } - - @Override - protected void doStop() throws ElasticsearchException { - } - - @Override - protected void doClose() throws ElasticsearchException { - } - - @Override - public List licenseesWithState(LicenseState state) { - return Collections.emptyList(); - } - - @Override - public License getLicense() { - return null; - } -} diff --git a/elasticsearch/license/plugin-api/.gitignore b/elasticsearch/license/plugin-api/.gitignore deleted file mode 100644 index ab956abf6f9..00000000000 --- a/elasticsearch/license/plugin-api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/eclipse-build/ diff --git a/elasticsearch/license/plugin-api/build.gradle b/elasticsearch/license/plugin-api/build.gradle deleted file mode 100644 index a93d897db89..00000000000 --- a/elasticsearch/license/plugin-api/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -apply plugin: 'elasticsearch.build' - -dependencies { - compile project(':x-plugins:elasticsearch:license:base') - compile "org.elasticsearch:elasticsearch:${version}" - testCompile project(':x-plugins:elasticsearch:license:licensor') - testCompile "org.elasticsearch.test:framework:${version}" -} - -dependencyLicenses.enabled = false - -jar { - baseName = 'license-plugin-api' -} - diff --git a/elasticsearch/x-pack/build.gradle b/elasticsearch/x-pack/build.gradle index 56a99fec249..970169a404c 100644 --- a/elasticsearch/x-pack/build.gradle +++ b/elasticsearch/x-pack/build.gradle @@ -21,7 +21,7 @@ dependencyLicenses.enabled = false dependencies { // license deps - compile project(':x-plugins:elasticsearch:license:plugin-api') + compile project(':x-plugins:elasticsearch:license:base') testCompile project(':x-plugins:elasticsearch:license:licensor') // shield deps @@ -31,11 +31,9 @@ dependencies { // watcher deps compile 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:r239' - compile 'com.google.guava:guava:16.0.1' // needed by watcher and shield tests for jimfs + compile 'com.google.guava:guava:16.0.1' // needed by watcher for the html sanitizer and shield tests for jimfs compile 'com.google.code.findbugs:jsr305:3.0.1' // TODO: remove this compile 'com.sun.mail:javax.mail:1.5.3' - // fork of mustache: https://github.com/elastic/x-plugins/issues/1116 - compile 'com.github.spullara.mustache.java:compiler:0.9.1' // TODO: remove this testCompile 'org.subethamail:subethasmtp:3.1.7' // common test deps @@ -153,6 +151,8 @@ task testJar(type: Jar) { from sourceSets.test.output } artifacts { + // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions + archives jar testArtifacts testJar } @@ -176,3 +176,25 @@ licenseHeaders.enabled = false forbiddenApisMain { signaturesURLs += [file('signatures.txt').toURI().toURL()] } + +modifyPom { MavenPom pom -> + pom.withXml { XmlProvider xml -> + // first find if we have dependencies at all, and grab the node + NodeList depsNodes = xml.asNode().get('dependencies') + if (depsNodes.isEmpty()) { + return + } + + // find the 'base' dependency and replace it with the correct name because the project name is + // always used even when the pom of the other project is correct + for (Node depNode : depsNodes.get(0).children()) { + String groupId = depNode.get('groupId').get(0).text() + Node artifactIdNode = depNode.get('artifactId').get(0) + String artifactId = artifactIdNode.text() + if (groupId.equals('org.elasticsearch') && artifactId.equals('base')) { + artifactIdNode.replaceNode(new Node(null, 'artifactId', 'license-core')) + return + } + } + } +} \ No newline at end of file diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/AbstractLicenseeComponent.java diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseUtils.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseUtils.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseUtils.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseUtils.java diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseeRegistry.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseeRegistry.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseeRegistry.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicenseeRegistry.java diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicensesManagerService.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesManagerService.java similarity index 100% rename from elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicensesManagerService.java rename to elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesManagerService.java diff --git a/elasticsearch/license/plugin-api/src/test/java/org/elasticsearch/license/plugin/core/LicenseUtilsTests.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/core/LicenseUtilsTests.java similarity index 100% rename from elasticsearch/license/plugin-api/src/test/java/org/elasticsearch/license/plugin/core/LicenseUtilsTests.java rename to elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/core/LicenseUtilsTests.java diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/email/service/attachment/EmailAttachmentsParser.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/email/service/attachment/EmailAttachmentsParser.java index fc795298072..0ac52ce863b 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/email/service/attachment/EmailAttachmentsParser.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/email/service/attachment/EmailAttachmentsParser.java @@ -5,13 +5,13 @@ */ package org.elasticsearch.watcher.actions.email.service.attachment; -import com.google.common.collect.ImmutableMap; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -21,7 +21,7 @@ public class EmailAttachmentsParser { @Inject public EmailAttachmentsParser(Map parsers) { - this.parsers = ImmutableMap.copyOf(parsers); + this.parsers = Collections.unmodifiableMap(parsers); } public EmailAttachments parse(XContentParser parser) throws IOException {