org.apache.maven.model.Resource Java Examples

The following examples show how to use org.apache.maven.model.Resource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsciidoctorFileScanner.java    From asciidoctor-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the Scanner with the default values.
 * <br>
 * By default:
 * <ul>
 *     <li>includes adds extension .adoc, .ad, .asc and .asciidoc
 *     <li>excludes adds filters to avoid hidden files and directoris beginning with undersore
 * </ul>
 *
 * NOTE: Patterns both in inclusions and exclusions are automatically excluded.
 */
private void setupScanner(Scanner scanner, Resource resource) {

    if (resource.getIncludes() == null || resource.getIncludes().isEmpty()) {
        scanner.setIncludes(DEFAULT_FILE_EXTENSIONS);
    } else {
        scanner.setIncludes(resource.getIncludes().toArray(new String[] {}));
    }

    if (resource.getExcludes() == null || resource.getExcludes().isEmpty()) {
        scanner.setExcludes(IGNORED_FOLDERS_AND_FILES);
    } else {
        scanner.setExcludes(mergeAndConvert(resource.getExcludes(), IGNORED_FOLDERS_AND_FILES));
    }
    // adds exclusions like SVN or GIT files
    scanner.addDefaultExcludes();
}
 
Example #2
Source File: Hyperjaxb3Mojo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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());
	}
}
 
Example #3
Source File: GenerateMapperInspectionsMojo.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@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/server/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);
    }
}
 
Example #4
Source File: MavenNbModuleImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: AbstractProctorMojo.java    From proctor with Apache License 2.0 6 votes vote down vote up
private void addNonPartialsToResources(final File dir, final Resource resource) throws CodeGenException {
    if (dir.equals(null)) {
        throw new CodeGenException("Could not read from directory " + dir.getPath());
    }
    final File[] files = dir.listFiles();
    if (files == null) {
        return;
    }
    for (final File entry : files) {
        try {
            if (entry.isDirectory()) {
                addNonPartialsToResources(entry, resource);
            } else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) {
                resource.addInclude(entry.getPath().substring(getTopDirectory().getPath().length() + 1));
            }
        } catch (final IOException e) {
            throw new CodeGenException("Could not read from file " + entry.getName(),e);
        }

    }
}
 
Example #6
Source File: AbstractProctorMojo.java    From proctor with Apache License 2.0 6 votes vote down vote up
Resource[] getResources() throws MojoExecutionException {
    final Resource resourceNonGenerated = new Resource();
    resourceNonGenerated.setDirectory(getTopDirectory().getPath());
    try {
        addNonPartialsToResources(getTopDirectory(),resourceNonGenerated);
    } catch (final CodeGenException e) {
        throw new MojoExecutionException("Couldn't add non partial specifications to resources");
    }
    if (resourceNonGenerated.getIncludes().isEmpty()) {
        resourceNonGenerated.addExclude("**/*");
    }
    final Resource resourceGenerated = new Resource();
    final File specificationOutputDir = getSpecificationOutput();
    resourceGenerated.setDirectory(specificationOutputDir.getPath());
    resourceGenerated.addInclude("**/*.json");
    final Resource[] resources = {resourceNonGenerated,resourceGenerated};
    return resources;

}
 
Example #7
Source File: MavenUtils.java    From wisdom with Apache License 2.0 6 votes vote down vote up
/**
 * Compute a String form the given list of resources. The list is structured as follows:
 * list:=resource[,resource]*
 * resource:=directory;target;filtering;
 *
 * @param resources the list of resources
 * @return the computed String form
 */
protected static String toString(List<Resource> resources) {
    StringBuilder builder = new StringBuilder();

    for (Resource resource : resources) {
        if (builder.length() == 0) {
            builder.append(resource.getDirectory())
                    .append(";")
                    .append(resource.getTargetPath() != null ? resource.getTargetPath() : "")
                    .append(";")
                    .append(resource.getFiltering() != null ? resource.getFiltering() : "true")
                    .append(";");
        } else {
            builder.append(",")
                    .append(resource.getDirectory())
                    .append(";")
                    .append(resource.getTargetPath() != null ? resource.getTargetPath() : "")
                    .append(";")
                    .append(resource.getFiltering() != null ? resource.getFiltering() : "true")
                    .append(";");
        }
    }

    return builder.toString();
}
 
Example #8
Source File: ResourceCopy.java    From wisdom with Apache License 2.0 6 votes vote down vote up
private static void filterAndCopy(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering, File in, File out) throws IOException {
    Resource resource = new Resource();
    resource.setDirectory(in.getAbsolutePath());
    resource.setFiltering(true);
    resource.setTargetPath(out.getAbsolutePath());

    List<String> excludedExtensions = new ArrayList<>();
    excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
    excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);

    MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), out, mojo.project,
            "UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
    exec.setEscapeString("\\");

    try {
        filtering.filterResources(exec);
    } catch (MavenFilteringException e) {
        throw new IOException("Error while copying resources", e);
    }
}
 
Example #9
Source File: MavenProjectConfigCollector.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
private void collectConfig(MavenProject project, MavenSession session) {
    final Path projectDir = project.getBasedir().toPath();
    final ProjectConfig config = ProjectConfig.projectConfig(projectDir);
    final List<String> dependencies = dependencies(project, session);
    final Path outputDir = projectDir.resolve(project.getBuild().getOutputDirectory());
    final List<String> classesDirs = List.of(outputDir.toString());
    final List<String> resourceDirs = project.getResources()
            .stream()
            .map(Resource::getDirectory)
            .collect(Collectors.toList());
    config.property(PROJECT_DEPENDENCIES, dependencies);
    config.property(PROJECT_MAINCLASS, project.getProperties().getProperty(MAIN_CLASS_PROPERTY));
    config.property(PROJECT_VERSION, project.getVersion());
    config.property(PROJECT_CLASSDIRS, classesDirs);
    config.property(PROJECT_SOURCEDIRS, project.getCompileSourceRoots());
    config.property(PROJECT_RESOURCEDIRS, resourceDirs);
    this.projectConfig = config;
}
 
Example #10
Source File: DevMojo.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * Execute the resources:resources goal if resources have been configured on the project
 */
private void handleResources() throws MojoExecutionException {
    List<Resource> resources = project.getResources();
    if (!resources.isEmpty()) {
        Plugin resourcesPlugin = project.getPlugin(ORG_APACHE_MAVEN_PLUGINS + ":" + MAVEN_RESOURCES_PLUGIN);
        MojoExecutor.executeMojo(
                MojoExecutor.plugin(
                        MojoExecutor.groupId(ORG_APACHE_MAVEN_PLUGINS),
                        MojoExecutor.artifactId(MAVEN_RESOURCES_PLUGIN),
                        MojoExecutor.version(resourcesPlugin.getVersion()),
                        resourcesPlugin.getDependencies()),
                MojoExecutor.goal("resources"),
                getPluginConfig(resourcesPlugin),
                MojoExecutor.executionEnvironment(
                        project,
                        session,
                        pluginManager));
    }
}
 
Example #11
Source File: InitializeMojoTest.java    From roboconf-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void checkSourcesDirectoriesAreUpdated() throws Exception {

	// Find the project
	File baseDir = this.resources.getBasedir( "project--valid" );
	Assert.assertNotNull( baseDir );
	Assert.assertTrue( baseDir.exists());
	Assert.assertTrue( baseDir.isDirectory());

	File pom = new File( baseDir, "pom.xml" );
	InitializeMojo mojo = (InitializeMojo) this.rule.lookupMojo( "initialize", pom );
	Assert.assertNotNull( mojo );

	// Create the Maven project by hand (...)
	final MavenProject mvnProject = new MavenProject() ;
	mvnProject.setFile( pom ) ;
	this.rule.setVariableValueToObject( mojo, "project", mvnProject );
	Assert.assertNotNull( this.rule.getVariableValueFromObject( mojo, "project" ));

	// Execute the mojo
	List<Resource> list = mvnProject.getResources();
	Assert.assertEquals( 0, list.size());
	Assert.assertTrue( Utils.isEmptyOrWhitespaces( mvnProject.getBuild().getOutputDirectory()));

	mojo.execute();

	list = mvnProject.getResources();
	Assert.assertEquals( 2, list.size());

	Resource res = list.get( 0 );
	Assert.assertTrue( res.isFiltering());
	Assert.assertEquals( new File( baseDir, MavenPluginConstants.SOURCE_MODEL_DIRECTORY ).getAbsolutePath(), res.getDirectory());

	res = list.get( 1 );
	Assert.assertFalse( res.isFiltering());
	Assert.assertEquals( new File( baseDir, MavenPluginConstants.SOURCE_MODEL_DIRECTORY ).getAbsolutePath(), res.getDirectory());

	File expectedFile = new File( mvnProject.getBasedir(), MavenPluginConstants.TARGET_MODEL_DIRECTORY );
	Assert.assertEquals( expectedFile.getAbsolutePath(), mvnProject.getBuild().getOutputDirectory());
}
 
Example #12
Source File: BaseMojo.java    From jax-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void addResources(Log log) {
    if (addResources) {
        cmd //
                .getResourceParameter() //
                .flatMap(parameterName -> Util.getNextArgument(arguments, parameterName)) //
                .ifPresent(x -> {
                    Resource resource = new Resource();
                    resource.setDirectory(x);
                    project.addResource(resource);
                    log.info("added resource folder: " + x);
                });
    }
}
 
Example #13
Source File: SchemaGenerationMojo.java    From jaxb2-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void addResource(final Resource resource) {

    if(resource != null) {

        final String newDirectory = resource.getDirectory();

        // Is the supplied resource already added?
        final List<Resource> currentResources = getProject().getResources();

        if(getLog().isDebugEnabled()) {
            getLog().debug("Candidate Resource Directory [" + newDirectory + "]");
            getLog().debug("Found [" + currentResources.size() + "] current Resources: "
                    + currentResources);
        }

        for (Resource current : currentResources) {

            // Is the resource already added?
            if(current.getDirectory() != null && current.getDirectory().equalsIgnoreCase(newDirectory)) {
                getLog().debug("Resource already added [" + newDirectory + "]. Not adding again.");
                return;
            }
        }

        // Add the new Resource
        currentResources.add(resource);

        if(getLog().isDebugEnabled()) {
            getLog().debug("Added resource [" + newDirectory + "] to existing resources.");
        }
    }
}
 
Example #14
Source File: AddTestResourceMojo.java    From build-helper-maven-plugin with MIT License 5 votes vote down vote up
/**
 * Add the resource to the project.
 *
 * @param resource the resource to add
 */
public void addResource( Resource resource )
{
    getProject().addTestResource( resource );
    if ( getLog().isDebugEnabled() )
    {
        getLog().debug( "Added test resource: " + resource.getDirectory() );
    }
}
 
Example #15
Source File: AddResourceMojo.java    From build-helper-maven-plugin with MIT License 5 votes vote down vote up
public void addResource( Resource resource )
{
    getProject().addResource( resource );
    if ( getLog().isDebugEnabled() )
    {
        getLog().debug( "Added resource: " + resource.getDirectory() );
    }
}
 
Example #16
Source File: TestSchemaGenerationMojo.java    From jaxb2-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void addResource(final Resource resource) {

    if (resource != null) {

        final String newDirectory = resource.getDirectory();

        // Is the supplied resource already added?
        final List<Resource> currentResources = getProject().getTestResources();

        if (getLog().isDebugEnabled()) {
            getLog().debug("Candidate Test Resource Directory [" + newDirectory + "]");
            getLog().debug("Found [" + currentResources.size() + "] current Test Resources: "
                    + currentResources);
        }

        for (Resource current : currentResources) {

            // Is the resource already added?
            if (current.getDirectory() != null && current.getDirectory().equalsIgnoreCase(newDirectory)) {
                getLog().debug("Test resource already added [" + newDirectory + "]. Not adding again.");
                return;
            }
        }

        // Add the new Resource
        currentResources.add(resource);

        if (getLog().isDebugEnabled()) {
            getLog().debug("Added test resource [" + newDirectory + "] to existing test resources.");
        }
    }
}
 
Example #17
Source File: AsciidoctorFileScanner.java    From asciidoctor-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Scans a list of resources returning all AsciiDoc documents found.
 *
 * @param resources List of {@link Resource} to scan (the directory property is mandatory)
 * @return List of found documents matching the resources properties
 */
public List<File> scan(List<Resource> resources) {
    List<File> files = new ArrayList<File>();
    for (Resource resource: resources) {
        files.addAll(scan(resource));
    }
    return files;
}
 
Example #18
Source File: AsciidoctorFileScanner.java    From asciidoctor-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Scans a resource directory (and sub-subdirectories) returning all AsciiDoc documents found.
 *
 * @param resource {@link Resource} to scan (the directory property is mandatory)
 * @return List of found documents matching the resource properties
 */
public List<File> scan(Resource resource) {
    Scanner scanner = buildContext.newScanner(new File(resource.getDirectory()), true);
    setupScanner(scanner, resource);
    scanner.scan();
    List<File> files = new ArrayList<File>();
    for (String file : scanner.getIncludedFiles()) {
        files.add(new File(resource.getDirectory(), file));
    }
    return files;
}
 
Example #19
Source File: RawXJC2Mojo.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Augments Maven paths with generated resources.
 */
protected void setupMavenPaths() {

	if (getAddCompileSourceRoot()) {
		getProject().addCompileSourceRoot(getGenerateDirectory().getPath());
	}
	if (getAddTestCompileSourceRoot()) {
		getProject().addTestCompileSourceRoot(getGenerateDirectory().getPath());
	}
	if (getEpisode() && getEpisodeFile() != null) {
		final String episodeFilePath = getEpisodeFile().getAbsolutePath();
		final String generatedDirectoryPath = getGenerateDirectory().getAbsolutePath();

		if (episodeFilePath.startsWith(generatedDirectoryPath + File.separator)) {
			final String path = episodeFilePath.substring(generatedDirectoryPath.length() + 1);

			final Resource resource = new Resource();
			resource.setDirectory(generatedDirectoryPath);
			resource.addInclude(path);
			if (getAddCompileSourceRoot()) {
				getProject().addResource(resource);
			}
			if (getAddTestCompileSourceRoot()) {
				getProject().addTestResource(resource);

			}
		}
	}
}
 
Example #20
Source File: JavascriptProctorTestMojo.java    From proctor with Apache License 2.0 5 votes vote down vote up
public void execute() throws MojoExecutionException {
    project.addTestCompileSourceRoot(getOutputDirectory().getPath());
    super.createTotalSpecifications(getTopDirectory(),null);
    final Resource[] resources = getResources();
    for (final Resource resource : resources) {
        project.addTestResource(resource);
    }
    super.execute();
}
 
Example #21
Source File: JavascriptProctorMojo.java    From proctor with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws MojoExecutionException {
    project.addCompileSourceRoot(getOutputDirectory().getPath());
    super.createTotalSpecifications(getTopDirectory(), null);
    final Resource[] resources = getResources();
    for (final Resource resource : resources) {
        project.addResource(resource);
    }
    super.execute();
}
 
Example #22
Source File: JavaProctorTestMojo.java    From proctor with Apache License 2.0 5 votes vote down vote up
public void execute() throws MojoExecutionException {
    project.addTestCompileSourceRoot(getOutputDirectory().getPath());
    super.createTotalSpecifications(getTopDirectory(),null);
    final Resource[] resources = getResources();
    for (final Resource resource : resources) {
        project.addTestResource(resource);
    }
    super.execute();
}
 
Example #23
Source File: Utils.java    From usergrid with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if there is at least one resource folder inside the project.
 *
 * @param project
 * @return
 */
public static boolean hasResourceFolders( MavenProject project ){
    List<Resource> resources = project.getResources();
    for ( Resource res : resources ){
        if ( FileUtils.fileExists( res.getDirectory() ) ){
            return true;
        }
    }
    return false;
}
 
Example #24
Source File: JavaProctorMojo.java    From proctor with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws MojoExecutionException {
    project.addCompileSourceRoot(getOutputDirectory().getPath());
    super.createTotalSpecifications(getTopDirectory(), null);
    final Resource[] resources = getResources();
    for (final Resource resource : resources) {
        project.addResource(resource);
    }
    super.execute();
}
 
Example #25
Source File: ResourceCopy.java    From wisdom with Apache License 2.0 5 votes vote down vote up
/**
 * Copies the file <tt>file</tt> to the directory <tt>dir</tt>, keeping the structure relative to <tt>rel</tt>.
 *
 * @param file                 the file to copy
 * @param rel                  the base 'relative'
 * @param dir                  the directory
 * @param mojo                 the mojo
 * @param filtering            the filtering component
 * @param additionalProperties additional properties
 * @throws IOException if the file cannot be copied.
 */
public static void copyFileToDir(File file, File rel, File dir, AbstractWisdomMojo mojo, MavenResourcesFiltering
        filtering, Properties additionalProperties) throws
        IOException {
    if (filtering == null) {
        File out = computeRelativeFile(file, rel, dir);
        if (out.getParentFile() != null) {
            mojo.getLog().debug("Creating " + out.getParentFile() + " : " + out.getParentFile().mkdirs());
            FileUtils.copyFileToDirectory(file, out.getParentFile());
        } else {
            throw new IOException("Cannot copy file - parent directory not accessible for "
                    + file.getAbsolutePath());
        }
    } else {
        Resource resource = new Resource();
        resource.setDirectory(rel.getAbsolutePath());
        resource.setFiltering(true);
        resource.setTargetPath(dir.getAbsolutePath());
        resource.setIncludes(ImmutableList.of("**/" + file.getName()));

        List<String> excludedExtensions = new ArrayList<>();
        excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
        excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);

        MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), dir, mojo.project,
                "UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);

        if (additionalProperties != null) {
            exec.setAdditionalProperties(additionalProperties);
        }
        exec.setEscapeString("\\");

        try {
            filtering.filterResources(exec);
        } catch (MavenFilteringException e) {
            throw new IOException("Error while copying resources", e);
        }
    }
}
 
Example #26
Source File: OthersRootChildren.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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()));
     }
}
 
Example #27
Source File: ProjectModelEnricher.java    From yaks with Apache License 2.0 5 votes vote down vote up
/**
 * Dynamically add test resource directory pointing to mounted test directory. Mounted directory usually gets added
 * as volume mount and holds tests to execute in this project.
 * @param projectModel
 */
private void injectTestResources(Model projectModel) {
    if (ExtensionSettings.hasMountedTests()) {
        Resource mountedTests = new Resource();
        mountedTests.setDirectory(ExtensionSettings.getMountedTestsPath() + "/..data");
        mountedTests.setTargetPath(projectModel.getBuild().getTestOutputDirectory() + "/org/citrusframework/yaks");
        mountedTests.setFiltering(false);
        projectModel.getBuild().getTestResources().add(mountedTests);

        logger.info("Add mounted test resources in directory: " + ExtensionSettings.getMountedTestsPath());
    }
}
 
Example #28
Source File: JarMojo.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Scan for project resources and produce a comma separated list of include resources.
 *
 * @return list of resources
 */
private Map<String, List<String>> scanResources() {
    getLog().debug("Scanning project resources");
    Map<String, List<String>> allResources = new HashMap<>();
    for (Resource resource : project.getResources()) {
        List<String> resources = new ArrayList<>();
        allResources.put(resource.getDirectory(), resources);
        File resourcesDir = new File(resource.getDirectory());
        Scanner scanner = buildContext.newScanner(resourcesDir);
        String[] includes = null;
        if (resource.getIncludes() != null
                && !resource.getIncludes().isEmpty()) {
            includes = (String[]) resource.getIncludes()
                    .toArray(new String[resource.getIncludes().size()]);
        }
        scanner.setIncludes(includes);
        String[] excludes = null;
        if (resource.getExcludes() != null
                && !resource.getExcludes().isEmpty()) {
            excludes = (String[]) resource.getExcludes()
                    .toArray(new String[resource.getExcludes().size()]);
        }
        scanner.setExcludes(excludes);
        scanner.scan();
        for (String included : scanner.getIncludedFiles()) {
            getLog().debug("Found resource: " + included);
            resources.add(included);
        }
    }
    return allResources;
}
 
Example #29
Source File: LocalProject.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public Path getResourcesSourcesDir() {
    final List<Resource> resources = rawModel.getBuild() == null ? Collections.emptyList()
            : rawModel.getBuild().getResources();
    //todo: support multiple resources dirs for config hot deployment
    final String resourcesDir = resources.isEmpty() ? null : resources.get(0).getDirectory();
    return resolveRelativeToBaseDir(resourcesDir, "src/main/resources");
}
 
Example #30
Source File: BuildMojo.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static boolean hasSources(MavenProject project) {
    if (new File(project.getBuild().getSourceDirectory()).exists()) {
        return true;
    }
    for (Resource r : project.getBuild().getResources()) {
        if (new File(r.getDirectory()).exists()) {
            return true;
        }
    }
    return false;
}