|
1 | 1 | package com.google.protobuf.gradle
|
2 | 2 |
|
3 |
| -import com.google.common.collect.ImmutableSet |
4 | 3 | import groovy.transform.CompileDynamic
|
5 | 4 | import org.gradle.api.Project
|
6 | 5 | import org.gradle.testfixtures.ProjectBuilder
|
@@ -339,130 +338,6 @@ class ProtobufJavaPluginTest extends Specification {
|
339 | 338 | gradleVersion << GRADLE_VERSIONS
|
340 | 339 | }
|
341 | 340 |
|
342 |
| - @Unroll |
343 |
| - void "testProject proto and generated output directories should be added to intellij [gradle #gradleVersion]"() { |
344 |
| - given: "project from testProject" |
345 |
| - File projectDir = ProtobufPluginTestHelper.projectBuilder('testIdea') |
346 |
| - .copyDirs('testProjectBase', 'testProject') |
347 |
| - .build() |
348 |
| -
|
349 |
| - when: "idea is invoked" |
350 |
| - BuildResult result = GradleRunner.create() |
351 |
| - .withProjectDir(projectDir) |
352 |
| - .withArguments('idea') |
353 |
| - .withPluginClasspath() |
354 |
| - .withGradleVersion(gradleVersion) |
355 |
| - .build() |
356 |
| -
|
357 |
| - then: "it succeed" |
358 |
| - result.task(":idea").outcome == TaskOutcome.SUCCESS |
359 |
| - Node imlRoot = new XmlParser().parse(projectDir.toPath().resolve("testProject.iml").toFile()) |
360 |
| - Collection rootMgr = imlRoot.component.findAll { it.'@name' == 'NewModuleRootManager' } |
361 |
| - assert rootMgr.size() == 1 |
362 |
| - assert rootMgr.content.sourceFolder.size() == 1 |
363 |
| -
|
364 |
| - Set<String> sourceDir = [] as Set |
365 |
| - Set<String> testSourceDir = [] as Set |
366 |
| - Set<String> generatedDirs = [] as Set |
367 |
| - rootMgr.content.sourceFolder[0].each { |
368 |
| - if (Boolean.parseBoolean(it.@isTestSource)) { |
369 |
| - testSourceDir.add(it.@url) |
370 |
| - } else { |
371 |
| - sourceDir.add(it.@url) |
372 |
| - } |
373 |
| - if (Boolean.parseBoolean(it.@generated)) { |
374 |
| - generatedDirs.add(it.@url) |
375 |
| - } |
376 |
| - } |
377 |
| -
|
378 |
| - Set<String> expectedSourceDir = ImmutableSet.builder() |
379 |
| - .add('file://$MODULE_DIR$/src/main/java') |
380 |
| - .add('file://$MODULE_DIR$/src/grpc/proto') |
381 |
| - .add('file://$MODULE_DIR$/src/main/proto') |
382 |
| - .add('file://$MODULE_DIR$/build/extracted-include-protos/grpc') |
383 |
| - .add('file://$MODULE_DIR$/build/extracted-protos/main') |
384 |
| - .add('file://$MODULE_DIR$/build/extracted-include-protos/main') |
385 |
| - .add('file://$MODULE_DIR$/build/extracted-protos/grpc') |
386 |
| - .add('file://$MODULE_DIR$/build/generated/source/proto/grpc/java') |
387 |
| - .add('file://$MODULE_DIR$/build/generated/source/proto/grpc/grpc_output') |
388 |
| - .add('file://$MODULE_DIR$/build/generated/source/proto/main/java') |
389 |
| - .build() |
390 |
| - Set<String> expectedTestSourceDir = ImmutableSet.builder() |
391 |
| - .add('file://$MODULE_DIR$/src/test/java') |
392 |
| - .add('file://$MODULE_DIR$/src/test/proto') |
393 |
| - .add('file://$MODULE_DIR$/build/extracted-protos/test') |
394 |
| - .add('file://$MODULE_DIR$/build/extracted-include-protos/test') |
395 |
| - .add('file://$MODULE_DIR$/build/generated/source/proto/test/java') |
396 |
| - .build() |
397 |
| - Set<String> expectedGeneratedDirs = [ |
398 |
| - 'file://$MODULE_DIR$/build/extracted-include-protos/grpc', |
399 |
| - 'file://$MODULE_DIR$/build/extracted-protos/main', |
400 |
| - 'file://$MODULE_DIR$/build/extracted-include-protos/main', |
401 |
| - 'file://$MODULE_DIR$/build/extracted-protos/grpc', |
402 |
| - 'file://$MODULE_DIR$/build/generated/source/proto/grpc/java', |
403 |
| - 'file://$MODULE_DIR$/build/generated/source/proto/grpc/grpc_output', |
404 |
| - 'file://$MODULE_DIR$/build/generated/source/proto/main/java', |
405 |
| - 'file://$MODULE_DIR$/build/extracted-protos/test', |
406 |
| - 'file://$MODULE_DIR$/build/extracted-include-protos/test', |
407 |
| - 'file://$MODULE_DIR$/build/generated/source/proto/test/java', |
408 |
| - ] |
409 |
| - assert Objects.equals(expectedSourceDir, sourceDir) |
410 |
| - assert Objects.equals(expectedTestSourceDir, testSourceDir) |
411 |
| - Objects.equals(expectedGeneratedDirs, generatedDirs) |
412 |
| -
|
413 |
| - where: |
414 |
| - gradleVersion << GRADLE_VERSIONS |
415 |
| - } |
416 |
| -
|
417 |
| - @Unroll |
418 |
| - void "testProject proto and generated output directories should be added to Eclipse [gradle #gradleVersion]"() { |
419 |
| - given: "project from testProject" |
420 |
| - File projectDir = ProtobufPluginTestHelper.projectBuilder('testEclipse') |
421 |
| - .copyDirs('testProjectBase', 'testProject') |
422 |
| - .build() |
423 |
| -
|
424 |
| - when: "eclipse is invoked" |
425 |
| - BuildResult result = GradleRunner.create() |
426 |
| - .withProjectDir(projectDir) |
427 |
| - .withArguments('eclipse') |
428 |
| - .withPluginClasspath() |
429 |
| - .withGradleVersion(gradleVersion) |
430 |
| - .build() |
431 |
| -
|
432 |
| - then: "it succeed" |
433 |
| - result.task(":eclipse").outcome == TaskOutcome.SUCCESS |
434 |
| - Node classpathFile = new XmlParser().parse(projectDir.toPath().resolve(".classpath").toFile()) |
435 |
| - Collection srcEntries = classpathFile.classpathentry.findAll {it.'@kind' == 'src'} |
436 |
| - assert srcEntries.size() == 6 |
437 |
| -
|
438 |
| - Set<String> sourceDir = [] as Set |
439 |
| - srcEntries.each { |
440 |
| - String path = it.@path |
441 |
| - sourceDir.add(path) |
442 |
| - if (path.startsWith("build/generated/source/proto")) { |
443 |
| - if (path.contains("test")) { |
444 |
| - // test source path has one more attribute: ["test"="true"] |
445 |
| - assert it.attributes.attribute.size() == 4 |
446 |
| - } else { |
447 |
| - assert it.attributes.attribute.size() == 3 |
448 |
| - } |
449 |
| - } |
450 |
| - } |
451 |
| -
|
452 |
| - Set<String> expectedSourceDir = ImmutableSet.builder() |
453 |
| - .add('src/main/java') |
454 |
| - .add('src/test/java') |
455 |
| - .add('build/generated/source/proto/grpc/java') |
456 |
| - .add('build/generated/source/proto/grpc/grpc_output') |
457 |
| - .add('build/generated/source/proto/main/java') |
458 |
| - .add('build/generated/source/proto/test/java') |
459 |
| - .build() |
460 |
| - assert Objects.equals(expectedSourceDir, sourceDir) |
461 |
| -
|
462 |
| - where: |
463 |
| - gradleVersion << GRADLE_VERSIONS |
464 |
| - } |
465 |
| -
|
466 | 341 | @Unroll
|
467 | 342 | void "test proto generation is not up-to-date on dependency changes [gradle #gradleVersion]"() {
|
468 | 343 | given: "project from testProject"
|
|
0 commit comments