org.codehaus.plexus.util.FileUtils.resolveFile()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.codehaus.plexus.util.FileUtils.resolveFile()方法的一些代码示例,展示了FileUtils.resolveFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.resolveFile()方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:resolveFile

FileUtils.resolveFile介绍

[英]Resolve a file filename to it's canonical form. If filename is relative (doesn't start with /), it will be resolved relative to baseFile, otherwise it is treated as a normal root-relative path.
[中]将文件filename解析为其规范格式。如果filename是相对的(不是以/开头),它将相对于baseFile进行解析,否则它将被视为正常的根相对路径。

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

throws Exception
File f = FileUtils.resolveFile( dir, entryName );

代码示例来源:origin: org.codehaus.plexus/plexus-archiver

final File f = FileUtils.resolveFile( dir, entryName );

代码示例来源:origin: org.codehaus.mojo/aspectj-maven-plugin

private boolean hasNoPreviousBuild(File outDir) {
  return !FileUtils.resolveFile(outDir, argumentFileName).exists();
}

代码示例来源:origin: mojohaus/aspectj-maven-plugin

private boolean hasNoPreviousBuild(File outDir) {
  return !FileUtils.resolveFile(outDir, argumentFileName).exists();
}

代码示例来源:origin: org.apache.maven.plugins/maven-checkstyle-plugin

protected List<File> getSourceDirectories()
{
  if ( sourceDirectories == null )
  {
    sourceDirectories = project.getCompileSourceRoots();
  }
  List<File> sourceDirs = new ArrayList<>( sourceDirectories.size() );
  for ( String sourceDir : sourceDirectories )
  {
    sourceDirs.add( FileUtils.resolveFile( project.getBasedir(), sourceDir ) );
  }
  return sourceDirs;
}

代码示例来源:origin: org.apache.maven.plugins/maven-checkstyle-plugin

private List<File> getSourceDirectories()
{
  if ( sourceDirectories == null )
  {
    sourceDirectories = project.getCompileSourceRoots();
  }
  List<File> sourceDirs = new ArrayList<>( sourceDirectories.size() );
  for ( String sourceDir : sourceDirectories )
  {
    sourceDirs.add( FileUtils.resolveFile( project.getBasedir(), sourceDir ) );
  }
  return sourceDirs;
}

代码示例来源:origin: org.apache.maven.plugins/maven-checkstyle-plugin

private List<File> getTestSourceDirectories()
{
  if ( testSourceDirectories == null )
  {
    testSourceDirectories = project.getTestCompileSourceRoots();
  }
  List<File> testSourceDirs = new ArrayList<>( testSourceDirectories.size() );
  for ( String testSourceDir : testSourceDirectories )
  {
    testSourceDirs.add( FileUtils.resolveFile( project.getBasedir(), testSourceDir ) );
  }
  return testSourceDirs;
}

代码示例来源:origin: org.apache.maven.plugins/maven-checkstyle-plugin

protected List<File> getTestSourceDirectories()
  {
    if ( testSourceDirectories == null )
    {
      testSourceDirectories = project.getTestCompileSourceRoots();
    }
    List<File> testSourceDirs = new ArrayList<>( testSourceDirectories.size() );
    for ( String testSourceDir : testSourceDirectories )
    {
      testSourceDirs.add( FileUtils.resolveFile( project.getBasedir(), testSourceDir ) );
    }
    return testSourceDirs;
  }
}

代码示例来源:origin: fusesource/hawtjni

private void copyTemplateResource(String file, String output, boolean filter) throws MojoExecutionException {
  try {
    File target = FileUtils.resolveFile(packageDirectory, output);
    if( target.isFile() && target.canRead() ) {
      return;
    }
    URL source = getClass().getClassLoader().getResource("project-template/" + file);
    File tmp = FileUtils.createTempFile("tmp", "txt", new File(project.getBuild().getDirectory()));
    try {
      FileUtils.copyURLToFile(source, tmp);
      FileUtils.copyFile(tmp, target, encoding, filters(filter), true);
    } finally {
      tmp.delete();
    }
  } catch (IOException e) {
    throw new MojoExecutionException("Could not extract template resource: "+file, e);
  }
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void createModulePoms(Properties pomReversedProperties, String rootArtifactId, String packageName, File basedir, File archetypeFilesDirectory, boolean preserveCData, boolean keepParent)
    throws IOException, XmlPullParserException
{
  Model pom = pomManager.readPom(FileUtils.resolveFile(basedir, Constants.ARCHETYPE_POM));
  String parentArtifactId = pomReversedProperties.getProperty(Constants.PARENT_ARTIFACT_ID);
  String artifactId = pom.getArtifactId();
  setParentArtifactId(pomReversedProperties, pomReversedProperties.getProperty(Constants.ARTIFACT_ID));
  setArtifactId(pomReversedProperties, pom.getArtifactId());
  for (String subModuleId : pom.getModules()) {
    String subModuleIdDirectory = subModuleId;
    if (subModuleId.indexOf(rootArtifactId) >= 0) {
      subModuleIdDirectory = StringUtils.replace(subModuleId, rootArtifactId, "__rootArtifactId__");
    }
    createModulePoms(pomReversedProperties, rootArtifactId, packageName, FileUtils.resolveFile(basedir, subModuleId), FileUtils.resolveFile(archetypeFilesDirectory, subModuleIdDirectory),
        preserveCData, keepParent);
  }
  createModulePom(pom, rootArtifactId, archetypeFilesDirectory, pomReversedProperties, FileUtils.resolveFile(basedir, Constants.ARCHETYPE_POM), preserveCData, keepParent);
  restoreParentArtifactId(pomReversedProperties, parentArtifactId);
  restoreArtifactId(pomReversedProperties, artifactId);
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void createPoms(Model pom, String rootArtifactId, String artifactId, File archetypeFilesDirectory, File basedir, Properties pomReversedProperties, boolean preserveCData, boolean keepParent)
    throws IOException, XmlPullParserException
{
  setArtifactId(pomReversedProperties, pom.getArtifactId());
  for (String moduleId : pom.getModules()) {
    String moduleIdDirectory = moduleId;
    if (moduleId.indexOf(rootArtifactId) >= 0) {
      moduleIdDirectory = StringUtils.replace(moduleId, rootArtifactId, "__rootArtifactId__");
    }
    createModulePoms(pomReversedProperties, rootArtifactId, moduleId, FileUtils.resolveFile(basedir, moduleId), FileUtils.resolveFile(archetypeFilesDirectory, moduleIdDirectory),
        preserveCData, keepParent);
  }
  restoreParentArtifactId(pomReversedProperties, null);
  restoreArtifactId(pomReversedProperties, artifactId);
  createArchetypePom(pom, archetypeFilesDirectory, pomReversedProperties, FileUtils.resolveFile(basedir, Constants.ARCHETYPE_POM), preserveCData, keepParent);
}

代码示例来源:origin: apache/maven-archetype

private void createModulePoms( Properties pomReversedProperties, String rootArtifactId, String packageName,
                File basedir, File archetypeFilesDirectory, boolean preserveCData,
                boolean keepParent )
  throws FileNotFoundException, IOException, XmlPullParserException
{
  Model pom = pomManager.readPom( FileUtils.resolveFile( basedir, Constants.ARCHETYPE_POM ) );
  String parentArtifactId = pomReversedProperties.getProperty( Constants.PARENT_ARTIFACT_ID );
  String artifactId = pom.getArtifactId();
  setParentArtifactId( pomReversedProperties, pomReversedProperties.getProperty( Constants.ARTIFACT_ID ) );
  setArtifactId( pomReversedProperties, pom.getArtifactId() );
  for ( String subModuleId : pom.getModules() )
  {
    String subModuleIdDirectory = subModuleId;
    if ( subModuleId.indexOf( rootArtifactId ) >= 0 )
    {
      subModuleIdDirectory = StringUtils.replace( subModuleId, rootArtifactId, "__rootArtifactId__" );
    }
    createModulePoms( pomReversedProperties, rootArtifactId, packageName,
             FileUtils.resolveFile( basedir, subModuleId ),
             FileUtils.resolveFile( archetypeFilesDirectory, subModuleIdDirectory ), preserveCData,
             keepParent );
  }
  createModulePom( pom, rootArtifactId, archetypeFilesDirectory, pomReversedProperties,
           FileUtils.resolveFile( basedir, Constants.ARCHETYPE_POM ), preserveCData, keepParent );
  restoreParentArtifactId( pomReversedProperties, parentArtifactId );
  restoreArtifactId( pomReversedProperties, artifactId );
}

代码示例来源:origin: apache/maven-archetype

private void createPoms( Model pom, String rootArtifactId, String artifactId, File archetypeFilesDirectory,
             File basedir, Properties pomReversedProperties, boolean preserveCData, boolean keepParent )
  throws IOException, FileNotFoundException, XmlPullParserException
{
  setArtifactId( pomReversedProperties, pom.getArtifactId() );
  for ( String moduleId : pom.getModules() )
  {
    String moduleIdDirectory = moduleId;
    if ( moduleId.indexOf( rootArtifactId ) >= 0 )
    {
      moduleIdDirectory = StringUtils.replace( moduleId, rootArtifactId, "__rootArtifactId__" );
    }
    createModulePoms( pomReversedProperties, rootArtifactId, moduleId,
             FileUtils.resolveFile( basedir, moduleId ),
             new File( archetypeFilesDirectory, moduleIdDirectory ), preserveCData, keepParent );
  }
  restoreParentArtifactId( pomReversedProperties, null );
  restoreArtifactId( pomReversedProperties, artifactId );
  createArchetypePom( pom, archetypeFilesDirectory, pomReversedProperties,
            FileUtils.resolveFile( basedir, Constants.ARCHETYPE_POM ), preserveCData, keepParent );
}

代码示例来源:origin: org.codehaus.mojo/jaxb2-maven-plugin

File renamedFile = FileUtils.resolveFile(schemaDirectory, newFilename);
String renameResult = (originalFile.renameTo(renamedFile) ? "Success " : "Failure ");

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void createArchetypePom(Model pom, File archetypeFilesDirectory, Properties pomReversedProperties, File initialPomFile, boolean preserveCData, boolean keepParent) throws IOException {
  File outputFile = FileUtils.resolveFile(archetypeFilesDirectory, Constants.ARCHETYPE_POM);
    File inputFile = FileUtils.resolveFile(archetypeFilesDirectory, Constants.ARCHETYPE_POM + ".tmp");

代码示例来源:origin: org.codehaus.mojo/aspectj-maven-plugin

protected Set<String> getIncludedSources()
    throws MojoExecutionException {
  Set<String> result = new HashSet<String>();
  if (getJavaSources() == null) {
    result = AjcHelper.getBuildFilesForSourceDirs(getSourceDirectories(), this.includes, this.excludes);
  } else {
    for (int scannerIndex = 0; scannerIndex < getJavaSources().length; scannerIndex++) {
      Scanner scanner = getJavaSources()[scannerIndex];
      if (scanner.getBasedir() == null) {
        getLog().info("Source without basedir, skipping it.");
      } else {
        scanner.scan();
        for (int fileIndex = 0; fileIndex < scanner.getIncludedFiles().length; fileIndex++) {
          result.add(FileUtils.resolveFile(scanner.getBasedir(),
              scanner.getIncludedFiles()[fileIndex]).getAbsolutePath());
        }
      }
    }
  }
  return result;
}

代码示例来源:origin: mojohaus/aspectj-maven-plugin

protected Set<String> getIncludedSources()
    throws MojoExecutionException {
  Set<String> result = new HashSet<String>();
  if (getJavaSources() == null) {
    result = AjcHelper.getBuildFilesForSourceDirs(getSourceDirectories(), this.includes, this.excludes);
  } else {
    for (int scannerIndex = 0; scannerIndex < getJavaSources().length; scannerIndex++) {
      Scanner scanner = getJavaSources()[scannerIndex];
      if (scanner.getBasedir() == null) {
        getLog().info("Source without basedir, skipping it.");
      } else {
        scanner.scan();
        for (int fileIndex = 0; fileIndex < scanner.getIncludedFiles().length; fileIndex++) {
          result.add(FileUtils.resolveFile(scanner.getBasedir(),
              scanner.getIncludedFiles()[fileIndex]).getAbsolutePath());
        }
      }
    }
  }
  return result;
}

代码示例来源:origin: org.codehaus.plexus/plexus-appserver-host

File location = FileUtils.resolveFile( directory, appId );

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void createModulePom(Model pom, String rootArtifactId, File archetypeFilesDirectory, Properties pomReversedProperties, File initialPomFile, boolean preserveCData, boolean keepParent)
    throws IOException
  File outputFile = FileUtils.resolveFile(archetypeFilesDirectory, Constants.ARCHETYPE_POM);
    File inputFile = FileUtils.resolveFile(archetypeFilesDirectory, Constants.ARCHETYPE_POM + ".tmp");

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

log.debug("Module's files output directory " + archetypeFilesDirectory);
Model pom = pomManager.readPom(FileUtils.resolveFile(basedir, Constants.ARCHETYPE_POM));
String replacementId = pom.getArtifactId();
String moduleDirectory = pom.getArtifactId();
  ModuleDescriptor moduleDescriptor = createModule(reverseProperties, rootArtifactId, subModuleId, packageName, FileUtils.resolveFile(basedir, subModuleId), FileUtils.resolveFile(
      archetypeFilesDirectory, subModuleIdDirectory), languages, filtereds, defaultEncoding, preserveCData, keepParent);

相关文章