当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getTargetPath方法代码示例

本文整理汇总了Java中org.apache.maven.model.Resource.getTargetPath方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getTargetPath方法的具体用法?Java Resource.getTargetPath怎么用?Java Resource.getTargetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.model.Resource的用法示例。


在下文中一共展示了Resource.getTargetPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResources

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
public URI[] getResources(boolean test) {
        List<URI> toRet = new ArrayList<URI>();
        URI projectroot = getProjectDirectory().toURI();
        Set<URI> sourceRoots = null;
        List<Resource> res = test ? getOriginalMavenProject().getTestResources() : getOriginalMavenProject().getResources();
        LBL : for (Resource elem : res) {
            String dir = elem.getDirectory();
            if (dir == null) {
                continue; // #191742
            }
            URI uri = FileUtilities.getDirURI(getProjectDirectory(), dir);
            if (elem.getTargetPath() != null || !elem.getExcludes().isEmpty() || !elem.getIncludes().isEmpty()) {
                URI rel = projectroot.relativize(uri);
                if (rel.isAbsolute()) { //outside of project directory
                    continue;// #195928, #231517
                }
                if (sourceRoots == null) {
                    sourceRoots = new HashSet<URI>();
                    sourceRoots.addAll(Arrays.asList(getSourceRoots(true)));
                    sourceRoots.addAll(Arrays.asList(getSourceRoots(false)));
                    //should we also consider generated sources? most like not necessary
                }
                for (URI sr : sourceRoots) {
                    if (!uri.relativize(sr).isAbsolute()) {
                        continue LBL;// #195928, #231517
                    }
                }
                //hope for the best now
            }
//            if (new File(uri).exists()) {
            toRet.add(uri);
//            }
        }
        return toRet.toArray(new URI[toRet.size()]);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:NbMavenProjectImpl.java

示例2: addTargetPath

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private String addTargetPath(String path, Resource resource) {
    String target = resource.getTargetPath();
    if (target != null) {
        target = target.replace("\\", "/");
        target = target.endsWith("/") ? target : (target + "/");
        path = target + path;
    }
    return path;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CopyResourcesOnSave.java

示例3: getShortDescription

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
@Messages({
    "# {0} - directory path",
    "TIP_Resource1=<html>Resource directory defined in POM.<br><i>Directory: </i><b>{0}</b><br>", 
    "# {0} - maven resource target path",
    "TIP_Resource2=<i>Target Path: </i><b>{0}</b><br>", 
    "# {0} - boolean value",
    "TIP_Resource6=<b><i>Filtering: </i>{0}. Please note that some IDE features rely on non-filtered content only.</b><br>", 
    "# {0} - includes string value",
    "TIP_Resource3=<i>Includes: </i><b>{0}</b><br>", 
    "# {0} - excludes string value",
    "TIP_Resource4=<i>Excludes: </i><b>{0}</b><br>", 
    "# {0} - directory path",
    "TIP_Resource5=<html>Configuration Directory<br><i>Directory: </i><b>{0}</b><br>"})
public String getShortDescription() {
    if (group.getResource() != null) {
        Resource rs = group.getResource();
        String str = TIP_Resource1(rs.getDirectory());
        if (rs.getTargetPath() != null) {
            str = str + TIP_Resource2(rs.getTargetPath());
        }
        if (rs.isFiltering()) {
            str = str + TIP_Resource6(rs.isFiltering());
        }
        if (rs.getIncludes() != null && rs.getIncludes().size() > 0) {
            str = str + TIP_Resource3(Arrays.toString(rs.getIncludes().toArray()));
        }
        if (rs.getExcludes() != null && rs.getExcludes().size() > 0) {
            str = str + TIP_Resource4(Arrays.toString(rs.getExcludes().toArray()));
        }
        return str;
    } else {
        return  TIP_Resource5(FileUtil.getFileDisplayName(group.getRootFolder()));
     }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:OthersRootChildren.java

示例4: copyResources

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
 * Copies webapp webResources from the specified directory.
 *
 * @param context the WAR packaging context to use
 * @param resource the resource to copy
 * @throws IOException if an error occurred while copying the resources
 * @throws MojoExecutionException if an error occurred while retrieving the filter properties
 */
public void copyResources( WarPackagingContext context, Resource resource )
    throws IOException, MojoExecutionException
{
    if ( !context.getWebappDirectory().exists() )
    {
        context.getLog().warn( "Not copying webapp webResources [" + resource.getDirectory()
                                   + "]: webapp directory [" + context.getWebappDirectory().getAbsolutePath()
                                   + "] does not exist!" );
    }

    context.getLog().info( "Copying webapp webResources [" + resource.getDirectory() + "] to ["
                               + context.getWebappDirectory().getAbsolutePath() + "]" );
    String[] fileNames = getFilesToCopy( resource );
    for ( String fileName : fileNames )
    {
        String targetFileName = fileName;
        if ( resource.getTargetPath() != null )
        {
            // TODO make sure this thing is 100% safe
            // MWAR-129 if targetPath is only a dot <targetPath>.</targetPath> or ./
            // and the Resource is in a part of the warSourceDirectory the file from sources will override this
            // that's we don't have to add the targetPath yep not nice but works
            if ( !StringUtils.equals( ".", resource.getTargetPath() )
                && !StringUtils.equals( "./", resource.getTargetPath() ) )
            {
                targetFileName = resource.getTargetPath() + File.separator + targetFileName;
            }
        }
        if ( resource.isFiltering() && !context.isNonFilteredExtension( fileName ) )
        {
            copyFilteredFile( id, context, new File( resource.getDirectory(), fileName ), targetFileName );
        }
        else
        {
            copyFile( id, context, new File( resource.getDirectory(), fileName ), targetFileName );
        }
    }
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:47,代码来源:WarProjectPackagingTask.java

示例5: process

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected void process(List<Resource> resources, File outputDirectory) throws MojoExecutionException {
  for (Resource resource : resources) {
    boolean filter = Boolean.parseBoolean(resource.getFiltering());
    try {
      File sourceDirectory = new File(resource.getDirectory());
      // Ensure the sourceDirectory is actually present before attempting to process any resources
      if (!sourceDirectory.exists()) {
        continue;
      }
      sourceDirectory = sourceDirectory.getCanonicalFile();
      File targetDirectory;
      if (resource.getTargetPath() != null) {
        targetDirectory = new File(outputDirectory, resource.getTargetPath());
      } else {
        targetDirectory = outputDirectory;
      }
      if (filter) {
        Map<Object, Object> properties = new HashMap<Object, Object>(this.properties);
        properties.putAll(sessionProperties); // command line parameters win over project properties
        properties.put("project", project);
        properties.put("localRepository", localRepository);
        properties.put("userSettingsFile", userSettingsFile);
        List<File> filters = project.getFilters().stream().map(File::new).collect(Collectors.toList());
        processor.process(sourceDirectory, targetDirectory, resource.getIncludes(), resource.getExcludes(), properties, filters, encoding, missingPropertyAction);
      } else {
        processor.process(sourceDirectory, targetDirectory, resource.getIncludes(), resource.getExcludes(), encoding);
      }
    } catch (IOException e) {
      throw new MojoExecutionException(e.getMessage(), e);
    }
  }
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:33,代码来源:AbstractProcessResourcesMojo.java

示例6: mergeResource_TargetPath

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected void mergeResource_TargetPath( Resource target, Resource source, boolean sourceDominant,
                                         Map<Object, Object> context )
{
    String src = source.getTargetPath();
    if ( src != null )
    {
        if ( sourceDominant || target.getTargetPath() == null )
        {
            target.setTargetPath( src );
            target.setLocation( "targetPath", source.getLocation( "targetPath" ) );
        }
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:14,代码来源:ModelMerger.java


注:本文中的org.apache.maven.model.Resource.getTargetPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。