Java 类org.apache.maven.plugin.MojoFailureException 实例源码

项目:living-documentation    文件:PublishMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    extractTemplatesFromJar();
    try {
        PublishProvider provider;
        switch (publish.getProvider()) {
            default:
                provider = new ConfluenceProvider(publish.getEndpoint(), publish.getUsername(), publish.getPassword());
        }

        List<Page> pages = readHtmlPages();
        publish(provider, pages);
    } catch (Exception e) {
        throw new MojoExecutionException("Unexpected error", e);
    }
}
项目:wavemaker-app-build-tools    文件:AppBuildMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    initializeHandlers();

    for (AppBuildHandler appBuildHandler : appBuildHandlers) {
        appBuildHandler.handle();
    }

    final Build build = project.getBuild();
    final List<String> nonFilteredFileExtensions = getNonFilteredFileExtensions(build.getPlugins());


    MavenResourcesExecution mavenResourcesExecution =
            new MavenResourcesExecution(build.getResources(), new File(outputDirectory), project,
                    ENCODING, build.getFilters(), nonFilteredFileExtensions, session);

    try {
        mavenResourcesFiltering.filterResources(mavenResourcesExecution);
    } catch (MavenFilteringException e) {
        throw new WMRuntimeException("Failed to execute resource filtering ", e);
    }
}
项目:wavemaker-app-build-tools    文件:AppBuildMojo.java   
private void initializeHandlers() throws MojoFailureException {
    if (appBuildHandlers == null) {
        appBuildHandlers = new ArrayList<AppBuildHandler>();
        Folder rootFolder = new LocalFolder(baseDirectory);

        Folder pagesFolder = rootFolder.getFolder(pagesDirectory);
        if (pagesFolder.exists()) {
            appBuildHandlers.add(new PageMinFileGenerationHandler(pagesFolder));
        }


        Folder servicesFolder = rootFolder.getFolder(servicesDirectory);
        if (servicesFolder.exists()) {
            URL[] runtimeClasspathElements = getRuntimeClasspathElements();
            appBuildHandlers.add(new SwaggerDocGenerationHandler(servicesFolder, runtimeClasspathElements));
            appBuildHandlers.add(new VariableServiceDefGenerationHandler(rootFolder));
        }
    }
}
项目:wavemaker-app-build-tools    文件:AppBuildMojo.java   
private URL[] getRuntimeClasspathElements() throws MojoFailureException {
    URL[] runtimeUrls = null;
    try {
        List<String> compileClasspathElements = project.getCompileClasspathElements();
        List<String> runtimeClasspathElements = project.getRuntimeClasspathElements();
        Set<String> allClassPathElements = new LinkedHashSet<>(compileClasspathElements.size());
        allClassPathElements.addAll(compileClasspathElements);
        allClassPathElements.addAll(runtimeClasspathElements);
        runtimeUrls = new URL[allClassPathElements.size()];
        int index=0;
        for (String s: allClassPathElements ) {
            runtimeUrls[index++] = new File(s).toURI().toURL();
        }
    } catch (Exception exception) {
        throw new MojoFailureException("Failed resolve project dependencies", exception);
    }

    return runtimeUrls;
}
项目:neoscada    文件:UpdateMojo.java   
@Override
public void execute () throws MojoExecutionException, MojoFailureException
{
    getLog ().debug ( "START HERE" );

    try
    {
        final Document doc = XmlHelper.parse ( this.sourceFile );
        updateFile ( doc );
        XmlHelper.write ( doc, this.targetFile );
    }
    catch ( final Exception e )
    {
        throw new MojoExecutionException ( "Failed to update version", e );
    }
}
项目:Lahiya    文件:LahiyaTestCaseReport.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
    logger.info("package name {}",packageName);

    logger.info("suites name {}",suites);

    try
    {
        generateReport(packageName, suites);
    }
    catch (IOException e)
    {
        getLog().error("sorry, report cannot created");
    }
}
项目:syndesis    文件:GenerateMapperInspectionsMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {

        final Resource resource = new Resource();
        resource.setDirectory(outputDir.getCanonicalPath());
        project.addResource(resource);

        final Set<File> generated = new HashSet<>();

        final ReadApiClientData reader = new ReadApiClientData();
        final List<ModelData<?>> modelList = reader.readDataFromFile("io/syndesis/dao/deployment.json");
        for (final ModelData<?> model : modelList) {
            if (model.getKind() == Kind.Connector) {
                final Connector connector = (Connector) model.getData();

                for (final ConnectorAction action : connector.getActions()) {
                    process(generated, connector, action, action.getInputDataShape());
                    process(generated, connector, action, action.getOutputDataShape());
                }
            }
        }
    } catch (final IOException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
}
项目:git-checkout-plugin    文件:GitCheckoutMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        outputDirectory.mkdirs();
        if (Files.exists(outputDirectory.toPath().resolve(".git"))) {
            throw new MojoExecutionException("Cannot execute mojo in a directory that already contains a .git directory");
        }
        executeCommand(outputDirectory, "git", "init");
        executeCommand(outputDirectory, "git", "remote", "add", "origin", repository);
        executeCommand(outputDirectory, "git", "config", "core.sparseCheckout", "true");
        Path sparseCheckoutFile = outputDirectory.toPath().resolve(".git/info/sparse-checkout");
        Files.write(sparseCheckoutFile, paths);
        executeCommand(outputDirectory, "git", "pull", "origin", branch);
        executeCommand(outputDirectory, "rm", "-rf", ".git");
        getLog().info("Files were checked out in: " + outputDirectory);
    } catch (IOException e) {
        throw new MojoFailureException("Caught IOException in mojo", e);
    }
}
项目:azure-maven-plugins    文件:AddMojo.java   
protected Map<String, String> prepareRequiredParameters(final FunctionTemplate template)
        throws MojoFailureException {
    info("");
    info(PREPARE_PARAMS);

    prepareFunctionName();

    preparePackageName();

    final Map<String, String> params = new HashMap<>();
    params.put("functionName", getFunctionName());
    params.put("className", getClassName());
    params.put("packageName", getFunctionPackageName());

    prepareTemplateParameters(template, params);

    displayParameters(params);

    return params;
}
项目:azure-maven-plugins    文件:AddMojo.java   
protected void prepareFunctionName() throws MojoFailureException {
    info("Common parameter [Function Name]: name for both the new function and Java class");

    if (settings != null && !settings.isInteractiveMode()) {
        assureInputInBatchMode(getFunctionName(),
                str -> isNotEmpty(str) && str.matches(FUNCTION_NAME_REGEXP),
                this::setFunctionName,
                true);
    } else {
        assureInputFromUser("Enter value for Function Name: ",
                getFunctionName(),
                str -> isNotEmpty(str) && str.matches(FUNCTION_NAME_REGEXP),
                "Function name must start with a letter and can contain letters, digits, '_' and '-'",
                this::setFunctionName);
    }
}
项目:azure-maven-plugins    文件:AddMojo.java   
protected void preparePackageName() throws MojoFailureException {
    info("Common parameter [Package Name]: package name of the new Java class");

    if (settings != null && !settings.isInteractiveMode()) {
        assureInputInBatchMode(getFunctionPackageName(),
                str -> isNotEmpty(str) && isName(str),
                this::setFunctionPackageName,
                true);
    } else {
        assureInputFromUser("Enter value for Package Name: ",
                getFunctionPackageName(),
                str -> isNotEmpty(str) && isName(str),
                "Input should be a valid Java package name.",
                this::setFunctionPackageName);
    }
}
项目:azure-maven-plugins    文件:AddMojo.java   
protected void assureInputInBatchMode(final String input, final Function<String, Boolean> validator,
                                      final Consumer<String> setter, final boolean required)
        throws MojoFailureException {
    if (validator.apply(input)) {
        info(FOUND_VALID_VALUE);
        setter.accept(input);
        return;
    }

    if (required) {
        throw new MojoFailureException(String.format("invalid input: %s", input));
    } else {
        out.printf("The input is invalid. Use empty string.%n");
        setter.accept("");
    }
}
项目:carnotzet    文件:PullMojo.java   
@Override
public void executeInternal() throws MojoExecutionException, MojoFailureException {
    PullPolicy policy = null;
    if (imagePullPolicy == null) {
        policy = PullPolicy.ALWAYS;
    } else {
        switch (imagePullPolicy) {
            case "always":
                policy = PullPolicy.ALWAYS;
                break;
            case "ifNotPresent":
                policy = PullPolicy.IF_LOCAL_IMAGE_ABSENT;
                break;
            case "ifNewer":
                policy = PullPolicy.IF_REGISTRY_IMAGE_NEWER;
                break;
            default:
                throw new MojoExecutionException("Unknown image pull policy : " + imagePullPolicy);
        }
    }

    getLog().info("Pulling images with policy : " + imagePullPolicy);
    getRuntime().pull(policy);
}
项目:carnotzet    文件:Welcome.java   
public static void execute(ContainerOrchestrationRuntime runtime, Carnotzet carnotzet, Log log)
        throws MojoExecutionException, MojoFailureException {
    try {
        IpPlaceholderResolver ipPlaceholderResolver = new IpPlaceholderResolver(runtime);

        WelcomePageGenerator generator = new WelcomePageGenerator(Arrays.asList(ipPlaceholderResolver));

        Path moduleResources = carnotzet.getResourcesFolder().resolve("expanded-jars");
        Path welcomePagePath = carnotzet.getResourcesFolder().resolve("welcome.html");

        generator.buildWelcomeHtmlFile(moduleResources, welcomePagePath);

        new ProcessBuilder("xdg-open", "file://" + welcomePagePath).start();
        log.info("********************************************************");
        log.info("*                                                      *");
        log.info("* The WELCOME page was opened in your default browser  *");
        log.info("*                                                      *");
        log.info("********************************************************");
    }
    catch (IOException e) {
        throw new MojoExecutionException("Cannot start browser:" + e, e);
    }
}
项目:carnotzet    文件:Run.java   
public static void execute(ContainerOrchestrationRuntime runtime, Carnotzet carnotzet, String service) throws MojoExecutionException,
        MojoFailureException {
    if (service == null) {
        runtime.start();
    } else {
        runtime.start(service);
    }
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        if (service == null) {
            if (runtime.isRunning()) {
                runtime.stop();
            }
        } else {
            if (runtime.getContainer(service).isRunning()) {
                runtime.stop(service);
            }
        }
    }));
    LogListener printer = new StdOutLogPrinter(Utils.getServiceNames(carnotzet), null, true);
    if (service != null) {
        printer.setEventFilter(event -> event.getService().equals(service));
    }
    runtime.registerLogListener(printer);

    Utils.waitForUserInterrupt();
}
项目:spring2ts    文件:Spring2TsMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    SourceGen generator = new SourceGen(sourceDir, outputDir);
    try {
        Map<String, OutputType> result = generator.run();
        int size = result.size();
        if(size > 0) {
            String types = result.values().stream().map(OutputType::getName).collect(Collectors.joining(", "));
            String msg = String.format("Generated %d types in %s: %s", size, outputDir.getCanonicalPath(), types);
            getLog().info(msg);
        } else {
            getLog().info("No types generated");
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Failed to generate TypeScript source", e);
    }
}
项目:OperatieBRP    文件:AbstractGenerateMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    // Create test context
    try (final GenericXmlApplicationContext generateContext = new GenericXmlApplicationContext()) {
        generateContext.load("classpath:generate-context.xml");
        generateContext.refresh();

        final DataSource dataSource = generateContext.getBean(DataSource.class);
        final Generator generator = new Generator(getLog(), this::processRecord);

        getLog().info("Loading templates from: " + source.getAbsolutePath());
        getLog().info("Package: " + packageName);
        for (final File file : source.listFiles(this::acceptAllFiles)) {
            generator.generate(dataSource, file, destination, packageName);
        }
    }
}
项目:OperatieBRP    文件:TimestampMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (artifact.endsWith("jar") || artifact.endsWith("war")) {
        getLog().debug("Setting fixed timestamp for " + artifact);
        try {
            final Path tmpFolderPath = createTmpFolderPath();
            if (tmpFolderPath.toFile().exists()) {
                deleteTmpFolder(tmpFolderPath);
            }
            final Path tmpFolder = Files.createDirectory(tmpFolderPath);
            backupArtifact();
            Set<String> keys = pakArchiefBestandUit(tmpFolder);
            pakArchiefBestandOpnieuwIn(tmpFolder, keys);
            Files.deleteIfExists(FileSystems.getDefault().getPath(artifact + ".bak"));
            deleteTmpFolder(tmpFolder);
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot create temp folder", e);
        }
    } else {
        getLog().debug("Artifact is not a jar or war file");
    }
}
项目:lambda-monitoring    文件:RemoveMetricFiltersMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    MetricFilterPublisher publisher =
            dryRun ? new DryRunMetricFilterPublisher(getLog()) : new CloudwatchMetricFilterPublisher(getLog());

    // Get a map of fully-namespaced metric names mapped to the metric fields in classes that extend LambdaMetricSet
    Map<String, Field> metricFields = new HashMap<>();
    try {
        metricFields.putAll(new MetricsFinder(project).find());
    } catch (DependencyResolutionRequiredException | MalformedURLException e) {
        throw new MojoExecutionException("Could not scan classpath for metric fields", e);
    }

    if (!metricFields.isEmpty()) {
        getLog().info(String.format("Found [%d] metric fields in classpath.", metricFields.size()));

        int removed = publisher.removeMetricFilters(getMetricFilters(metricFields));
        getLog().info(String.format("Removed [%d] metric filters.", removed));
    } else {
        getLog().warn("Did not find any metric fields in classpath.");
    }

}
项目:camunda-bpm-swagger    文件:SpoonProcessingMojo.java   
@Override
@SneakyThrows
public void execute() throws MojoExecutionException, MojoFailureException {
  Context.builder()
  .executionEnvironment(executionEnvironment(project, session, buildPluginManager))
  .camundaVersion(camundaVersion)
  .unpackDirectory(unpackDirectory)
  .outputDirectory(outputDirectory)
  .noClasspath(false)
  .autoImports(false)
  .shouldCompile(false)
  .dtoYamlFile(dtoYamlFile)
  .serviceYamlFile(serviceYamlFile)
  .build()
  .initDirectory()
  .downloadSources()
  .loadDtoDocumentation()
  .loadServiceDocumentation()
  .processSources()
  ;
}
项目:hashsdn-controller    文件:DeleteSources.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (directory == null || !directory.exists()) {
        super.getLog().error("Directory does not exists.");
    }
    File sourceDirectory = new File(directory.getPath() + Util.replaceDots(".org.opendaylight.controller.config.yang.test.impl"));
    if (sourceDirectory == null || !sourceDirectory.exists()) {
        super.getLog().error(String.format("Source directory does not exists %s", sourceDirectory.getPath()));
    }
    File[] sourceFiles = sourceDirectory.listFiles();
    for (File sourceFile: sourceFiles) {
        if(sourceFile.getName().endsWith("Module.java") || sourceFile.getName().endsWith("ModuleFactory.java")) {
            super.getLog().debug(String.format("Source file deleted: %s", sourceFile.getName()));
            sourceFile.delete();
        }
    }
}
项目:solr-runner-maven-plugin    文件:AbstractSolrMojo.java   
protected void setUpSolr() throws MojoFailureException {
    if (!isSOLRFolderExisting()) {
        if (!isSOLRZipExisting()) {
            getLog().debug("Download solr-zip because it does not exists!");
            downloadZip();
        }
        extractSOLRZip();
    }
}
项目:solr-runner-maven-plugin    文件:AbstractSolrMojo.java   
protected SOLRRunner buildRunner() throws MojoFailureException {
    SOLRRunner solrRunner = new SOLRRunner(getSOLRExecutablePath());

    solrRunner.setForeground(false);
    solrRunner.setSolrHome(this.getSOLRHome().toString());
    solrRunner.setPort(this.solrPort);
    return solrRunner;
}
项目:solr-runner-maven-plugin    文件:AbstractSolrMojo.java   
private Path getSOLRExecutablePath() throws MojoFailureException {
    Path solr = getSOLRPath().resolve("bin/");

    if(System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")){
        solr = solr.resolve("solr.cmd");
    } else {
        solr = solr.resolve("solr");
    }

    return solr;
}
项目:solr-runner-maven-plugin    文件:AbstractSolrMojo.java   
private Path getLocalRepoPath() throws MojoFailureException {
    try {
        return Paths.get(new URL(localRepository.getUrl()).toURI());
    } catch (MalformedURLException | URISyntaxException e) {
        throw new MojoFailureException("Could not resolve path to local .m2", e);
    }
}
项目:solr-runner-maven-plugin    文件:StartSOLRMojo.java   
public void execute() throws MojoExecutionException, MojoFailureException {
    setUpSolr();
    try {
        SOLRRunner runner = buildRunner();
        if (runner.start() != 0) {
            throw new MojoExecutionException("Solr command did not return 0. See Log for errors.");
        }
    } catch (IOException | InterruptedException e) {
        throw new MojoFailureException("Error while starting SOLR!", e);
    }
}
项目:solr-runner-maven-plugin    文件:StopSOLRMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    setUpSolr();
    try {
        SOLRRunner runner = buildRunner();
        if (runner.stop() != 0) {
            throw new MojoExecutionException("Solr command did not return 0. See Log for errors.");
        }
    } catch (IOException | InterruptedException e) {
        throw new MojoFailureException("Error while stopping SOLR!", e);
    }
}
项目:greycat    文件:GeneratorPlugin.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    Generator generator = new Generator();
    try {
        generator.parse(input);
    } catch (Exception e) {
        e.printStackTrace();
        throw new MojoExecutionException("Error during GCM parse stage", e);
    }

    final String[] gcVersion = {""};
    project.getPluginArtifacts().forEach(artifact -> {
        if (artifact.getGroupId().equals("com.datathings") && artifact.getArtifactId().equals("greycat-mavenplugin")) {
            gcVersion[0] = artifact.getVersion();
        }
    });
    final List<File> cps = new ArrayList<File>();
    if (project != null) {
        for (Artifact a : project.getArtifacts()) {
            File file = a.getFile();
            if (file != null) {
                if (file.isFile()) {
                    cps.add(file);
                }
            }
        }
    }
    generator.generate(packageName, pluginName, targetGen, targetGenJS, generateJava, generateJS, gcVersion[0], project.getVersion(), cps);
    project.addCompileSourceRoot(targetGen.getAbsolutePath());
}
项目:qpp-conversion-tool    文件:ErrorCodeDocumentationGenerator.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        getLog().info( "Running Error Code documentation plugin" );
        ErrorCodeDocumentationGenerator.main();
    } catch (IOException | TransformerConfigurationException e) {
        throw new MojoExecutionException("Error code documentation problems", e);
    }
}
项目:maven-cdn-alioss-plugin    文件:OssMojo.java   
public void execute() throws MojoExecutionException, MojoFailureException {
    if (!StrUtils.notBlank(endpoint)) {
        throw new MojoExecutionException("endpoint can not be null");
    }

    if (!StrUtils.notBlank(accessKeyId)) {
        throw new MojoExecutionException("accessKeyId can not be null");
    }

    if (!StrUtils.notBlank(accessKeySecret)) {
        throw new MojoExecutionException("accessKeySecret can not be null");
    }

    if (!StrUtils.notBlank(bucketName)) {
        throw new MojoExecutionException("bucketName can not be null");
    }

    AliyunOssUtills.init(endpoint, accessKeyId, accessKeySecret, bucketName, supportCname);
    String[] upFiles = listSelectedFiles();
    if (null != upFiles && upFiles.length > 0) {
        getLog().info("files upload to aliyun oss begin");
        for (String upFile : upFiles) {
            File file = new File(getBasePath() + "/" + upFile);
            if (file.exists()) {
                doUpload(file);
            } else {
                warn("upload file not exists: %s", file.getName());
            }
        }
        getLog().info(upFiles.length + " files upload to aliyun oss finished");
    } else {
        getLog().warn("no files to upload");
    }
}
项目:maven-cdn-alioss-plugin    文件:MyAbstractMojo.java   
protected final String[] listSelectedFiles() throws MojoFailureException {
    Selection selection = new Selection(getBaseDir(), includes, buildExcludes(), true);
    debug("From: %s", getBaseDir());
    debug("Including: %s", deepToString(selection.getIncluded()));
    debug("Excluding: %s", deepToString(selection.getExcluded()));
    return selection.getSelectedFiles();
}
项目:tscfg-docgen    文件:GenerateDocsMojo.java   
public void execute() throws MojoExecutionException, MojoFailureException {
  try {
    generateDocs(readInputFiles());
  } catch (Exception e) {
    throw new MojoFailureException("Failed to generate configuration docs", e);
  }
}
项目:neoscada    文件:VersionPropertyMojo.java   
@Override
public synchronized void execute () throws MojoExecutionException, MojoFailureException
{
    if ( !this.project.getProperties ().containsKey ( UNQUALIFIED_VERSION_PROPERTY ) )
    {
        final String result = makeVersion ( this.project.getVersion () );
        getLog ().debug ( "Setting unqualified version to: " + result );
        if ( result != null )
        {
            this.project.getProperties ().put ( UNQUALIFIED_VERSION_PROPERTY, result );
        }
    }
}
项目:neoscada    文件:MergeMojo.java   
@Override
public void execute () throws MojoExecutionException, MojoFailureException
{
    if ( this.sourceFiles == null || this.sourceFiles.isEmpty () )
    {
        throw new MojoFailureException ( "'sourceFiles' must not be empty!" );
    }

    try
    {
        Document doc = null;

        for ( final File file : this.sourceFiles )
        {
            if ( doc == null )
            {
                doc = XmlHelper.parse ( file );
            }
            else
            {
                doc = merge ( doc, XmlHelper.parse ( file ) );
            }
        }

        updateInformation ( doc );

        XmlHelper.write ( doc, this.targetFile );
    }
    catch ( final Exception e )
    {
        throw new MojoExecutionException ( "Failed to merge target files", e );
    }
}
项目:neoscada    文件:SetVersionMojo.java   
private void parseProvidedVersions () throws MojoFailureException
{
    for ( final String v : this.providedVersions )
    {
        final String toks[] = v.split ( ":" );
        if ( toks.length != 3 )
        {
            throw new MojoFailureException ( this.providedVersions, "Wrong provided version syntax", "The syntax of the provided versions is <groupId>:<artifactId>:<version>. Multiple entries must be comma seperated." );
        }
        getLog ().info ( String.format ( "Recording provided version - %s:%s -> %s", toks[0], toks[1], toks[2] ) );
        this.versions.put ( new PomId ( toks[0], toks[1] ), toks[2] );
    }
}
项目:spring-data-generator    文件:SDManagerMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    SDLogger.configure(getLog());

    this.validateField(Constants.ENTITY_PACKAGE);
    this.validateField(Constants.MAGANER_PACKAGE);
    this.validateField(Constants.REPOSITORY_PACKAGE);

    try {
        CustomResourceLoader resourceLoader = new CustomResourceLoader(project);
        resourceLoader = new CustomResourceLoader(project);
        resourceLoader.setPostfix(managerPostfix);
        resourceLoader.setRepositoryPackage(repositoryPackage);
        resourceLoader.setRepositoryPostfix(repositoryPostfix);
        resourceLoader.setOverwrite(overwrite);

        String absolutePath = GeneratorUtils.getAbsolutePath(managerPackage);
        if (absolutePath == null){
            SDLogger.addError("Could not define the absolute path of the managers");
            throw new SDMojoException();
        }

        ScanningConfigurationSupport scanningConfigurationSupport = new ScanningConfigurationSupport(entityPackage, onlyAnnotations);

        ManagerTemplateSupport managerTemplateSupport = new ManagerTemplateSupport(resourceLoader);
        managerTemplateSupport.initializeCreation(absolutePath, managerPackage, scanningConfigurationSupport.getCandidates(resourceLoader));

        SDLogger.printGeneratedTables(true);

    } catch (Exception e) {
        SDLogger.addError(e.getMessage());
        throw new SDMojoException(e.getMessage(), e);
    }
}
项目:spring-data-generator    文件:SDRepositoryMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    SDLogger.configure(getLog());

    this.validateField(Constants.ENTITY_PACKAGE);
    this.validateField(Constants.REPOSITORY_PACKAGE);

    try {
        CustomResourceLoader resourceLoader = new CustomResourceLoader(project);
        resourceLoader = new CustomResourceLoader(project);
        resourceLoader.setPostfix(repositoryPostfix);
        resourceLoader.setOverwrite(overwrite);

        String absolutePath = GeneratorUtils.getAbsolutePath(repositoryPackage);
        if (absolutePath == null){
            SDLogger.addError("Could not define the absolute path of the repositories");
            throw new SDMojoException();
        }

        ScanningConfigurationSupport scanningConfigurationSupport = new ScanningConfigurationSupport(entityPackage, onlyAnnotations);

        RepositoryTemplateSupport repositoryTemplateSupport = new RepositoryTemplateSupport(resourceLoader);
        repositoryTemplateSupport.initializeCreation(absolutePath, repositoryPackage, scanningConfigurationSupport.getCandidates(resourceLoader));

        SDLogger.printGeneratedTables(true);

    } catch (Exception e) {
        SDLogger.addError(e.getMessage());
        throw new SDMojoException(e.getMessage(), e);
    }
}
项目:living-documentation    文件:GherkinMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    if (!gerkinSeparateFeature) {
        appendTitle(get(pageCount.get()));
    }

    readFeatures().forEach(path -> {

        if (gerkinSeparateFeature) {
            // read feature title
            try {
                Map<String, Object> parsed = MapFormatter.parse(readFileToString(FileUtils.getFile(path), defaultCharset()));
                String title = StringUtils.defaultString(getTitle(), EMPTY) + String.valueOf(parsed.get("name"));
                appendTitle(get(pageCount.get()), title);
            } catch (IOException e) {
                throw new IllegalStateException("Error reading " + path, e);
            }
        }
        get(pageCount.get()).textLine(String.format("gherkin::%s[%s]", path, gherkinOptions));
        get(pageCount.get()).textLine(EMPTY);
        somethingWasGenerated = true;

        if (gerkinSeparateFeature) {
            pageCount.incrementAndGet();
        }
    });

    if (!somethingWasGenerated) {
        // nothing generated
        return;
    }

    write(docBuilders.get(0));
}
项目:living-documentation    文件:DiagramMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (interactive) {
        diagramWithLink = true;
        diagramImageType = DiagramImageType.svg;
    }
    // generate diagram
    String diagram = generateDiagram();

    if (StringUtils.isBlank(diagram)) {
        // nothing to generate
        return;
    }

    switch (format) {
        case html:
        case adoc:
        case asciidoc:
            AsciiDocBuilder asciiDocBuilder = this.createAsciiDocBuilder();
            appendTitle(asciiDocBuilder);

            switch (diagramType) {
                case plantuml:
                    asciiDocBuilder.textLine(String.format("[plantuml, %s, format=%s, opts=interactive]", getOutputFilename(), diagramImageType));
            }
            asciiDocBuilder.textLine("----");
            asciiDocBuilder.textLine(diagram);
            asciiDocBuilder.textLine("----");
            // write to file
            write(asciiDocBuilder);
            break;

        case plantuml:
            write(diagram, getOutput(getOutputFilename(), Format.plantuml));
    }
}
项目:syndesis    文件:TooltipExtractorMojo.java   
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        final TooltipExtractor consumer = new TooltipExtractor();

        for (File path: sources) {
            Files.lines(path.toPath()).forEach(consumer);
        }

        consumer.write(new FileWriter(output));
    } catch (IOException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
}