All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codearte.accurest.plugin.GenerateServerTestsTask.groovy Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package io.codearte.accurest.plugin

import io.codearte.accurest.AccurestException
import io.codearte.accurest.TestGenerator
import io.codearte.accurest.config.AccurestConfigProperties
import org.gradle.api.GradleException
import org.gradle.api.internal.ConventionTask
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

class GenerateServerTestsTask extends ConventionTask {

	@InputDirectory
	File contractsDslDir
	@OutputDirectory
	File generatedTestSourcesDir

	//TODO: How to deal with @Input*, @Output* and that domain object?
	AccurestConfigProperties configProperties

	@TaskAction
	void generate() {
		project.logger.info("Accurest Plugin: Invoking test sources generation")

		project.sourceSets.test.groovy {
			project.logger.info("Registering ${getConfigProperties().generatedTestSourcesDir} as test source directory")
			srcDir getConfigProperties().generatedTestSourcesDir
		}

		try {
			//TODO: What with that? How to pass?
			TestGenerator generator = new TestGenerator(getConfigProperties())
			int generatedClasses = generator.generate()
			project.logger.info("Generated {} test classes", generatedClasses)
		} catch (AccurestException e) {
			throw new GradleException("Accurest Plugin exception: ${e.message}", e)
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy