Java Code Examples for org.gradle.api.internal.file.FileResolver

The following examples show how to use org.gradle.api.internal.file.FileResolver. 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
public DefaultGradle(Gradle parent, StartParameter startParameter, ServiceRegistryFactory parentRegistry) {
    this.parent = parent;
    this.startParameter = startParameter;
    this.services = parentRegistry.createFor(this);
    this.listenerManager = services.get(ListenerManager.class);
    taskGraph = services.get(TaskGraphExecuter.class);
    distributionLocator = services.get(GradleDistributionLocator.class);
    classLoaderScope = services.get(ClassLoaderScope.class);
    pluginContainer = services.get(PluginContainer.class);
    fileResolver = services.get(FileResolver.class);
    scriptPluginFactory = services.get(ScriptPluginFactory.class);
    scriptHandlerFactory = services.get(ScriptHandlerFactory.class);
    buildListenerBroadcast = listenerManager.createAnonymousBroadcaster(BuildListener.class);
    projectEvaluationListenerBroadcast = listenerManager.createAnonymousBroadcaster(ProjectEvaluationListener.class);
    buildListenerBroadcast.add(new BuildAdapter() {
        @Override
        public void projectsLoaded(Gradle gradle) {
            rootProjectActions.execute(rootProject);
            rootProjectActions = null;
        }
    });
}
 
Example 2
public Project createProject(String name, File inputProjectDir) {
    File projectDir = prepareProjectDir(inputProjectDir);

    final File homeDir = new File(projectDir, "gradleHome");

    StartParameter startParameter = new StartParameter();
    startParameter.setGradleUserHomeDir(new File(projectDir, "userHome"));

    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(GLOBAL_SERVICES, startParameter, homeDir);
    GradleInternal gradle = new DefaultGradle(null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));

    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(),
            topLevelRegistry.get(FileResolver.class));
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild();
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);

    gradle.setRootProject(project);
    gradle.setDefaultProject(project);

    return project;
}
 
Example 3
public Project createProject(String name, File inputProjectDir) {
    File projectDir = prepareProjectDir(inputProjectDir);

    final File homeDir = new File(projectDir, "gradleHome");

    StartParameter startParameter = new StartParameter();
    startParameter.setGradleUserHomeDir(new File(projectDir, "userHome"));

    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(GLOBAL_SERVICES, startParameter, homeDir);
    GradleInternal gradle = new DefaultGradle(null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));

    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(),
            topLevelRegistry.get(FileResolver.class));
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild();
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);

    gradle.setRootProject(project);
    gradle.setDefaultProject(project);

    return project;
}
 
Example 4
public GroovyLibraryProjectInitDescriptor(TemplateOperationFactory templateOperationFactory, final FileResolver fileResolver, TemplateLibraryVersionProvider libraryVersionProvider, TemplateOperation delegate) {
    super("groovy", templateOperationFactory, fileResolver);
    register(delegate);

    register(templateOperationFactory.newTemplateOperation()
            .withTemplate("groovylibrary/build.gradle.template")
            .withTarget("build.gradle")
            .withDocumentationBindings(GUtil.map("ref_userguide_groovy_tutorial", "tutorial_groovy_projects"))
            .withBindings(GUtil.map("groovyVersion", libraryVersionProvider.getVersion("groovy")))
            .withBindings(GUtil.map("junitVersion", libraryVersionProvider.getVersion("junit")))
            .create()
    );

    TemplateOperation groovyLibTemplateOperation = fromClazzTemplate("groovylibrary/Library.groovy.template", "main");
    TemplateOperation groovyTestTemplateOperation = fromClazzTemplate("groovylibrary/LibraryTest.groovy.template", "test");

    register(whenNoSourcesAvailable(groovyLibTemplateOperation, groovyTestTemplateOperation));
}
 
Example 5
Source Project: azure-gradle-plugins   Source File: RunTask.java    License: MIT License 6 votes vote down vote up
private void runCommand(final String[] command, final boolean showStdout, final List<Long> validReturnCodes,
                              final String errorMessage) throws Exception {
        getLogger().quiet("Executing command: " + StringUtils.join(command, " "));

        ExecAction action = new DefaultExecActionFactory(getServices().get(FileResolver.class)).newExecAction();
        action.setCommandLine(command);
        action.execute();
//        final ProcessBuilder.Redirect redirect = getStdoutRedirect(showStdout);
//        final Process process = new ProcessBuilder(command)
//                .redirectOutput(redirect)
//                .redirectErrorStream(true)
//                .start();
//
//        process.waitFor();
//
//        handleExitValue(process.exitValue(), validReturnCodes, errorMessage, process.getInputStream());
    }
 
Example 6
public DefaultManifest merge(Manifest baseManifest, FileResolver fileResolver) {
    DefaultManifest mergedManifest = new DefaultManifest(fileResolver);
    mergedManifest.getAttributes().putAll(baseManifest.getAttributes());
    mergedManifest.getSections().putAll(baseManifest.getSections());
    for (Object mergePath : mergePaths) {
        DefaultManifest manifestToMerge = createManifest(mergePath, fileResolver);
        mergedManifest = mergeManifest(mergedManifest, manifestToMerge, fileResolver);
    }
    return mergedManifest;
}
 
Example 7
public DefaultMavenPom(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMappings, PomDependenciesConverter pomDependenciesConverter,
                       FileResolver fileResolver) {
    this.configurations = configurationContainer;
    this.scopeMappings = scopeMappings;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
    mavenProject.setModelVersion("4.0.0");
}
 
Example 8
private <U extends LanguageSourceSet> void registerLanguageSourceSetFactory(final LanguageRegistration<U> languageRegistration, ProjectSourceSet sources, final FileResolver fileResolver) {
    sources.all(new Action<FunctionalSourceSet>() {
        public void execute(final FunctionalSourceSet functionalSourceSet) {
            NamedDomainObjectFactory<U> namedDomainObjectFactory = new NamedDomainObjectFactory<U>() {
                public U create(String name) {
                    Class<? extends U> sourceSetImplementation = languageRegistration.getSourceSetImplementation();
                    return instantiator.newInstance(sourceSetImplementation, name, functionalSourceSet, fileResolver);
                }
            };
            functionalSourceSet.registerFactory(languageRegistration.getSourceSetType(), namedDomainObjectFactory);
        }
    });
}
 
Example 9
public DefaultSourceSetOutput(String sourceSetDisplayName, FileResolver fileResolver, TaskResolver taskResolver) {
    this.fileResolver = fileResolver;
    String displayName = String.format("%s output", sourceSetDisplayName);
    outputDirectories = new DefaultConfigurableFileCollection(displayName, fileResolver, taskResolver, new Callable() {
        public Object call() throws Exception {
            return getClassesDir();
        }
    }, new Callable() {
        public Object call() throws Exception {
            return getResourcesDir();
        }
    });
    dirs = new DefaultConfigurableFileCollection("dirs", fileResolver, taskResolver);
}
 
Example 10
public AbstractGccCompatibleToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory, ToolSearchPath toolSearchPath) {
    super(name, operatingSystem, fileResolver);
    this.execActionFactory = execActionFactory;
    this.toolSearchPath = toolSearchPath;

    addPlatformConfiguration(new ToolChainDefaultArchitecture());
    addPlatformConfiguration(new Intel32Architecture());
    addPlatformConfiguration(new Intel64Architecture());
    configInsertLocation = 0;
}
 
Example 11
@Inject
public IvyPublishPlugin(Instantiator instantiator, DependencyMetaDataProvider dependencyMetaDataProvider, FileResolver fileResolver, ModelRules modelRules,
                        ProjectDependencyPublicationResolver projectDependencyResolver) {
    this.instantiator = instantiator;
    this.dependencyMetaDataProvider = dependencyMetaDataProvider;
    this.fileResolver = fileResolver;
    this.modelRules = modelRules;
    this.projectDependencyResolver = projectDependencyResolver;
}
 
Example 12
public DefaultProjectDescriptor(DefaultProjectDescriptor parent, String name, File dir,
                                ProjectDescriptorRegistry projectDescriptorRegistry, FileResolver fileResolver) {
    this.parent = parent;
    this.name = name;
    this.fileResolver = fileResolver;
    this.dir = GFileUtils.canonicalise(dir);
    this.projectDescriptorRegistry = projectDescriptorRegistry;
    this.path = path(name);
    projectDescriptorRegistry.addProject(this);
    if (parent != null) {
        parent.getChildren().add(this);
    }
}
 
Example 13
public DefaultScalaSourceSet(String displayName, FileResolver fileResolver) {
    scala = new DefaultSourceDirectorySet(String.format("%s Scala source", displayName), fileResolver);
    scala.getFilter().include("**/*.java", "**/*.scala");
    allScala = new DefaultSourceDirectorySet(String.format("%s Scala source", displayName), fileResolver);
    allScala.getFilter().include("**/*.scala");
    allScala.source(scala);
}
 
Example 14
@Inject
public MavenPublishPlugin(Instantiator instantiator, DependencyMetaDataProvider dependencyMetaDataProvider, FileResolver fileResolver,
                          ProjectDependencyPublicationResolver projectDependencyResolver) {
    this.instantiator = instantiator;
    this.dependencyMetaDataProvider = dependencyMetaDataProvider;
    this.fileResolver = fileResolver;
    this.projectDependencyResolver = projectDependencyResolver;
}
 
Example 15
@Model
public static VisualStudioExtensionInternal visualStudio(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    ProjectLocator projectLocator = serviceRegistry.get(ProjectLocator.class);
    FileResolver fileResolver = serviceRegistry.get(FileResolver.class);

    return instantiator.newInstance(DefaultVisualStudioExtension.class, instantiator, projectLocator, fileResolver);
}
 
Example 16
@Inject
public IvyPublishPlugin(Instantiator instantiator, DependencyMetaDataProvider dependencyMetaDataProvider, FileResolver fileResolver,
                        ProjectDependencyPublicationResolver projectDependencyResolver) {
    this.instantiator = instantiator;
    this.dependencyMetaDataProvider = dependencyMetaDataProvider;
    this.fileResolver = fileResolver;
    this.projectDependencyResolver = projectDependencyResolver;
}
 
Example 17
public DefaultCopySpec(FileResolver resolver, Instantiator instantiator, DefaultCopySpec parentSpec) {
    this.parentSpec = parentSpec;
    this.resolver = resolver;
    this.instantiator = instantiator;
    this.pathNotationParser = new PathNotationParser<String>();
    sourcePaths = new LinkedHashSet<Object>();
    childSpecs = new ArrayList<CopySpecInternal>();
    patternSet = new PatternSet();
    duplicatesStrategy = null; //inherit from parent
}
 
Example 18
@Mutate
public static void addGccToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) {
    final FileResolver fileResolver = serviceRegistry.get(FileResolver.class);
    final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class);
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    final CompilerMetaDataProviderFactory metaDataProviderFactory = serviceRegistry.get(CompilerMetaDataProviderFactory.class);

    toolChainRegistry.registerFactory(Gcc.class, new NamedDomainObjectFactory<Gcc>() {
        public Gcc create(String name) {
            return instantiator.newInstance(GccToolChain.class, instantiator, name, OperatingSystem.current(), fileResolver, execActionFactory, metaDataProviderFactory);
        }
    });
    toolChainRegistry.registerDefaultToolChain(GccToolChain.DEFAULT_NAME, Gcc.class);
}
 
Example 19
PluginResolutionServiceResolver createPluginResolutionServiceResolver(PluginResolutionServiceClient pluginResolutionServiceClient, Instantiator instantiator, VersionMatcher versionMatcher, StartParameter startParameter, final DependencyManagementServices dependencyManagementServices, final FileResolver fileResolver, final DependencyMetaDataProvider dependencyMetaDataProvider, ClassLoaderScopeRegistry classLoaderScopeRegistry) {
    final ProjectFinder projectFinder = new ProjectFinder() {
        public ProjectInternal getProject(String path) {
            throw new UnknownProjectException("Cannot use project dependencies in a plugin resolution definition.");
        }
    };

    return new PluginResolutionServiceResolver(pluginResolutionServiceClient, instantiator, versionMatcher, startParameter, classLoaderScopeRegistry.getCoreScope(), new Factory<DependencyResolutionServices>() {
        public DependencyResolutionServices create() {
            return dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, new BasicDomainObjectContext());
        }
    });
}
 
Example 20
public DefaultScalaSourceSet(String displayName, FileResolver fileResolver) {
    scala = new DefaultSourceDirectorySet(String.format("%s Scala source", displayName), fileResolver);
    scala.getFilter().include("**/*.java", "**/*.scala");
    allScala = new DefaultSourceDirectorySet(String.format("%s Scala source", displayName), fileResolver);
    allScala.getFilter().include("**/*.scala");
    allScala.source(scala);
}
 
Example 21
public ResolvedPattern(String rawPattern, FileResolver fileResolver) {
    // get rid of the ivy [] token, as [ ] are not valid URI characters
    int pos = rawPattern.indexOf('[');
    String basePath = pos < 0 ? rawPattern : rawPattern.substring(0, pos);
    this.baseUri = fileResolver.resolveUri(basePath);
    this.pattern = pos < 0 ? "" : rawPattern.substring(pos);
    scheme = baseUri.getScheme().toLowerCase();
    absolutePattern = constructAbsolutePattern(baseUri, pattern);
}
 
Example 22
public CompareGradleBuilds() {
    FileResolver fileResolver = getFileResolver();
    Instantiator instantiator = getInstantiator();
    sourceBuild = instantiator.newInstance(DefaultGradleBuildInvocationSpec.class, fileResolver, getProject().getRootDir());
    sourceBuild.setTasks(DEFAULT_TASKS);
    targetBuild = instantiator.newInstance(DefaultGradleBuildInvocationSpec.class, fileResolver, getProject().getRootDir());
    targetBuild.setTasks(DEFAULT_TASKS);

    // Never up to date
    getOutputs().upToDateWhen(new Spec<Task>() {
        public boolean isSatisfiedBy(Task element) {
            return false;
        }
    });
}
 
Example 23
public ClangToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory) {
    super(name, operatingSystem, fileResolver, execActionFactory, new ToolSearchPath(operatingSystem));

    registerTool(ToolType.CPP_COMPILER, "clang++");
    registerTool(ToolType.C_COMPILER, "clang");
    registerTool(ToolType.OBJECTIVECPP_COMPILER, "clang++");
    registerTool(ToolType.OBJECTIVEC_COMPILER, "clang");
    registerTool(ToolType.ASSEMBLER, "as");
    registerTool(ToolType.LINKER, "clang++");
    registerTool(ToolType.STATIC_LIB_ARCHIVER, "ar");
}
 
Example 24
public VisualCppToolChain(String name, OperatingSystem operatingSystem, FileResolver fileResolver, ExecActionFactory execActionFactory,
                          VisualStudioLocator visualStudioLocator, WindowsSdkLocator windowsSdkLocator) {
    super(name, operatingSystem, fileResolver);
    this.execActionFactory = execActionFactory;
    this.visualStudioLocator = visualStudioLocator;
    this.windowsSdkLocator = windowsSdkLocator;
}
 
Example 25
public DefaultObjectConfigurationAction(FileResolver resolver, ScriptPluginFactory configurerFactory, ScriptHandlerFactory scriptHandlerFactory, ClassLoaderScope classLoaderScope, Object... defaultTargets) {
    this.resolver = resolver;
    this.configurerFactory = configurerFactory;
    this.scriptHandlerFactory = scriptHandlerFactory;
    this.classLoaderScope = classLoaderScope;
    this.defaultTargets = defaultTargets;
}
 
Example 26
@Mutate
public static void addGccToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) {
    final FileResolver fileResolver = serviceRegistry.get(FileResolver.class);
    final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class);
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    final CompilerMetaDataProviderFactory metaDataProviderFactory = serviceRegistry.get(CompilerMetaDataProviderFactory.class);

    toolChainRegistry.registerFactory(Gcc.class, new NamedDomainObjectFactory<Gcc>() {
        public Gcc create(String name) {
            return instantiator.newInstance(GccToolChain.class, instantiator, name, OperatingSystem.current(), fileResolver, execActionFactory, metaDataProviderFactory);
        }
    });
    toolChainRegistry.registerDefaultToolChain(GccToolChain.DEFAULT_NAME, Gcc.class);
}
 
Example 27
public DefaultFlatDirArtifactRepository(FileResolver fileResolver,
                                        RepositoryTransportFactory transportFactory,
                                        LocallyAvailableResourceFinder<ModuleComponentArtifactMetaData> locallyAvailableResourceFinder,
                                        ResolverStrategy resolverStrategy,
                                        FileStore<ModuleComponentArtifactMetaData> artifactFileStore) {
    this.fileResolver = fileResolver;
    this.transportFactory = transportFactory;
    this.locallyAvailableResourceFinder = locallyAvailableResourceFinder;
    this.resolverStrategy = resolverStrategy;
    this.artifactFileStore = artifactFileStore;
}
 
Example 28
public SimpleGlobalFilesBuildSettingsDescriptor(TemplateOperationFactory templateOperationBuilder, FileResolver fileResolver) {
    register(templateOperationBuilder.newTemplateOperation()
                .withTemplate("settings.gradle.template")
                .withTarget("settings.gradle")
                .withDocumentationBindings(GUtil.map("ref_userguide_multiproject", "multi_project_builds"))
                .withBindings(GUtil.map("rootProjectName", fileResolver.resolve(".").getName()))
                .create()
    );
}
 
Example 29
@Inject
public GenerateMavenPom(FileResolver fileResolver) {
    this.fileResolver = fileResolver;

    // Never up to date; we don't understand the data structures.
    getOutputs().upToDateWhen(Specs.satisfyNone());
}
 
Example 30
@Inject
public GenerateIvyDescriptor(FileResolver fileResolver) {
    this.fileResolver = fileResolver;

    // Never up to date; we don't understand the data structures.
    getOutputs().upToDateWhen(Specs.satisfyNone());
}