當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.getDirectory方法代碼示例

本文整理匯總了Java中org.apache.maven.model.Resource.getDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.getDirectory方法的具體用法?Java Resource.getDirectory怎麽用?Java Resource.getDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.model.Resource的用法示例。


在下文中一共展示了Resource.getDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: haveResourcesChanged

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
public static boolean haveResourcesChanged(Log log, MavenProject project, BuildContext buildContext, String suffix) {
    String baseDir = project.getBasedir().getAbsolutePath();
    for (Resource r : project.getBuild().getResources()) {
        File file = new File(r.getDirectory());
        if (file.isAbsolute()) {
            file = new File(r.getDirectory().substring(baseDir.length() + 1));
        }
        String path = file.getPath() + "/" + suffix;
        log.debug("checking  if " + path + " (" + r.getDirectory() + "/" + suffix + ") has changed.");
        if (buildContext.hasDelta(path)) {
            log.debug("Indeed " + suffix + " has changed.");
            return true;
        }
    }
    return false;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:PackageHelper.java

示例2: detectBlueprintOnClassPathOrBlueprintXMLFiles

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private boolean detectBlueprintOnClassPathOrBlueprintXMLFiles() {
    List<Dependency> deps = project.getCompileDependencies();
    for (Dependency dep : deps) {
        if ("org.apache.camel".equals(dep.getGroupId()) && "camel-blueprint".equals(dep.getArtifactId())) {
            getLog().info("camel-blueprint detected on classpath");
        }
    }

    // maybe there is blueprint XML files
    List<Resource> resources = project.getResources();
    for (Resource res : resources) {
        File dir = new File(res.getDirectory());
        File xml = new File(dir, "OSGI-INF/blueprint");
        if (xml.exists() && xml.isDirectory()) {
            getLog().info("OSGi Blueprint XML files detected in directory " + xml);
            return true;
        }
    }

    return false;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:23,代碼來源:RunMojo.java

示例3: collectSourceFiles

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected SourceFile[] collectSourceFiles(MavenProject project) {

	logInfo("source includes: " + ArrayUtils.toString(includes));
	logInfo("source excludes: " + ArrayUtils.toString(excludes));

	List<String> sourcePaths = project.getCompileSourceRoots();
	logInfo("sources paths: " + sourcePaths);

	List<SourceFile> sources = new LinkedList<>();
	for (String sourcePath : sourcePaths) {
		scanForJavaFiles(sources, new File(sourcePath));
	}

	List<Resource> resources = project.getResources();
	logInfo("sources paths from resources: " + sourcePaths);

	for (Resource resource : resources) {
		String directory = resource.getDirectory();
		scanForJavaFiles(sources, new File(directory));
	}

	logInfo("sourceFiles=" + sources);

	return sources.toArray(new SourceFile[0]);
}
 
開發者ID:lgrignon,項目名稱:jsweet-maven-plugin,代碼行數:27,代碼來源:AbstractJSweetMojo.java

示例4: execute

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Main plugin execution
 */
public void execute()
{
    for ( Resource resource : resources )
    {
        // Check for relative paths in the resource configuration.
        // http://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
        File resourceDir = new File( resource.getDirectory() );
        if ( !resourceDir.isAbsolute() )
        {
            resourceDir = new File( project.getBasedir(), resource.getDirectory() );
            resource.setDirectory( resourceDir.getAbsolutePath() );
        }

        addResource( resource );
    }
}
 
開發者ID:mojohaus,項目名稱:build-helper-maven-plugin,代碼行數:20,代碼來源:AbstractAddResourceMojo.java

示例5: copyResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private void copyResources() throws MojoExecutionException {
    List resources = project.getResources();
    if (resources != null) {
        getLog().info("Copying resources");
        for (Object obj : resources) {
            if (obj instanceof Resource) {
                Resource resource = (Resource) obj;
                try {
                    File resourceFolder = new File(resource.getDirectory());
                    if (resourceFolder.exists()) {
                        getLog().info("   " + resource.getDirectory());
                        FileManagementUtil.copyDirectory(resourceFolder, REPO_GEN_LOCATION);
                    }
                } catch (IOException e) {
                    throw new MojoExecutionException("Unable copy resources: " + resource.getDirectory(), e);
                }
            }
        }
    }
}
 
開發者ID:wso2,項目名稱:maven-tools,代碼行數:21,代碼來源:RepositoryGenMojo.java

示例6: 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

示例7: refresh

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
final void refresh() {
    synchronized (resourceUris) {
        List<Resource> resources = new ArrayList<Resource>();
        resources.addAll(nbproject.getMavenProject().getResources());
        resources.addAll(nbproject.getMavenProject().getTestResources());
        Set<File> old = new HashSet<File>(resourceUris);
        Set<File> added = new HashSet<File>();
        
            for (Resource res : resources) {
                String dir = res.getDirectory();
                if (dir == null) {
                    continue;
                }
                URI uri = FileUtilities.getDirURI(project.getProjectDirectory(), dir);
                File file = Utilities.toFile(uri);
                if (!old.contains(file) && !added.contains(file)) { // if a given file is there multiple times, we get assertion back from FileUtil. there can be only one listener+file tuple
                    FileUtil.addRecursiveListener(this, file);
                }
                added.add(file);
            }
        
        old.removeAll(added);
        for (File oldFile : old) {
            FileUtil.removeRecursiveListener(this, oldFile);
        }
        resourceUris.removeAll(old);
        resourceUris.addAll(added);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:CopyResourcesOnSave.java

示例8: hasChangedResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private boolean hasChangedResources(Resource r, long stamp) {
        String dir = r.getDirectory();
        File dirFile = FileUtil.normalizeFile(new File(dir));
  //      System.out.println("checkresource dirfile =" + dirFile);
        if (dirFile.exists()) {
            List<File> toCopy = new ArrayList<File>();
            DirectoryScanner ds = new DirectoryScanner();
            ds.setBasedir(dirFile);
            //includes/excludes
            String[] incls = r.getIncludes().toArray(new String[0]);
            if (incls.length > 0) {
                ds.setIncludes(incls);
            } else {
                ds.setIncludes(DEFAULT_INCLUDES);
            }
            String[] excls = r.getExcludes().toArray(new String[0]);
            if (excls.length > 0) {
                ds.setExcludes(excls);
            }
            ds.addDefaultExcludes();
            ds.scan();
            String[] inclds = ds.getIncludedFiles();
//            System.out.println("found=" + inclds.length);
            for (String inc : inclds) {
                File f = new File(dirFile, inc);
                if (f.lastModified() >= stamp) { 
                    toCopy.add(FileUtil.normalizeFile(f));
                }
            }
            if (toCopy.size() > 0) {
                    //the case of filtering source roots, here we want to return false
                    //to skip CoS altogether.
                return true;
            }
        }
        return false;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:FilteredResourcesCoSSkipper.java

示例9: checkResource

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private Resource checkResource(FileObject rootFold, List<Resource> list) {
    for (Resource elem : list) {
        String dir = elem.getDirectory();
        if (dir == null) { // #203635
            continue;
        }
        URI uri = FileUtilities.getDirURI(project.getProjectDirectory(), dir);
        FileObject fo = FileUtilities.convertURItoFileObject(uri);
        if (fo != null && fo.equals(rootFold)) {
            return elem;
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:MavenSourcesImpl.java

示例10: handleWebResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Handles the web resources.
 *
 * @param context the packaging context
 * @throws MojoExecutionException if a resource could not be copied
 */
protected void handleWebResources( WarPackagingContext context )
    throws MojoExecutionException
{
    for ( Resource resource : webResources )
    {

        // MWAR-246
        if ( resource.getDirectory() == null )
        {
            throw new MojoExecutionException( "The <directory> tag is missing from the <resource> tag." );
        }

        if ( !( new File( resource.getDirectory() ) ).isAbsolute() )
        {
            resource.setDirectory( context.getProject().getBasedir() + File.separator + resource.getDirectory() );
        }

        // Make sure that the resource directory is not the same as the webappDirectory
        if ( !resource.getDirectory().equals( context.getWebappDirectory().getPath() ) )
        {

            try
            {
                copyResources( context, resource );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Could not copy resource [" + resource.getDirectory() + "]", e );
            }
        }
    }
}
 
開發者ID:zhegexiaohuozi,項目名稱:maven-seimicrawler-plugin,代碼行數:39,代碼來源:WarProjectPackagingTask.java

示例11: addResources

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private void addResources(List<URL> urls) throws IOException {
	if (this.addResources) {
		for (Resource resource : this.project.getResources()) {
			File directory = new File(resource.getDirectory());
			urls.add(directory.toURI().toURL());
			FileUtils.removeDuplicatesFromOutputDirectory(this.classesDirectory,
					directory);
		}
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:11,代碼來源:AbstractRunMojo.java

示例12: findComponentNames

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private List<String> findComponentNames() {
    List<String> componentNames = new ArrayList<String>();
    for (Resource r : project.getBuild().getResources()) {
        File f = new File(r.getDirectory());
        if (!f.exists()) {
            f = new File(project.getBasedir(), r.getDirectory());
        }
        f = new File(f, "META-INF/services/org/apache/camel/component");

        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    // skip directories as there may be a sub .resolver directory
                    if (file.isDirectory()) {
                        continue;
                    }
                    String name = file.getName();
                    if (name.charAt(0) != '.') {
                        componentNames.add(name);
                    }
                }
            }
        }
    }
    return componentNames;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:ReadmeComponentMojo.java

示例13: findDataFormatNames

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
private List<String> findDataFormatNames() {
    List<String> dataFormatNames = new ArrayList<String>();
    for (Resource r : project.getBuild().getResources()) {
        File f = new File(r.getDirectory());
        if (!f.exists()) {
            f = new File(project.getBasedir(), r.getDirectory());
        }
        f = new File(f, "META-INF/services/org/apache/camel/dataformat");

        if (f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            if (files != null) {
                for (File file : files) {
                    // skip directories as there may be a sub .resolver directory
                    if (file.isDirectory()) {
                        continue;
                    }
                    String name = file.getName();
                    if (name.charAt(0) != '.') {
                        dataFormatNames.add(name);
                    }
                }
            }
        }
    }
    return dataFormatNames;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:SpringBootAutoConfigurationMojo.java

示例14: includeConfigurationFile

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * <p>todo: javadocs</p>
 *
 * @param testResources
 */
private void includeConfigurationFile(final List<Resource> testResources) {

    for (final Resource rawResource : testResources) {

        if (rawResource.getDirectory() != null) {

            rawResource.addInclude(configurationFileName);
        }
    }
}
 
開發者ID:AndyScherzinger,項目名稱:architecturerules,代碼行數:16,代碼來源:ArchitectureRulesMojo.java

示例15: getIncludedDirectoriesFromModel

import org.apache.maven.model.Resource; //導入方法依賴的package包/類
/**
 * Get filsets of files included in the project from the Maven model
 * @param model Maven model
 * @return Source file set and resource filesets
 */
@SuppressWarnings( "unused" )
private FileSet[] getIncludedDirectoriesFromModel( Model model ) 
{
    //TODO: This can be refactored to common code from the CreateSpdxMojo
    ArrayList<FileSet> result = new ArrayList<FileSet>();
    String sourcePath = model.getBuild().getSourceDirectory();
    if ( sourcePath != null && !sourcePath.isEmpty() ) {
        FileSet srcFileSet = new FileSet();
        File sourceDir = new File( sourcePath );
        srcFileSet.setDirectory( sourceDir.getAbsolutePath() );
        srcFileSet.addInclude( CreateSpdxMojo.INCLUDE_ALL );
        result.add( srcFileSet );  
    }
  
    List<Resource> resourceList = model.getBuild().getResources();
    if ( resourceList != null ) 
    {
        Iterator<Resource> resourceIter = resourceList.iterator();
        while ( resourceIter.hasNext() ) 
        {
            Resource resource = resourceIter.next();
            FileSet resourceFileSet = new FileSet();
            File resourceDir = new File( resource.getDirectory() );
            resourceFileSet.setDirectory( resourceDir.getAbsolutePath() );
            resourceFileSet.setExcludes( resource.getExcludes() );
            resourceFileSet.setIncludes( resource.getIncludes() );
            result.add( resourceFileSet );
        }
    }
    return result.toArray( new FileSet[result.size()] );
}
 
開發者ID:spdx,項目名稱:spdx-maven-plugin,代碼行數:37,代碼來源:SpdxDependencyInformation.java


注:本文中的org.apache.maven.model.Resource.getDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。