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


Java Resource类代码示例

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


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

示例1: getResourceDirectoryPath

import org.apache.maven.model.Resource; //导入依赖的package包/类
@Override
public String getResourceDirectoryPath(boolean isTest) {
    NbMavenProject watch = project.getLookup().lookup(NbMavenProject.class);
    List<Resource> res;
    String defaultValue;
    
    if (isTest) {
        res = watch.getMavenProject().getTestResources();           
        defaultValue = "src/test/resources"; //NOI18N
    } else {
        res = watch.getMavenProject().getResources();
        defaultValue = "src/main/resources"; //NOI18N
    }
    for (Resource resource : res) {
        FileObject fo = FileUtilities.convertStringToFileObject(resource.getDirectory());
        if (fo != null && FileUtil.isParentOf(project.getProjectDirectory(), fo)) {
            return FileUtil.getRelativePath(project.getProjectDirectory(), fo);
        }
    }
    return defaultValue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MavenNbModuleImpl.java

示例2: execute

import org.apache.maven.model.Resource; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {

        final Resource resource = new Resource();
        resource.setDirectory(outputDir.getCanonicalPath());
        project.addResource(resource);

        final Set<File> generated = new HashSet<>();

        final ReadApiClientData reader = new ReadApiClientData();
        final List<ModelData<?>> modelList = reader.readDataFromFile("io/syndesis/dao/deployment.json");
        for (final ModelData<?> model : modelList) {
            if (model.getKind() == Kind.Connector) {
                final Connector connector = (Connector) model.getData();

                for (final ConnectorAction action : connector.getActions()) {
                    process(generated, connector, action, action.getInputDataShape());
                    process(generated, connector, action, action.getOutputDataShape());
                }
            }
        }
    } catch (final IOException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:27,代码来源:GenerateMapperInspectionsMojo.java

示例3: retrieveResourcesDirectories

import org.apache.maven.model.Resource; //导入依赖的package包/类
public static List<File> retrieveResourcesDirectories(List<File> contentRoots, List<MavenProject> allProjectsInBuild) {
    List<File> result = new ArrayList<>();
    for (MavenProject project : allProjectsInBuild) {
        String buildDirectory = formatPath(project.getBuild().getDirectory());
        for (Resource resource : project.getBuild().getResources()) {
            String contentRootPath = formatPath(resource.getDirectory());
            if (contentRootPath.startsWith(buildDirectory)) {
                continue;
            }
            File contentRoot = new File(contentRootPath);
            result.add(contentRoot);
        }
    }
    if (contentRoots != null) {
        result.addAll(contentRoots);
    }
    Iterator<File> iterator = result.iterator();
    while (iterator.hasNext()) {
        if (!iterator.next().exists()) {
            iterator.remove();
        }
    }
    return result;
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:25,代码来源:MavenUtil.java

示例4: WarProjectPackagingTask

import org.apache.maven.model.Resource; //导入依赖的package包/类
/**
 * @param webResources {@link #webResources}
 * @param webXml {@link #webXml}
 * @param containerConfigXml {@link #containerConfigXML}
 * @param currentProjectOverlay {@link #currentProjectOverlay}
 */
public WarProjectPackagingTask( Resource[] webResources, File webXml, File containerConfigXml,
                                Overlay currentProjectOverlay )
{
    if ( webResources != null )
    {
        this.webResources = webResources;
    }
    else
    {
        this.webResources = new Resource[0];
    }
    this.webXml = webXml;
    this.containerConfigXML = containerConfigXml;
    this.currentProjectOverlay = currentProjectOverlay;
    this.id = currentProjectOverlay.getId();
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:23,代码来源:WarProjectPackagingTask.java

示例5: getFilesToCopy

import org.apache.maven.model.Resource; //导入依赖的package包/类
/**
 * Returns a list of filenames that should be copied over to the destination directory.
 *
 * @param resource the resource to be scanned
 * @return the array of filenames, relative to the sourceDir
 */
private String[] getFilesToCopy( Resource resource )
{
    // CHECKSTYLE_OFF: LineLength
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir( resource.getDirectory() );
    if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
    {
        scanner.setIncludes( (String[]) resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) );
    }
    else
    {
        scanner.setIncludes( DEFAULT_INCLUDES );
    }
    if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
    {
        scanner.setExcludes( (String[]) resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) );
    }

    scanner.addDefaultExcludes();

    scanner.scan();

    return scanner.getIncludedFiles();
    // CHECKSTYLE_ON: LineLength
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:32,代码来源:WarProjectPackagingTask.java

示例6: install

import org.apache.maven.model.Resource; //导入依赖的package包/类
@Override
public boolean install() {
  if (!this.isInstalled()) {
    getResourceDirectories().forEach(DirectoryResource::mkdirs);
  }

  // Update Maven model - main resource only
  MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
  Model pom = maven.getModel();
  Resource main = new Resource();
  main.setDirectory("${project.basedir}/src/main/" + name);
  pom.getBuild().getResources().add(main);

  maven.setModel(pom);

  return true;
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:18,代码来源:CustomResourceFacet.java

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

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

示例9: convenrtResources

import org.apache.maven.model.Resource; //导入依赖的package包/类
private static List<MavenResource> convenrtResources(List<Resource> resources, File projectDir) {
  List<MavenResource> result = new ArrayList<>();
  if (resources != null) {
    for (Resource res : resources) {
      result.add(
          new MavenResource(
              relativize(projectDir, res.getDirectory()),
              res.isFiltering(),
              res.getTargetPath(),
              patternsOrEmptyList(res.getIncludes()),
              patternsOrEmptyList(res.getExcludes())));
    }
  }

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:MavenModelUtil.java

示例10: getResources

import org.apache.maven.model.Resource; //导入依赖的package包/类
/**
 * Get resources for specific scope.
 *
 * @param project
 * @param scope
 * @return
 */
private List<Resource> getResources(final MavenProject project, final String scope)
{
	if (SCOPE_COMPILE.equals(scope) || SCOPE_RUNTIME.equals(scope))
	{
		return project.getResources();
	}
	else if (SCOPE_TEST.equals(scope))
	{
		List<Resource> resources = new ArrayList<Resource>();
		resources.addAll(project.getTestResources());
		resources.addAll(project.getResources());
		return resources;
	}
	else
	{
		throw new RuntimeException("Not allowed scope " + scope);
	}
}
 
开发者ID:CruxFramework,项目名称:crux-maven-plugin,代码行数:26,代码来源:ClasspathBuilder.java

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

示例12: execute

import org.apache.maven.model.Resource; //导入依赖的package包/类
/**
 * Triggers thee execution of SJS compilation.
 *
 * @throws MojoExecutionException
 *     whenever an unexpected error occurs when executing mojo.
 */
@Override
public void execute() throws MojoExecutionException {
  if (isChangeDetected()) {
    try {
      runSjsCompilation();
    } catch (IOException | DependencyResolutionRequiredException | ScriptException | ResourceException ex) {
      throw new MojoExecutionException(
          "An unexpected exception occurred when running SJS compilation.", ex);
    }
  } else {
    getLog().info("No change detected. Skipping generation.");
  }
  Resource outputResource = new Resource();
  outputResource.setDirectory(outputDir.getPath());
  project.addResource(outputResource);
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:23,代码来源:SjsMojo.java

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

示例14: setupMavenPaths

import org.apache.maven.model.Resource; //导入依赖的package包/类
/**
 * Updates XJC's compilePath ans resources and update hyperjaxb2's
 * resources, that is, *.hbm.xml files and hibernate.config.xml file.
 * 
 * @param xjcOpts
 * @throws MojoExecutionException
 */
protected void setupMavenPaths() {
	super.setupMavenPaths();

	final Resource resource = new Resource();
	resource.setDirectory(getGenerateDirectory().getPath());
	for (String resourceInclude : resourceIncludes) {
		resource.addInclude(resourceInclude);
	}
	getProject().addResource(resource);

	if (this.roundtripTestClassName != null) {
		getProject().addTestCompileSourceRoot(
				getGenerateDirectory().getPath());
	}
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:23,代码来源:Hyperjaxb3Mojo.java

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


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