Java Code Examples for org.codehaus.plexus.resource.loader.FileResourceLoader

The following examples show how to use org.codehaus.plexus.resource.loader.FileResourceLoader. These examples are extracted from open source projects. 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 Project: xml-maven-plugin   Source File: AbstractXmlMojo.java    License: Apache License 2.0 5 votes vote down vote up
protected ResourceManager getLocator()
{
    if ( !locatorInitialized )
    {
        locator.addSearchPath( FileResourceLoader.ID, getBasedir().getAbsolutePath() );
        locatorInitialized = true;
    }
    return locator;
}
 
Example 2
Source Project: xml-maven-plugin   Source File: AbstractXmlMojoTestCase.java    License: Apache License 2.0 5 votes vote down vote up
protected AbstractXmlMojo newMojo( String pDir )
        throws Exception
    {
        File testPom = new File( new File( getBasedir(), pDir ), "pom.xml" );
        
        MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
        ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
        ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
        MavenProject project = projectBuilder.build(testPom, buildingRequest).getProject();
//        final Build build = new Build();
//        build.setDirectory( "target" );
//        project.setBuild(build);
        project.getBuild().setDirectory("target");
        AbstractXmlMojo vm = (AbstractXmlMojo) lookupConfiguredMojo(project, getGoal());
        setVariableValueToObject( vm, "basedir", new File( getBasedir(), pDir ) );
        final Log log = new SilentLog();
        DefaultResourceManager rm = new DefaultResourceManager();
        setVariableValueToObject( rm, "logger", log );
        setVariableValueToObject( vm, "locator", rm );
        final Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>();
        resourceLoaders.put( "file", new FileResourceLoader() );
        resourceLoaders.put( "jar", new JarResourceLoader() );
        resourceLoaders.put( "classloader", new ThreadContextClasspathResourceLoader() );
        URLResourceLoader url = new URLResourceLoader();
        setVariableValueToObject( url, "logger", log );
        resourceLoaders.put( "url", url );
        setVariableValueToObject( rm, "resourceLoaders", resourceLoaders );

//        MavenProjectStub project = new MavenProjectStub()
//        {
//            public Build getBuild()
//            {
//                return build;
//            }
//        };
//        setVariableValueToObject( vm, "project", project );
        return vm;
    }
 
Example 3
protected void configureResourceManager() {
    rm.setOutputDirectory(new File(project.getBuild().getDirectory()));
    File dir = project.getFile().getParentFile();
    rm.addSearchPath(FileResourceLoader.ID, dir.getAbsolutePath());
    rm.addSearchPath("url", "");
}