本文整理匯總了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;
}
示例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;
}
示例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]);
}
示例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 );
}
}
示例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);
}
}
}
}
}
示例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()]);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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 );
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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()] );
}