Skip to content

Commit 6598377

Browse files
committed
Add test to reproduce elastic#32985
1 parent e3700a9 commit 6598377

File tree

4 files changed

+81
-8
lines changed

4 files changed

+81
-8
lines changed

buildSrc/src/test/java/org/elasticsearch/gradle/BuildExamplePluginsIT.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,4 @@ private Path writeBuildScript(String script) {
153153
}
154154
}
155155

156-
private String getLocalTestRepoPath() {
157-
String property = System.getProperty("test.local-test-repo-path");
158-
Objects.requireNonNull(property, "test.local-test-repo-path not passed to tests");
159-
File file = new File(property);
160-
assertTrue("Expected " + property + " to exist, but it did not!", file.exists());
161-
return file.getAbsolutePath();
162-
}
163-
164156
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.elasticsearch.gradle.precommit;
2+
3+
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
4+
import org.gradle.testkit.runner.BuildResult;
5+
import org.gradle.testkit.runner.GradleRunner;
6+
import org.gradle.testkit.runner.TaskOutcome;
7+
8+
/*
9+
* Licensed to Elasticsearch under one or more contributor
10+
* license agreements. See the NOTICE file distributed with
11+
* this work for additional information regarding copyright
12+
* ownership. Elasticsearch licenses this file to you under
13+
* the Apache License, Version 2.0 (the "License"); you may
14+
* not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing,
20+
* software distributed under the License is distributed on an
21+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22+
* KIND, either express or implied. See the License for the
23+
* specific language governing permissions and limitations
24+
* under the License.
25+
*/
26+
public class JarHellTaskIT extends GradleIntegrationTestCase {
27+
28+
public void testModuleInfo()
29+
{
30+
BuildResult result = GradleRunner.create()
31+
.withProjectDir(getProjectDir("jarHell"))
32+
.withArguments("clean", "jarHell", "-s", "-Dlocal.repo.path="+getLocalTestRepoPath())
33+
.withPluginClasspath()
34+
.build();
35+
36+
assertEquals(TaskOutcome.SUCCESS, result.task(":jarHell").getOutcome());
37+
}
38+
39+
}

buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
1111
import java.util.List;
12+
import java.util.Objects;
1213
import java.util.stream.Collectors;
1314
import java.util.stream.Stream;
1415

@@ -109,4 +110,12 @@ protected void assertBuildFileDoesNotExists(BuildResult result, String projectNa
109110
Files.exists(absPath)
110111
);
111112
}
113+
114+
protected String getLocalTestRepoPath() {
115+
String property = System.getProperty("test.local-test-repo-path");
116+
Objects.requireNonNull(property, "test.local-test-repo-path not passed to tests");
117+
File file = new File(property);
118+
assertTrue("Expected " + property + " to exist, but it did not!", file.exists());
119+
return file.getAbsolutePath();
120+
}
112121
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plugins {
2+
id 'java'
3+
id 'elasticsearch.build'
4+
}
5+
6+
dependencyLicenses.enabled = false
7+
dependenciesInfo.enabled = false
8+
forbiddenApisMain.enabled = false
9+
forbiddenApisTest.enabled = false
10+
thirdPartyAudit.enabled = false
11+
ext.licenseFile = file("$buildDir/dummy/license")
12+
ext.noticeFile = file("$buildDir/dummy/notice")
13+
14+
repositories {
15+
mavenCentral()
16+
repositories {
17+
maven {
18+
url System.getProperty("local.repo.path")
19+
}
20+
}
21+
}
22+
23+
dependencies {
24+
// Needed for the JarHell task
25+
testCompile ("org.elasticsearch.test:framework:${versions.elasticsearch}") {
26+
exclude group: "org.apache.logging.log4j", module: "log4j-api"
27+
}
28+
// both contain module-info.class
29+
testCompile 'org.apache.logging.log4j:log4j-api:2.10.0'
30+
testCompile 'org.projectlombok:lombok:1.18.2'
31+
}
32+
33+
namingConventions.enabled = false

0 commit comments

Comments
 (0)