org.gradle.api.tasks.TaskAction Java Examples

The following examples show how to use org.gradle.api.tasks.TaskAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientNativeLink.java    From client-gradle-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@TaskAction
public void action() {
    getProject().getLogger().info("ClientNativeLink action");

    boolean result;
    try {
        SubstrateDispatcher dispatcher = new ConfigBuild(project).createSubstrateDispatcher();
        result = dispatcher.nativeLink();
    } catch (Exception e) {
    	throw new GradleException("Failed to link", e);
    }

    if (!result) {
    	throw new GradleException("Linking failed");
    }
}
 
Example #2
Source File: CheckTask.java    From spring-javaformat with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void checkFormatting() throws IOException, InterruptedException {
	List<File> problems = formatFiles().filter(FileEdit::hasEdits).map(FileEdit::getFile)
			.collect(Collectors.toList());
	this.reportLocation.getParentFile().mkdirs();
	if (!problems.isEmpty()) {
		StringBuilder message = new StringBuilder("Formatting violations found in the following files:\n");
		problems.stream().forEach((f) -> message.append(" * " + getProject().relativePath(f) + "\n"));
		message.append("\nRun `format` to fix.");
		Files.write(this.reportLocation.toPath(), Collections.singletonList(message.toString()),
				StandardOpenOption.CREATE);
		throw new GradleException(message.toString());
	}
	else {
		this.reportLocation.createNewFile();
	}
}
 
Example #3
Source File: GroovyCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
protected void compile() {
    checkGroovyClasspathIsNonEmpty();
    DefaultGroovyJavaJointCompileSpec spec = new DefaultGroovyJavaJointCompileSpec();
    spec.setSource(getSource());
    spec.setDestinationDir(getDestinationDir());
    spec.setClasspath(getClasspath());
    spec.setSourceCompatibility(getSourceCompatibility());
    spec.setTargetCompatibility(getTargetCompatibility());
    spec.setGroovyClasspath(getGroovyClasspath());
    spec.setCompileOptions(compileOptions);
    spec.setGroovyCompileOptions(groovyCompileOptions);
    if (spec.getGroovyCompileOptions().getStubDir() == null) {
        File dir = tempFileProvider.newTemporaryFile("groovy-java-stubs");
        GFileUtils.mkdirs(dir);
        spec.getGroovyCompileOptions().setStubDir(dir);
    }
    WorkResult result = compiler.execute(spec);
    setDidWork(result.getDidWork());
}
 
Example #4
Source File: AbstractReportTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
public void generate() {
    try {
        ReportRenderer renderer = getRenderer();
        File outputFile = getOutputFile();
        if (outputFile != null) {
            renderer.setOutputFile(outputFile);
        } else {
            renderer.setOutput(getServices().get(StyledTextOutputFactory.class).create(getClass()));
        }
        Set<Project> projects = new TreeSet<Project>(getProjects());
        for (Project project : projects) {
            renderer.startProject(project);
            generate(project);
            renderer.completeProject(project);
        }
        renderer.complete();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #5
Source File: GeneratorTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
@TaskAction
void generate() {
    File inputFile = getInputFile();
    if (inputFile != null && inputFile.exists()) {
        try {
            domainObject = generator.read(inputFile);
        } catch (RuntimeException e) {
            throw new GradleException(String.format("Cannot parse file '%s'.\n"
                    + "       Perhaps this file was tinkered with? In that case try delete this file and then retry.",
                    inputFile), e);
        }
    } else {
        domainObject = generator.defaultInstance();
    }
    beforeConfigured.execute(domainObject);
    generator.configure(domainObject);
    afterConfigured.execute(domainObject);

    generator.write(domainObject, getOutputFile());
}
 
Example #6
Source File: PlayRun.java    From playframework with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void run() {
    String deploymentId = getPath();
    DeploymentRegistry deploymentRegistry = getDeploymentRegistry();
    PlayApplicationDeploymentHandle deploymentHandle = deploymentRegistry.get(deploymentId, PlayApplicationDeploymentHandle.class);

    if (deploymentHandle == null) {
        PlayRunSpec spec = new DefaultPlayRunSpec(runtimeClasspath, changingClasspath, applicationJar.getAsFile().get(), assetsJar.getAsFile().get(), assetsDirs, workingDir.get().getAsFile(), getForkOptions(), getHttpPort().get());
        PlayApplicationRunner playApplicationRunner = PlayApplicationRunnerFactory.create(platform.get(), getWorkerProcessFactory(), getClasspathFingerprinter());
        deploymentHandle = deploymentRegistry.start(deploymentId, DeploymentRegistry.ChangeBehavior.BLOCK, PlayApplicationDeploymentHandle.class, spec, playApplicationRunner);

        InetSocketAddress playAppAddress = deploymentHandle.getPlayAppAddress();
        String playUrl = "http://localhost:" + playAppAddress.getPort() + "/";
        LOGGER.warn("Running Play App ({}) at {}", getPath(), playUrl);
    }
}
 
Example #7
Source File: Wrapper.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
void generate() {
    File jarFileDestination = getJarFile();
    File unixScript = getScriptFile();
    FileResolver resolver = getFileLookup().getFileResolver(unixScript.getParentFile());
    String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);

    writeProperties(getPropertiesFile());

    URL jarFileSource = Wrapper.class.getResource("/gradle-wrapper.jar");
    if (jarFileSource == null) {
        throw new GradleException("Cannot locate wrapper JAR resource.");
    }
    GFileUtils.copyURLToFile(jarFileSource, jarFileDestination);

    StartScriptGenerator generator = new StartScriptGenerator();
    generator.setApplicationName("Gradle");
    generator.setMainClassName(GradleWrapperMain.class.getName());
    generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
    generator.setOptsEnvironmentVar("GRADLE_OPTS");
    generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
    generator.setAppNameSystemProperty("org.gradle.appname");
    generator.setScriptRelPath(unixScript.getName());
    generator.generateUnixScript(unixScript);
    generator.generateWindowsScript(getBatchScript());
}
 
Example #8
Source File: VerifyJigEnvironmentTask.java    From jig with Apache License 2.0 6 votes vote down vote up
@TaskAction
void verify() {
    try {
        GraphvizCmdLineEngine graphvizCmdLineEngine = new GraphvizCmdLineEngine();
        GraphvizjView.confirmInstalledGraphviz(graphvizCmdLineEngine);
    } catch(RuntimeException e) {
        Logger logger = getLogger();
        logger.warn("-- JIG ERROR -----------------------------------------------");
        logger.warn("+ 実行可能なGraphvizが見つけられませんでした。");
        logger.warn("+ dotにPATHが通っているか確認してください。");
        logger.warn("+ JIGはダイアグラムの出力にGraphvizを使用しています。");
        logger.warn("+ ");
        logger.warn("+ Graphvizは以下から入手できます。");
        logger.warn("+     https://www.graphviz.org/");
        logger.warn("------------------------------------------------------------");

        throw e;
    }
}
 
Example #9
Source File: QuarkusAddExtension.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void addExtension() {
    Set<String> extensionsSet = getExtensionsToAdd()
            .stream()
            .flatMap(ext -> stream(ext.split(",")))
            .map(String::trim)
            .collect(toSet());

    try {
        new AddExtensions(getQuarkusProject())
                .extensions(extensionsSet)
                .execute();
    } catch (Exception e) {
        throw new GradleException("Failed to add extensions " + getExtensionsToAdd(), e);
    }
}
 
Example #10
Source File: Wrapper.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
void generate() {
    File jarFileDestination = getJarFile();
    File unixScript = getScriptFile();
    FileResolver resolver = getServices().get(FileLookup.class).getFileResolver(unixScript.getParentFile());
    String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);

    writeProperties(getPropertiesFile());

    URL jarFileSource = Wrapper.class.getResource("/gradle-wrapper.jar");
    if (jarFileSource == null) {
        throw new GradleException("Cannot locate wrapper JAR resource.");
    }
    GFileUtils.copyURLToFile(jarFileSource, jarFileDestination);

    StartScriptGenerator generator = new StartScriptGenerator();
    generator.setApplicationName("Gradle");
    generator.setMainClassName(GradleWrapperMain.class.getName());
    generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
    generator.setOptsEnvironmentVar("GRADLE_OPTS");
    generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
    generator.setAppNameSystemProperty("org.gradle.appname");
    generator.setScriptRelPath(unixScript.getName());
    generator.generateUnixScript(unixScript);
    generator.generateWindowsScript(getBatchScript());
}
 
Example #11
Source File: DownloadTask.java    From swaggerhub-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void downloadDefinition() throws GradleException {
    SwaggerHubClient swaggerHubClient = new SwaggerHubClient(host, port, protocol, token);

    LOGGER.info("Downloading from " + host
            + ": api:" + api
            + ", owner:" + owner
            + ", version:" + version
            + ", format:" + format
            + ", outputFile:" + outputFile);

    SwaggerHubRequest swaggerHubRequest = new SwaggerHubRequest.Builder(api, owner, version)
            .format(format)
            .build();

    try {
        String swaggerJson = swaggerHubClient.getDefinition(swaggerHubRequest);
        File file = new File(outputFile);

        setUpOutputDir(file);
        Files.write(Paths.get(outputFile), swaggerJson.getBytes(Charset.forName("UTF-8")));
    } catch (IOException | GradleException e) {
        throw new GradleException(e.getMessage(), e);
    }
}
 
Example #12
Source File: ClientNativePackage.java    From client-gradle-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@TaskAction
public void action() {
    getProject().getLogger().info("ClientNativePackage action");

    boolean result;
    try {
        SubstrateDispatcher dispatcher = new ConfigBuild(project).createSubstrateDispatcher();
        result = dispatcher.nativePackage();
    } catch (Exception e) {
    	throw new GradleException("Failed to package", e);
    }
    
    if (!result) {
        throw new GradleException("Packaging failed");
    }
}
 
Example #13
Source File: GenerateIvyDescriptor.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
public void doGenerate() {
    IvyModuleDescriptorSpecInternal descriptorInternal = toIvyModuleDescriptorInternal(getDescriptor());

    IvyDescriptorFileGenerator ivyGenerator = new IvyDescriptorFileGenerator(descriptorInternal.getProjectIdentity());
    ivyGenerator.setStatus(descriptorInternal.getStatus());
    ivyGenerator.setBranch(descriptorInternal.getBranch());
    ivyGenerator.setExtraInfo(descriptorInternal.getExtraInfo().asMap());

    for (IvyConfiguration ivyConfiguration : descriptorInternal.getConfigurations()) {
        ivyGenerator.addConfiguration(ivyConfiguration);
    }

    for (IvyArtifact ivyArtifact : descriptorInternal.getArtifacts()) {
        ivyGenerator.addArtifact(ivyArtifact);
    }

    for (IvyDependencyInternal ivyDependency : descriptorInternal.getDependencies()) {
        ivyGenerator.addDependency(ivyDependency);
    }

    ivyGenerator.withXml(descriptorInternal.getXmlAction()).writeTo(getDestination());
}
 
Example #14
Source File: GeneratorTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
@TaskAction
void generate() {
    File inputFile = getInputFile();
    if (inputFile != null && inputFile.exists()) {
        try {
            domainObject = generator.read(inputFile);
        } catch (RuntimeException e) {
            throw new GradleException(String.format("Cannot parse file '%s'.\n"
                    + "       Perhaps this file was tinkered with? In that case try delete this file and then retry.",
                    inputFile), e);
        }
    } else {
        domainObject = generator.defaultInstance();
    }
    beforeConfigured.execute(domainObject);
    generator.configure(domainObject);
    afterConfigured.execute(domainObject);

    generator.write(domainObject, getOutputFile());
}
 
Example #15
Source File: GenerateDocsTask.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@TaskAction
public void generateDocs() throws IOException, TemplateException, IntegrationException {
    final Project project = getProject();
    final File file = new File("synopsys-detect-" + project.getVersion() + "-help.json");
    final Reader reader = new FileReader(file);
    final HelpJsonData helpJson = new Gson().fromJson(reader, HelpJsonData.class);

    final File outputDir = project.file("docs/generated");
    final File troubleshootingDir = new File(outputDir, "advanced/troubleshooting");

    FileUtils.deleteDirectory(outputDir);
    troubleshootingDir.mkdirs();

    final TemplateProvider templateProvider = new TemplateProvider(project.file("docs/templates"), project.getVersion().toString());

    createFromFreemarker(templateProvider, troubleshootingDir, "exit-codes", new ExitCodePage(helpJson.getExitCodes()));

    handleDetectors(templateProvider, outputDir, helpJson);
    handleProperties(templateProvider, outputDir, helpJson);
    handleContent(outputDir, templateProvider);
}
 
Example #16
Source File: GenerateIvyDescriptor.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
public void doGenerate() {
    IvyModuleDescriptorInternal descriptorInternal = toIvyModuleDescriptorInternal(getDescriptor());

    IvyDescriptorFileGenerator ivyGenerator = new IvyDescriptorFileGenerator(descriptorInternal.getProjectIdentity());
    ivyGenerator.setStatus(descriptorInternal.getStatus());
    for (IvyConfiguration ivyConfiguration : descriptorInternal.getConfigurations()) {
        ivyGenerator.addConfiguration(ivyConfiguration);
    }

    for (IvyArtifact ivyArtifact : descriptorInternal.getArtifacts()) {
        ivyGenerator.addArtifact(ivyArtifact);
    }

    for (IvyDependencyInternal ivyDependency : descriptorInternal.getDependencies()) {
        ivyGenerator.addDependency(ivyDependency);
    }

    ivyGenerator.withXml(descriptorInternal.getXmlAction()).writeTo(getDestination());
}
 
Example #17
Source File: DesugarTask.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Gradle's entry-point into this task. Determines whether or not it's possible to do this task
 * incrementally and calls either doIncrementalTaskAction() if an incremental build is possible,
 * and doFullTaskAction() if not.
 */
@TaskAction
void taskAction(IncrementalTaskInputs inputs) throws Exception {
    initDesugarJar(getProject().getExtensions().findByType(JFXMobileExtension.class).getAndroidExtension().getBuildCache());

    if (Files.notExists(inputDir.toPath())) {
        PathUtils.deleteIfExists(outputDir.toPath());
    } else {
        processSingle(inputDir.toPath(), outputDir.toPath(), Collections.emptySet());

    }
    waitableExecutor.waitForTasksWithQuickFail(true);

    processNonCachedOnes(getClasspath());
    waitableExecutor.waitForTasksWithQuickFail(true);
}
 
Example #18
Source File: Retrolambda.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@TaskAction
public void action() {
    RetrolambdaExec exec = new RetrolambdaExec(getProject());
    exec.setInputDir(getRetrolambdaInput());
    exec.setOutputDir(getRetrolambdaOutput());

    exec.setBytecodeVersion(50);

    if (getClasspath() == null || getClasspath().isEmpty()) {
        exec.setRetrolambdaClasspath(getProject().files(getRetrolambdaInput()));
    } else {
        exec.setRetrolambdaClasspath(getProject().files(getRetrolambdaInput(), getClasspath()));
    }

    exec.setDefaultMethods(true);

    exec.setJvmArgs(Collections.emptyList());
    exec.exec();
}
 
Example #19
Source File: ScalaCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@TaskAction
protected void compile() {
    checkScalaClasspathIsNonEmpty();
    DefaultScalaJavaJointCompileSpec spec = new DefaultScalaJavaJointCompileSpec();
    spec.setSource(getSource());
    spec.setDestinationDir(getDestinationDir());
    spec.setWorkingDir(getProject().getProjectDir());
    spec.setTempDir(getTemporaryDir());
    spec.setClasspath(getClasspath());
    spec.setScalaClasspath(getScalaClasspath());
    spec.setZincClasspath(getZincClasspath());
    spec.setSourceCompatibility(getSourceCompatibility());
    spec.setTargetCompatibility(getTargetCompatibility());
    spec.setCompileOptions(compileOptions);
    spec.setScalaCompileOptions(scalaCompileOptions);
    if (!scalaCompileOptions.isUseAnt()) {
        configureIncrementalCompilation(spec);
    }

    getCompiler(spec).execute(spec);
}
 
Example #20
Source File: JavaScriptMinify.java    From playframework with Apache License 2.0 6 votes vote down vote up
@TaskAction
void compileJavaScriptSources() {
    StaleClassCleaner cleaner = new SimpleStaleClassCleaner(getOutputs());
    cleaner.addDirToClean(destinationDir.get().getAsFile());
    cleaner.execute();

    MinifyFileVisitor visitor = new MinifyFileVisitor();
    getSource().visit(visitor);

    JavaScriptCompileSpec spec = new DefaultJavaScriptCompileSpec(visitor.relativeFiles, destinationDir.get().getAsFile());

    workerExecutor.submit(JavaScriptMinifyRunnable.class, workerConfiguration -> {
        workerConfiguration.setIsolationMode(IsolationMode.PROCESS);
        workerConfiguration.forkOptions(options -> options.jvmArgs("-XX:MaxMetaspaceSize=256m"));
        workerConfiguration.params(spec);
        workerConfiguration.classpath(compilerClasspath);
        workerConfiguration.setDisplayName("Minifying JavaScript source files");
    });
    workerExecutor.await();
}
 
Example #21
Source File: ValidateStructureTask.java    From scaffold-clean-architecture with MIT License 6 votes vote down vote up
@TaskAction
public void validateStructureTask() throws IOException, CleanException {

    String packageName = FileUtils.readProperties(getProject().getProjectDir().getPath(), "package");
    logger.lifecycle("Clean Architecture plugin version: {}", Utils.getVersionPlugin());
    logger.lifecycle("Project Package: {}", packageName);
    if (!validateModelLayer()) {
        throw new CleanException("the model layer is invalid");
    }
    if (!validateUseCaseLayer()) {
        throw new CleanException("the use case layer is invalid");
    }
    if (!validateEntryPointLayer()) {
        throw new CleanException("the entry point layer is invalid");
    }
    if (!validateDrivenAdapterLayer()) {
        throw new CleanException("the driven adapter layer is invalid");
    }
    logger.lifecycle("The project is valid");

}
 
Example #22
Source File: GenerateWrappersTask.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void generateWrappers() {
  // TODO: Use Gradle worker API to generate wrappers concurrently
  WrapperGenerator generator;
  try {
    generator = (WrapperGenerator) Class.forName(_generatorClass.get()).getConstructor().newInstance();
  } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
    throw new RuntimeException("Could not create object of class: " + _generatorClass.get(), e);
  }
  generator.generateWrappers(
      new WrapperGeneratorContext(getUDFMetadataFile(_inputClassesDirs.get()), _sourcesOutputDir.getAsFile().get(),
          _resourcesOutputDir.getAsFile().get()));
}
 
Example #23
Source File: AbstractJettyRunTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void start() {
    ClassLoader originalClassloader = Server.class.getClassLoader();
    List<File> additionalClasspath = new ArrayList<File>();
    for (File additionalRuntimeJar : getAdditionalRuntimeJars()) {
        additionalClasspath.add(additionalRuntimeJar);
    }
    URLClassLoader jettyClassloader = new URLClassLoader(new DefaultClassPath(additionalClasspath).getAsURLArray(), originalClassloader);
    try {
        Thread.currentThread().setContextClassLoader(jettyClassloader);
        startJetty();
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassloader);
    }
}
 
Example #24
Source File: Compile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!maybeCompileIncrementally(inputs)) {
        compile();
    }
    incrementalCompilation.compilationComplete(compileOptions,
            new ClassDependencyInfoExtractor(getDestinationDir()),
            getDependencyInfoSerializer(), Collections.<JarArchive>emptyList());
}
 
Example #25
Source File: Help.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
void displayHelp() {
    StyledTextOutput output = getServices().get(StyledTextOutputFactory.class).create(Help.class);
    BuildClientMetaData metaData = getServices().get(BuildClientMetaData.class);
    if (taskPath != null) {
        printTaskHelp(output);
    } else {
        printDefaultHelp(output, metaData);
    }
}
 
Example #26
Source File: HtmlDependencyReportTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void generate() {
    if (!reports.getHtml().isEnabled()) {
        setDidWork(false);
        return;
    }

    try {
        HtmlDependencyReporter reporter = new HtmlDependencyReporter(getServices().get(VersionMatcher.class));
        reporter.setOutputDirectory(reports.getHtml().getDestination());
        reporter.generate(getProjects());
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #27
Source File: CoffeeScriptCompile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void doCompile() {
    RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);

    CoffeeScriptCompileSpec spec = new DefaultCoffeeScriptCompileSpec();
    spec.setCoffeeScriptJs(getCoffeeScriptJs().getSingleFile());
    spec.setDestinationDir(getDestinationDir());
    spec.setSource(getSource());
    spec.setOptions(getOptions());

    LogLevel logLevel = getProject().getGradle().getStartParameter().getLogLevel();
    CoffeeScriptCompiler compiler = new RhinoCoffeeScriptCompiler(handleFactory, getRhinoClasspath(), logLevel, getProject().getProjectDir());

    setDidWork(compiler.compile(spec).getDidWork());
}
 
Example #28
Source File: AntlrTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void generate() {
    // Determine the grammar files and the proper ordering amongst them
    XRef xref = new MetadataExtracter().extractMetadata(getSource());
    List<GenerationPlan> generationPlans = new GenerationPlanBuilder(outputDirectory).buildGenerationPlans(xref);

    for (GenerationPlan generationPlan : generationPlans) {
        if (!generationPlan.isOutOfDate()) {
            LOGGER.info("grammar [" + generationPlan.getId() + "] was up-to-date; skipping");
            continue;
        }

        LOGGER.info("performing grammar generation [" + generationPlan.getId() + "]");

        //noinspection ResultOfMethodCallIgnored
        GFileUtils.mkdirs(generationPlan.getGenerationDirectory());

        ANTLR antlr = new ANTLR();
        antlr.setProject(getAnt().getAntProject());
        Path antlrTaskClasspath = antlr.createClasspath();
        for (File dep : getAntlrClasspath()) {
            antlrTaskClasspath.createPathElement().setLocation(dep);
        }
        antlr.setTrace(trace);
        antlr.setTraceLexer(traceLexer);
        antlr.setTraceParser(traceParser);
        antlr.setTraceTreeWalker(traceTreeWalker);
        antlr.setOutputdirectory(generationPlan.getGenerationDirectory());
        antlr.setTarget(generationPlan.getSource());

        antlr.execute();
    }
}
 
Example #29
Source File: GenerateMavenPom.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void doGenerate() {
    MavenPomInternal pomInternal = (MavenPomInternal) getPom();

    MavenPomFileGenerator pomGenerator = new MavenPomFileGenerator(pomInternal.getProjectIdentity());
    pomGenerator.setPackaging(pomInternal.getPackaging());

    for (MavenDependencyInternal runtimeDependency : pomInternal.getRuntimeDependencies()) {
        pomGenerator.addRuntimeDependency(runtimeDependency);
    }

    pomGenerator.withXml(pomInternal.getXmlAction());

    pomGenerator.writeTo(getDestination());
}
 
Example #30
Source File: PublishToMavenRepository.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}