-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves issue 395. Declared exceptions are part of the ABI.
- Loading branch information
1 parent
963c309
commit d654b71
Showing
5 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/functionalTest/groovy/com/autonomousapps/jvm/AbiExceptionsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.autonomousapps.jvm | ||
|
||
import com.autonomousapps.jvm.projects.AbiExceptionsProject | ||
|
||
import static com.autonomousapps.utils.Runner.build | ||
import static com.google.common.truth.Truth.assertThat | ||
|
||
final class AbiExceptionsSpec extends AbstractJvmSpec { | ||
|
||
def "declared exceptions are part of the abi (#gradleVersion)"() { | ||
given: | ||
def project = new AbiExceptionsProject() | ||
gradleProject = project.gradleProject | ||
when: | ||
build(gradleVersion, gradleProject.rootDir, ':buildHealth') | ||
then: | ||
assertThat(project.actualBuildHealth()).containsExactlyElementsIn(project.expectedBuildHealth) | ||
where: | ||
gradleVersion << gradleVersions() | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/functionalTest/groovy/com/autonomousapps/jvm/projects/AbiExceptionsProject.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.autonomousapps.jvm.projects | ||
|
||
import com.autonomousapps.AbstractProject | ||
import com.autonomousapps.advice.ComprehensiveAdvice | ||
import com.autonomousapps.kit.GradleProject | ||
import com.autonomousapps.kit.Plugin | ||
import com.autonomousapps.kit.Source | ||
import com.autonomousapps.kit.SourceType | ||
|
||
import static com.autonomousapps.AdviceHelper.actualBuildHealth | ||
import static com.autonomousapps.AdviceHelper.emptyBuildHealthFor | ||
import static com.autonomousapps.kit.Dependency.project | ||
|
||
final class AbiExceptionsProject extends AbstractProject { | ||
|
||
final GradleProject gradleProject | ||
|
||
AbiExceptionsProject() { | ||
this.gradleProject = build() | ||
} | ||
|
||
private GradleProject build() { | ||
def builder = newGradleProjectBuilder() | ||
builder.withSubproject('proj') { s -> | ||
s.sources = libSources | ||
s.withBuildScript { bs -> | ||
bs.plugins = [Plugin.javaLibraryPlugin] | ||
bs.dependencies = [project('api', ':exceptions')] | ||
} | ||
} | ||
builder.withSubproject('exceptions') { s -> | ||
s.sources = exceptionsSources | ||
s.withBuildScript { bs -> | ||
bs.plugins = [Plugin.javaLibraryPlugin] | ||
} | ||
} | ||
|
||
def project = builder.build() | ||
project.writer().write() | ||
return project | ||
} | ||
|
||
private libSources = [ | ||
new Source( | ||
SourceType.JAVA, "Sup", "com/example", | ||
"""\ | ||
package com.example; | ||
public interface Sup {} | ||
""".stripIndent() | ||
), | ||
new Source( | ||
SourceType.JAVA, "Main", "com/example", | ||
"""\ | ||
package com.example; | ||
import com.example.exception.FancyException; | ||
public class Main implements Sup { | ||
public String magic() throws FancyException { | ||
return "42"; | ||
} | ||
} | ||
""".stripIndent() | ||
) | ||
] | ||
|
||
private exceptionsSources = [ | ||
new Source( | ||
SourceType.JAVA, "FancyException", "com/example/exception", | ||
"""\ | ||
package com.example.exception; | ||
public class FancyException extends RuntimeException {} | ||
""".stripIndent() | ||
) | ||
] | ||
|
||
List<ComprehensiveAdvice> actualBuildHealth() { | ||
return actualBuildHealth(gradleProject) | ||
} | ||
|
||
final List<ComprehensiveAdvice> expectedBuildHealth = emptyBuildHealthFor( | ||
':proj', ':exceptions', ':' | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters