Skip to content

Commit

Permalink
Merge branch 'master' into 2019-05-01-prevent-downgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveCTurner committed May 7, 2019
2 parents 374ff83 + a22c046 commit 27c14af
Show file tree
Hide file tree
Showing 311 changed files with 5,833 additions and 2,358 deletions.
3 changes: 3 additions & 0 deletions .ci/init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
settings.pluginManagement {
repositories {
maven {
name "artifactory-gradle-plugins"
url "https://artifactory.elstc.co/artifactory/gradle-plugins"
credentials {
username System.env.ELASTIC_ARTIFACTORY_USERNAME
Expand All @@ -21,6 +22,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
buildscript {
repositories {
maven {
name "artifactory-gradle-release"
url "https://artifactory.elstc.co/artifactory/gradle-release/"
credentials {
username System.env.ELASTIC_ARTIFACTORY_USERNAME
Expand All @@ -31,6 +33,7 @@ if (System.env.ELASTIC_ARTIFACTORY_USERNAME == null || System.env.ELASTIC_ARTIFA
}
repositories {
maven {
name "artifactory-gradle-release"
url "https://artifactory.elstc.co/artifactory/gradle-release/"
credentials {
username System.env.ELASTIC_ARTIFACTORY_USERNAME
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subprojects {
}
repositories {
maven {
name = 'localTest'
name = 'test'
url = "${rootProject.buildDir}/local-test-repo"
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ if (project != rootProject) {
task integTest(type: Test) {
// integration test requires the local testing repo for example plugin builds
dependsOn project.rootProject.allprojects.collect {
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
it.tasks.matching { it.name == 'publishNebulaPublicationToTestRepository'}
}
dependsOn setupLocalDownloads
exclude "**/*Tests.class"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.ResolvedArtifact
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.ArtifactRepository
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.credentials.HttpHeaderCredentials
import org.gradle.api.execution.TaskActionListener
import org.gradle.api.execution.TaskExecutionGraph
Expand Down Expand Up @@ -580,6 +583,16 @@ class BuildPlugin implements Plugin<Project> {

/** Adds repositories used by ES dependencies */
static void configureRepositories(Project project) {
project.getRepositories().all { repository ->
if (repository instanceof MavenArtifactRepository) {
final MavenArtifactRepository maven = (MavenArtifactRepository) repository
assertRepositoryURIUsesHttps(maven, project, maven.getUrl())
repository.getArtifactUrls().each { uri -> assertRepositoryURIUsesHttps(project, uri) }
} else if (repository instanceof IvyArtifactRepository) {
final IvyArtifactRepository ivy = (IvyArtifactRepository) repository
assertRepositoryURIUsesHttps(ivy, project, ivy.getUrl())
}
}
RepositoryHandler repos = project.repositories
if (System.getProperty("repos.mavenLocal") != null) {
// with -Drepos.mavenLocal=true we can force checking the local .m2 repo which is
Expand All @@ -589,6 +602,7 @@ class BuildPlugin implements Plugin<Project> {
}
repos.jcenter()
repos.ivy {
name "elasticsearch"
url "https://artifacts.elastic.co/downloads"
patternLayout {
artifact "elasticsearch/[module]-[revision](-[classifier]).[ext]"
Expand Down Expand Up @@ -617,6 +631,12 @@ class BuildPlugin implements Plugin<Project> {
}
}

private static void assertRepositoryURIUsesHttps(final ArtifactRepository repository, final Project project, final URI uri) {
if (uri != null && uri.toURL().getProtocol().equals("http")) {
throw new GradleException("repository [${repository.name}] on project with path [${project.path}] is using http for artifacts on [${uri.toURL()}]")
}
}

/**
* Returns a closure which can be used with a MavenPom for fixing problems with gradle generated poms.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ class PluginBuildPlugin extends BuildPlugin {

project.tasks.run.dependsOn(project.tasks.bundlePlugin)
if (isModule) {
project.tasks.run.clusterConfig.module(project)
project.tasks.run.clusterConfig.distribution = System.getProperty(
'run.distribution', 'integ-test-zip'
'run.distribution', isXPackModule ? 'default' : 'oss'
)
} else {
project.tasks.run.clusterConfig.plugin(project.path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ class ClusterFormationTasks {
}
doLast {
project.delete(node.pidFile)
// Large tests can exhaust disk space, clean up jdk from the distribution to save some space
project.delete(new File(node.homeDir, "jdk"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class VagrantTestPlugin implements Plugin<Project> {
which should work for 5.0.0+. This isn't a real ivy repository but gradle
is fine with that */
repos.ivy {
name "elasticsearch"
artifactPattern "https://artifacts.elastic.co/downloads/elasticsearch/[module]-[revision].[ext]"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@

public enum Distribution {

INTEG_TEST("elasticsearch", "integ-test-zip"),
DEFAULT("elasticsearch", "elasticsearch"),
OSS("elasticsearch-oss", "elasticsearch-oss");
INTEG_TEST("elasticsearch"),
DEFAULT("elasticsearch"),
OSS("elasticsearch-oss");

private final String artifactName;
private final String group;

Distribution(String name, String group) {
Distribution(String name) {
this.artifactName = name;
this.group = group;
}

public String getArtifactName() {
return artifactName;
}

public String getGroup() {
return "org.elasticsearch.distribution." + group;
if (this.equals(INTEG_TEST)) {
return "org.elasticsearch.distribution.integ-test-zip";
} else {
return "org.elasticsearch.distribution." + name().toLowerCase();
}
}

public String getFileExtension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ public boolean isProcessAlive() {
}

void eachVersionedDistribution(BiConsumer<String, Distribution> consumer) {
nodes.forEach(each -> consumer.accept(each.getVersion(), each.getDistribution()));
nodes.forEach(each -> {
consumer.accept(each.getVersion(), each.getDistribution());
});
}

public ElasticsearchNode singleNode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public synchronized void start() {

Path distroArtifact = artifactsExtractDir
.resolve(distribution.getGroup())
.resolve(distribution.getArtifactName() + "-" + getVersion());
.resolve("elasticsearch-" + getVersion());

if (Files.exists(distroArtifact) == false) {
throw new TestClustersException("Can not start " + this + ", missing: " + distroArtifact);
Expand Down
Loading

0 comments on commit 27c14af

Please sign in to comment.