當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。