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