This repository was archived by the owner on Sep 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
main/groovy/com/benjaminsproule/swagger/gradleplugin
test/groovy/com/benjaminsproule/swagger/gradleplugin Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ class GradleSwaggerPlugin implements Plugin<Project> {
4747 }. findAll {
4848 it != null
4949 }
50- generateSwaggerDocsTask. inputFiles = ((createdClassFinder. getClassLoader() as URLClassLoader ). parent as VisitableURLClassLoader ). URLs . collect {
50+ def classLoader = createdClassFinder. getClassLoader() as URLClassLoader
51+ generateSwaggerDocsTask. inputFiles = ((classLoader. getURLs() + (classLoader. parent as VisitableURLClassLoader ). URLs ) as Set ). collect {
5152 new File (it. toURI())
5253 }
5354 }
Original file line number Diff line number Diff line change @@ -260,6 +260,54 @@ class GradleSwaggerPluginITest extends AbstractPluginITest {
260260 newClassFile. delete()
261261 }
262262
263+ def ' Runs task if file in input directory changed' () {
264+ given :
265+ def expectedSwaggerDirectory = " ${ testProjectOutputDir} /swaggerui"
266+ buildFile << """
267+ plugins {
268+ id 'java'
269+ id 'groovy'
270+ id 'com.benjaminsproule.swagger'
271+ }
272+ swagger {
273+ apiSource {
274+ attachSwaggerArtifact = true
275+ locations = ['com.benjaminsproule']
276+ schemes = ['http']
277+ info {
278+ title = 'test'
279+ version = '1'
280+ license { name = 'Apache 2.0' }
281+ contact { name = 'Joe Blogs' }
282+ }
283+ swaggerDirectory = '${ expectedSwaggerDirectory} '
284+ host = 'localhost:8080'
285+ basePath = '/'
286+ securityDefinition {
287+ name = 'MyBasicAuth'
288+ type = 'basic'
289+ }
290+ }
291+ }
292+ """
293+
294+ when :
295+ def newClassFile = new File (' build/classes/groovy/test/com/benjaminsproule/swagger/gradleplugin/NewGradleSwaggerPluginITest.class' )
296+ new File (' build/classes/groovy/test/com/benjaminsproule/swagger/gradleplugin/GradleSwaggerPluginITest.class' ). readLines(). each {
297+ newClassFile. write(it. replace(' GradleSwaggerPluginITest' , ' NewGradleSwaggerPluginITest' ))
298+ }
299+ def firstRunResult = pluginTaskRunnerBuilder(). withArguments(GenerateSwaggerDocsTask . TASK_NAME ). build()
300+ newClassFile. append(" \n " )
301+ def secondRunResult = pluginTaskRunnerBuilder(). withArguments(GenerateSwaggerDocsTask . TASK_NAME ). build()
302+
303+ then :
304+ firstRunResult. task(" :${ GenerateSwaggerDocsTask.TASK_NAME} " ). outcome == SUCCESS
305+ secondRunResult. task(" :${ GenerateSwaggerDocsTask.TASK_NAME} " ). outcome == SUCCESS
306+
307+ cleanup :
308+ newClassFile. delete()
309+ }
310+
263311 def ' Can apply plugin before declaring dependencies' () {
264312 given :
265313 def expectedSwaggerDirectory = " ${ testProjectOutputDir} /swaggerui"
You can’t perform that action at this time.
0 commit comments