Java Code Examples for org.codehaus.plexus.util.FileUtils#mkdir()

The following examples show how to use org.codehaus.plexus.util.FileUtils#mkdir() . 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: WindowsServiceMojo.java    From joylau-springboot-daemon-windows with MIT License 6 votes vote down vote up
/**
     * @param outDri   输出目录
     * @param fileName 文件名
     * @param text     命令文本
     */
    private void createBat(File outDri, String fileName, String text) {
        if (!outDri.exists()) {
            FileUtils.mkdir(outDri.getPath());
        }
        File file = new File(outDri, fileName);
        try (FileWriter w = new FileWriter(file)) {
            w.write("@echo off\n" +
                    "%1 mshta vbscript:CreateObject(\"Shell.Application\").ShellExecute(\"cmd.exe\",\"/c %~s0 ::\",\"\",\"runas\",1)(window.close)&&exit\n" +
                    "%~dp0" + getJarPrefixName() + ".exe " + text + "\n" +
                    "echo The " + getJarPrefixName() + " service current state:\n" +
                    "%~dp0" + getJarPrefixName() + ".exe status\n" +
                    "pause");
        } catch (IOException e) {
//            throw new MojoExecutionException("Error creating file ", e);
            e.printStackTrace();
        }
        // ignore
    }
 
Example 2
Source File: JaxbUtil.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 将对象转成xml并存储到xml
 *
 * @param ss
 * @param file
 */
public static void saveToXML(Object ss, String file) {
    try {
        String content = convertToXml(ss, CHARSET_UTF8);
        FileUtils.mkdir(DIR);
        FileUtils.fileWrite(file, content);
    } catch (Exception ex) {
        LOGGER.error(ex.getLocalizedMessage(), ex);
    }
}
 
Example 3
Source File: NativeResourceCompileMojo.java    From maven-native with MIT License 5 votes vote down vote up
@Override
public void execute()
    throws MojoExecutionException
{

    if ( !this.resourceCompilerOutputDirectory.exists() )
    {
        this.resourceCompilerOutputDirectory.mkdirs();
    }

    FileUtils.mkdir( project.getBuild().getDirectory() );

    ResourceCompiler compiler = this.getResourceCompiler();

    ResourceCompilerConfiguration config = new ResourceCompilerConfiguration();
    config.setExecutable( this.resourceCompilerExecutable );
    config.setWorkingDirectory( this.workingDirectory );
    config.setOptions( NativeMojoUtils.trimParams( this.resourceCompilerOptions ) );
    config.setOutputDirectory( this.resourceCompilerOutputDirectory );
    config.setEnvFactory( this.getEnvFactory() );

    try
    {
        List<File> resourceOutputFiles;
        resourceOutputFiles = compiler.compile( config, this.resources );

        this.saveCompilerOutputFilePaths( resourceOutputFiles );
    }
    catch ( NativeBuildException e )
    {
        throw new MojoExecutionException( e.getMessage(), e );
    }

}
 
Example 4
Source File: EnhanceMojo.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
/**
 * Write a report on any meta data missing from components.
 */
private void writeMissingMetaDataReport(File aReportFile, Multimap<String, String> aReportData)
        throws MojoExecutionException {
  String[] classes = aReportData.keySet().toArray(new String[aReportData.keySet().size()]);
  Arrays.sort(classes);

  PrintWriter out = null;
  FileUtils.mkdir(aReportFile.getParent());
  try {
    out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(aReportFile), encoding));

    if (classes.length > 0) {
      for (String clazz : classes) {
        out.printf("%s %s%n", MARK_CLASS, clazz);
        Collection<String> messages = aReportData.get(clazz);
        if (messages.isEmpty()) {
          out.printf("  No problems");
        } else {
          for (String message : messages) {
            out.printf("  %s%n", message);
          }
        }
        out.printf("%n");
      }
    } else {
      out.printf("%s%n", MARK_NO_MISSING_META_DATA);
    }
  } catch (IOException e) {
    throw new MojoExecutionException("Unable to write missing meta data report to ["
            + aReportFile + "]" + ExceptionUtils.getRootCauseMessage(e), e);
  } finally {
    IOUtils.closeQuietly(out);
  }
}