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

The following examples show how to use org.gradle.api.internal.file.FileResolver. 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: RunTask.java    From azure-gradle-plugins with 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 #2
Source File: ProjectBuilderImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: DefaultGradle.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: ProjectBuilderImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: GroovyLibraryProjectInitDescriptor.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #6
Source File: DefaultManifestMergeSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultMavenPom.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: ComponentModelBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultScalaSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #10
Source File: MavenPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Inject
public MavenPublishPlugin(Instantiator instantiator, DependencyMetaDataProvider dependencyMetaDataProvider, FileResolver fileResolver,
                          ProjectDependencyPublicationResolver projectDependencyResolver) {
    this.instantiator = instantiator;
    this.dependencyMetaDataProvider = dependencyMetaDataProvider;
    this.fileResolver = fileResolver;
    this.projectDependencyResolver = projectDependencyResolver;
}
 
Example #11
Source File: DefaultSourceSetOutput.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #12
Source File: DefaultProjectDescriptor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: GccCompilerPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #14
Source File: VisualStudioPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #15
Source File: IvyPublishPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Inject
public IvyPublishPlugin(Instantiator instantiator, DependencyMetaDataProvider dependencyMetaDataProvider, FileResolver fileResolver,
                        ProjectDependencyPublicationResolver projectDependencyResolver) {
    this.instantiator = instantiator;
    this.dependencyMetaDataProvider = dependencyMetaDataProvider;
    this.fileResolver = fileResolver;
    this.projectDependencyResolver = projectDependencyResolver;
}
 
Example #16
Source File: DefaultCopySpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #17
Source File: IvyPublishPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #18
Source File: PluginUsePluginServiceRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #19
Source File: DefaultScalaSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #20
Source File: ResolvedPattern.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #21
Source File: CompareGradleBuilds.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #22
Source File: ClangToolChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #23
Source File: VisualCppToolChain.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #24
Source File: DefaultObjectConfigurationAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #25
Source File: GccCompilerPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #26
Source File: DefaultFlatDirArtifactRepository.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #27
Source File: SimpleGlobalFilesBuildSettingsDescriptor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #28
Source File: GenerateMavenPom.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Inject
public GenerateMavenPom(FileResolver fileResolver) {
    this.fileResolver = fileResolver;

    // Never up to date; we don't understand the data structures.
    getOutputs().upToDateWhen(Specs.satisfyNone());
}
 
Example #29
Source File: GenerateIvyDescriptor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Inject
public GenerateIvyDescriptor(FileResolver fileResolver) {
    this.fileResolver = fileResolver;

    // Never up to date; we don't understand the data structures.
    getOutputs().upToDateWhen(Specs.satisfyNone());
}
 
Example #30
Source File: JvmOptions.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JvmOptions(FileResolver resolver) {
    this.bootstrapClasspath = new DefaultConfigurableFileCollection(resolver, null);
    immutableSystemProperties.put(FILE_ENCODING_KEY, Charset.defaultCharset().name());
    immutableSystemProperties.put(USER_LANGUAGE_KEY, DEFAULT_LOCALE.getLanguage());
    immutableSystemProperties.put(USER_COUNTRY_KEY, DEFAULT_LOCALE.getCountry());
    immutableSystemProperties.put(USER_VARIANT_KEY, DEFAULT_LOCALE.getVariant());
}