@Override public void run(BuildAction action, BuildController buildController) { if (!(action instanceof TestExecutionRequestAction)) { return; } GradleInternal gradle = buildController.getGradle(); try { TestExecutionRequestAction testExecutionRequestAction = (TestExecutionRequestAction) action; TestExecutionResultEvaluator testExecutionResultEvaluator = new TestExecutionResultEvaluator(testExecutionRequestAction); buildController.addNestedListener(testExecutionResultEvaluator); doRun(testExecutionRequestAction, buildController); testExecutionResultEvaluator.evaluate(); } catch (RuntimeException rex) { Throwable throwable = findRootCause(rex); if (throwable instanceof TestExecutionException) { throw new InternalTestExecutionException("Error while running test(s)", throwable); } else { throw rex; } } PayloadSerializer payloadSerializer = gradle.getServices().get(PayloadSerializer.class); buildController.setResult(new BuildActionResult(payloadSerializer.serialize(null), null)); }
private ProjectInternal getTargetProject(Object target) { ProjectInternal project; if (target == null) { project = gradle.getDefaultProject(); } else if (target instanceof GradleProjectIdentity) { GradleProjectIdentity projectIdentity = (GradleProjectIdentity) target; GradleInternal build = findBuild(projectIdentity); project = findProject(build, projectIdentity); } else if (target instanceof GradleBuildIdentity) { GradleBuildIdentity buildIdentity = (GradleBuildIdentity) target; project = findBuild(buildIdentity).getDefaultProject(); } else { throw new IllegalArgumentException("Don't know how to build models for " + target); } return project; }
private List<Test> configureBuildForInternalJvmTestRequest(GradleInternal gradle, TestExecutionRequestAction testExecutionRequest) { final Collection<InternalJvmTestRequest> internalJvmTestRequests = testExecutionRequest.getInternalJvmTestRequests(); if(internalJvmTestRequests.isEmpty()){ return Collections.emptyList(); } List<Test> tasksToExecute = new ArrayList<Test>(); final Set<Project> allprojects = gradle.getRootProject().getAllprojects(); for (Project project : allprojects) { final Collection<Test> testTasks = project.getTasks().withType(Test.class); for (Test testTask : testTasks) { for (InternalJvmTestRequest jvmTestRequest : internalJvmTestRequests) { final TestFilter filter = testTask.getFilter(); filter.includeTest(jvmTestRequest.getClassName(), jvmTestRequest.getMethodName()); } } tasksToExecute.addAll(testTasks); } return tasksToExecute; }
private void registerListenersForClientSubscriptions(BuildClientSubscriptions clientSubscriptions, GradleInternal gradle, BuildController buildController) { BuildEventConsumer eventConsumer = gradle.getServices().get(BuildEventConsumer.class); if (clientSubscriptions.isSendTestProgressEvents()) { buildController.addNestedListener(new ClientForwardingTestListener(eventConsumer, clientSubscriptions)); } if (!clientSubscriptions.isSendBuildProgressEvents() && !clientSubscriptions.isSendTaskProgressEvents()) { return; } InternalBuildListener buildListener = NO_OP; if (clientSubscriptions.isSendBuildProgressEvents()) { buildListener = new ClientForwardingBuildListener(eventConsumer); } buildListener = new ClientForwardingTaskListener(eventConsumer, clientSubscriptions, buildListener); buildController.addNestedListener(buildListener); }
@Override public void run(BuildAction action, final BuildController buildController) { if (!(action instanceof ClientProvidedBuildAction)) { return; } final GradleInternal gradle = buildController.getGradle(); ClientProvidedBuildAction clientProvidedBuildAction = (ClientProvidedBuildAction) action; PayloadSerializer payloadSerializer = getPayloadSerializer(gradle); final InternalBuildAction<?> clientAction = (InternalBuildAction<?>) payloadSerializer.deserialize(clientProvidedBuildAction.getAction()); gradle.addBuildListener(new BuildAdapter() { @Override public void buildFinished(BuildResult result) { if (result.getFailure() == null) { buildController.setResult(buildResult(clientAction, gradle)); } } }); buildController.configure(); }
@Override public void run(BuildAction action, final BuildController buildController) { if (!(action instanceof BuildModelAction)) { return; } final BuildModelAction buildModelAction = (BuildModelAction) action; final GradleInternal gradle = buildController.getGradle(); gradle.addBuildListener(new BuildResultAdapter(gradle, buildController, buildModelAction)); if (buildModelAction.isRunTasks()) { buildController.run(); } else { buildController.configure(); } }
public Project createProject(String name, File inputProjectDir, File gradleUserHomeDir) { File projectDir = prepareProjectDir(inputProjectDir); final File homeDir = new File(projectDir, "gradleHome"); StartParameter startParameter = new StartParameter(); File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir); startParameter.setGradleUserHomeDir(userHomeDir); NativeServices.initialize(userHomeDir); ServiceRegistry topLevelRegistry = new TestBuildScopeServices(getUserHomeServices(userHomeDir), startParameter, homeDir); GradleInternal gradle = CLASS_GENERATOR.newInstance(DefaultGradle.class, 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("root-project"); ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope); gradle.setRootProject(project); gradle.setDefaultProject(project); return project; }
public DefaultProject createProject(ProjectDescriptor projectDescriptor, ProjectInternal parent, GradleInternal gradle, ClassLoaderScope selfClassLoaderScope, ClassLoaderScope baseClassLoaderScope) { File buildFile = projectDescriptor.getBuildFile(); ScriptSource source = UriScriptSource.file("build file", buildFile); DefaultProject project = instantiator.newInstance(DefaultProject.class, projectDescriptor.getName(), parent, projectDescriptor.getProjectDir(), source, gradle, gradle.getServiceRegistryFactory(), selfClassLoaderScope, baseClassLoaderScope ); if (parent != null) { parent.addChildProject(project); } projectRegistry.addProject(project); return project; }
@Override public SettingsInternal findAndLoadSettings(GradleInternal gradle) { StartParameter startParameter = gradle.getStartParameter(); SettingsInternal settings = findSettingsAndLoadIfAppropriate(gradle, startParameter); ProjectSpec spec = ProjectSpecs.forStartParameter(startParameter, settings); if (spec.containsProject(settings.getProjectRegistry())) { setDefaultProject(spec, settings); return settings; } // Try again with empty settings StartParameter noSearchParameter = startParameter.newInstance(); noSearchParameter.useEmptySettings(); settings = findSettingsAndLoadIfAppropriate(gradle, noSearchParameter); // Set explicit build file, if required if (noSearchParameter.getBuildFile() != null) { ProjectDescriptor rootProject = settings.getRootProject(); rootProject.setBuildFileName(noSearchParameter.getBuildFile().getName()); } setDefaultProject(spec, settings); return settings; }
public DefaultGradleLauncher(GradleInternal gradle, InitScriptHandler initScriptHandler, SettingsLoader settingsLoader, BuildConfigurer buildConfigurer, ExceptionAnalyser exceptionAnalyser, LoggingManagerInternal loggingManager, BuildListener buildListener, ModelConfigurationListener modelConfigurationListener, BuildCompletionListener buildCompletionListener, BuildOperationExecutor operationExecutor, BuildConfigurationActionExecuter buildConfigurationActionExecuter, BuildExecuter buildExecuter, BuildScopeServices buildServices, ListenerManager globalListenerManager, List<?> servicesToStop) { this.gradle = gradle; this.initScriptHandler = initScriptHandler; this.settingsLoader = settingsLoader; this.buildConfigurer = buildConfigurer; this.exceptionAnalyser = exceptionAnalyser; this.buildListener = buildListener; this.loggingManager = loggingManager; this.modelConfigurationListener = modelConfigurationListener; this.buildOperationExecutor = operationExecutor; this.buildConfigurationActionExecuter = buildConfigurationActionExecuter; this.buildExecuter = buildExecuter; this.buildCompletionListener = buildCompletionListener; this.buildServices = buildServices; this.globalListenerManager = globalListenerManager; this.servicesToStop = servicesToStop; loggingManager.start(); }
public void executeScripts(final GradleInternal gradle) { final List<File> initScripts = gradle.getStartParameter().getAllInitScripts(); if (initScripts.isEmpty()) { return; } BuildOperationDetails operationDetails = BuildOperationDetails.displayName("Run init scripts").progressDisplayName("init scripts").build(); buildOperationExecutor.run(operationDetails, new Action<BuildOperationContext>() { @Override public void execute(BuildOperationContext buildOperationContext) { for (File script : initScripts) { processor.process(new UriScriptSource("initialization script", script), gradle); } } }); }
@Override public SettingsInternal findAndLoadSettings(GradleInternal gradle) { SettingsInternal settings = delegate.findAndLoadSettings(gradle); Collection<IncludedBuild> includedBuilds = getIncludedBuilds(gradle.getStartParameter(), settings); if (!includedBuilds.isEmpty()) { gradle.setIncludedBuilds(includedBuilds); if (gradle.getStartParameter().isContinuous()) { LOGGER.warn("[composite-build] Warning: continuous build doesn't detect changes in included builds."); } CompositeContextBuilder compositeContextBuilder = buildServices.get(CompositeContextBuilder.class); compositeContextBuilder.addToCompositeContext(includedBuilds); } return settings; }
private ScriptTarget wrap(Object target, boolean isInitialPass) { if (target instanceof ProjectInternal && topLevelScript) { // Only use this for top level project scripts return new ProjectScriptTarget((ProjectInternal) target); } if (target instanceof GradleInternal && topLevelScript) { // Only use this for top level init scripts return new InitScriptTarget((GradleInternal) target); } if (target instanceof SettingsInternal && topLevelScript) { // Only use this for top level settings scripts if (isInitialPass) { return new InitialPassSettingScriptTarget((SettingsInternal) target); } else { return new SettingScriptTarget((SettingsInternal) target); } } else { return new DefaultScriptTarget(target); } }
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; }
public BaseSettings(ServiceRegistryFactory serviceRegistryFactory, GradleInternal gradle, ClassLoaderScope classLoaderScope, ClassLoaderScope rootClassLoaderScope, File settingsDir, ScriptSource settingsScript, StartParameter startParameter) { this.gradle = gradle; this.rootClassLoaderScope = rootClassLoaderScope; this.settingsDir = settingsDir; this.settingsScript = settingsScript; this.startParameter = startParameter; this.classLoaderScope = classLoaderScope; ServiceRegistry services = serviceRegistryFactory.createFor(this); this.plugins = services.get(PluginContainer.class); this.fileResolver = services.get(FileResolver.class); this.scriptPluginFactory = services.get(ScriptPluginFactory.class); this.scriptHandlerFactory = services.get(ScriptHandlerFactory.class); this.projectDescriptorRegistry = services.get(ProjectDescriptorRegistry.class); rootProjectDescriptor = createProjectDescriptor(null, settingsDir.getName(), settingsDir); }
public SettingsInternal findAndLoadSettings(GradleInternal gradle) { StartParameter startParameter = gradle.getStartParameter(); SettingsInternal settings = findSettingsAndLoadIfAppropriate(gradle, startParameter); ProjectSpec spec = ProjectSpecs.forStartParameter(startParameter, settings); if (spec.containsProject(settings.getProjectRegistry())) { setDefaultProject(spec, settings); return settings; } // Try again with empty settings StartParameter noSearchParameter = startParameter.newInstance(); noSearchParameter.useEmptySettings(); settings = findSettingsAndLoadIfAppropriate(gradle, noSearchParameter); // Set explicit build file, if required if (noSearchParameter.getBuildFile() != null) { ProjectDescriptor rootProject = settings.getRootProject(); rootProject.setBuildFileName(noSearchParameter.getBuildFile().getName()); } setDefaultProject(spec, settings); return settings; }
public void configure(BuildExecutionContext context) { GradleInternal gradle = context.getGradle(); Set<String> excludedTaskNames = gradle.getStartParameter().getExcludedTaskNames(); if (!excludedTaskNames.isEmpty()) { TaskSelector selector = gradle.getServices().get(TaskSelector.class); final Set<Task> excludedTasks = new HashSet<Task>(); for (String taskName : excludedTaskNames) { excludedTasks.addAll(selector.getSelection(taskName).getTasks()); } gradle.getTaskGraph().useFilter(new Spec<Task>() { public boolean isSatisfiedBy(Task task) { return !excludedTasks.contains(task); } }); } context.proceed(); }
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)); ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, gradle.getClassLoaderScope().createSibling()); gradle.setRootProject(project); gradle.setDefaultProject(project); return project; }
public DefaultProject createProject(ProjectDescriptor projectDescriptor, ProjectInternal parent, GradleInternal gradle, ClassLoaderScope classLoaderScope) { File buildFile = projectDescriptor.getBuildFile(); ScriptSource source; if (!buildFile.exists()) { source = new StringScriptSource("empty build file", ""); } else { source = new UriScriptSource("build file", buildFile); } DefaultProject project = instantiator.newInstance(DefaultProject.class, projectDescriptor.getName(), parent, projectDescriptor.getProjectDir(), source, gradle, gradle.getServiceRegistryFactory(), classLoaderScope ); if (parent != null) { parent.addChildProject(project); } projectRegistry.addProject(project); return project; }
public BaseSettings(ServiceRegistryFactory serviceRegistryFactory, GradleInternal gradle, ClassLoaderScope classLoaderScope, File settingsDir, ScriptSource settingsScript, StartParameter startParameter) { this.gradle = gradle; this.settingsDir = settingsDir; this.settingsScript = settingsScript; this.startParameter = startParameter; this.classLoaderScope = classLoaderScope; ServiceRegistry services = serviceRegistryFactory.createFor(this); this.plugins = services.get(PluginContainer.class); this.fileResolver = services.get(FileResolver.class); this.scriptPluginFactory = services.get(ScriptPluginFactory.class); this.scriptHandlerFactory = services.get(ScriptHandlerFactory.class); this.projectDescriptorRegistry = services.get(ProjectDescriptorRegistry.class); rootProjectDescriptor = createProjectDescriptor(null, settingsDir.getName(), settingsDir); }
/** * Creates a new instance. Don't call this directly, use {@link #newInstance(org.gradle.StartParameter)} or {@link * #newInstance(String...)} instead. */ public DefaultGradleLauncher(GradleInternal gradle, InitScriptHandler initScriptHandler, SettingsHandler settingsHandler, BuildLoader buildLoader, BuildConfigurer buildConfigurer, BuildListener buildListener, ExceptionAnalyser exceptionAnalyser, LoggingManagerInternal loggingManager, ModelConfigurationListener modelConfigurationListener, TasksCompletionListener tasksCompletionListener, BuildExecuter buildExecuter) { this.gradle = gradle; this.initScriptHandler = initScriptHandler; this.settingsHandler = settingsHandler; this.buildLoader = buildLoader; this.buildConfigurer = buildConfigurer; this.exceptionAnalyser = exceptionAnalyser; this.buildListener = buildListener; this.loggingManager = loggingManager; this.modelConfigurationListener = modelConfigurationListener; this.tasksCompletionListener = tasksCompletionListener; this.buildExecuter = buildExecuter; }
public GradleInternal run() { try { return (GradleInternal) getLauncher().run().getGradle(); } finally { state = State.Completed; } }
public GradleInternal configure() { try { return (GradleInternal) getLauncher().getBuildAnalysis().getGradle(); } finally { state = State.Completed; } }
private GradleInternal findBuild(GradleBuildIdentity buildIdentity) { GradleInternal build = findBuild(gradle, buildIdentity); if (build != null) { return build; } else { throw new IllegalArgumentException(buildIdentity.getRootDir() + " is not included in this build"); } }
private GradleInternal findBuild(GradleInternal rootBuild, GradleBuildIdentity buildIdentity) { if (rootBuild.getRootProject().getProjectDir().equals(buildIdentity.getRootDir())) { return rootBuild; } for (IncludedBuild includedBuild : rootBuild.getIncludedBuilds()) { GradleInternal matchingBuild = findBuild(((IncludedBuildInternal) includedBuild).getConfiguredBuild(), buildIdentity); if (matchingBuild != null) { return matchingBuild; } } return null; }
@Override public void configure(BuildExecutionContext context) { final Set<Test> allTestTasksToRun = new LinkedHashSet<Test>(); final GradleInternal gradleInternal = context.getGradle(); allTestTasksToRun.addAll(configureBuildForTestDescriptors(gradleInternal, testExecutionRequest)); allTestTasksToRun.addAll(configureBuildForInternalJvmTestRequest(gradleInternal, testExecutionRequest)); configureTestTasks(allTestTasksToRun); gradle.getTaskGraph().addTasks(allTestTasksToRun); }
@Override public void run(BuildAction action, BuildController buildController) { if (!(action instanceof SubscribableBuildAction)) { return; } GradleInternal gradle = buildController.getGradle(); SubscribableBuildAction subscribableBuildAction = (SubscribableBuildAction) action; // register listeners that dispatch all progress via the registered BuildEventConsumer instance, // this allows to send progress events back to the DaemonClient (via short-cut) registerListenersForClientSubscriptions(subscribableBuildAction.getClientSubscriptions(), gradle, buildController); delegate.run(action, buildController); }
private static BuildActionResult buildResult(GradleInternal gradle, BuildModelAction buildModelAction) { PayloadSerializer serializer = gradle.getServices().get(PayloadSerializer.class); try { Object model = buildModel(gradle, buildModelAction); return new BuildActionResult(serializer.serialize(model), null); } catch (RuntimeException e) { return new BuildActionResult(null, serializer.serialize(e)); } }
private static Object buildModel(GradleInternal gradle, BuildModelAction buildModelAction) { if (!buildModelAction.isRunTasks()) { forceFullConfiguration(gradle); } String modelName = buildModelAction.getModelName(); ToolingModelBuilder builder = getModelBuilder(gradle, modelName); return builder.buildAll(modelName, gradle.getDefaultProject()); }
private static ToolingModelBuilder getModelBuilder(GradleInternal gradle, String modelName) { ToolingModelBuilderRegistry builderRegistry = getToolingModelBuilderRegistry(gradle); try { return builderRegistry.getBuilder(modelName); } catch (UnknownModelException e) { throw (InternalUnsupportedModelException) new InternalUnsupportedModelException().initCause(e); } }
/** * <p>Called when the build is completed. All selected tasks have been executed.</p> * * @param buildResult The result of the build. Never null. */ @Override public void buildFinished(BuildResult buildResult) { boolean wasSuccessful = buildResult.getFailure() == null; String output = allOutputText.toString(); if (!wasSuccessful) //if we fail, send the results, otherwise, we'll send the projects. { //we can't send the exception itself because it might not be serializable (it can include anything from anywhere inside gradle //or one of its dependencies). So format it as text. String details = GradlePluginLord.getGradleExceptionMessage(buildResult.getFailure(), gradle.getStartParameter().getShowStacktrace()); output += details; client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_WITH_ERRORS_TYPE, output, wasSuccessful); } else { ProjectConverter buildExecuter = new ProjectConverter(((GradleInternal) buildResult.getGradle()).getServices().get(ProjectTaskLister.class)); List<ProjectView> projects = new ArrayList<ProjectView>(); projects.addAll(buildExecuter.convertProjects(buildResult.getGradle().getRootProject())); client.sendMessage(ProtocolConstants.TASK_LIST_COMPLETED_SUCCESSFULLY_TYPE, output, (Serializable) projects); } //tell the server we're going to exit. client.sendMessage(ProtocolConstants.EXITING, null, null); client.stop(); }
@Override public GradleInternal getConfiguredBuild() { if (gradle == null) { GradleLauncher gradleLauncher = getGradleLauncher(); gradleLauncher.getBuildAnalysis(); settings = gradleLauncher.getSettings(); gradle = gradleLauncher.getGradle(); } return gradle; }
@Override public SettingsInternal process(final GradleInternal gradle, final SettingsLocation settingsLocation, final ClassLoaderScope buildRootClassLoaderScope, final StartParameter startParameter) { BuildOperationDetails operationDetails = BuildOperationDetails.displayName("Configure settings").progressDisplayName("settings").build(); return buildOperationExecutor.run(operationDetails, new Transformer<SettingsInternal, BuildOperationContext>() { @Override public SettingsInternal transform(BuildOperationContext buildOperationContext) { return settingsProcessor.process(gradle, settingsLocation, buildRootClassLoaderScope, startParameter); } }); }
public DefaultSettings(ServiceRegistryFactory serviceRegistryFactory, GradleInternal gradle, ClassLoaderScope settingsClassLoaderScope, ClassLoaderScope buildRootClassLoaderScope, File settingsDir, ScriptSource settingsScript, StartParameter startParameter) { this.gradle = gradle; this.buildRootClassLoaderScope = buildRootClassLoaderScope; this.settingsDir = settingsDir; this.settingsScript = settingsScript; this.startParameter = startParameter; this.settingsClassLoaderScope = settingsClassLoaderScope; services = serviceRegistryFactory.createFor(this); rootProjectDescriptor = createProjectDescriptor(null, settingsDir.getName(), settingsDir); }
public SettingsInternal process(GradleInternal gradle, SettingsLocation settingsLocation, ClassLoaderScope buildRootClassLoaderScope, StartParameter startParameter) { propertiesLoader.loadProperties(settingsLocation.getSettingsDir()); return processor.process(gradle, settingsLocation, buildRootClassLoaderScope, startParameter); }
@Override public SettingsInternal findAndLoadSettings(GradleInternal gradle) { SettingsInternal settings = settingsLoader.findAndLoadSettings(gradle); gradle.getBuildListenerBroadcaster().settingsEvaluated(settings); buildLoader.load(settings.getRootProject(), settings.getDefaultProject(), gradle, settings.getRootClassLoaderScope()); gradle.getBuildListenerBroadcaster().projectsLoaded(gradle); return settings; }
/** * Finds the settings.gradle for the given startParameter, and loads it if contains the project selected by the * startParameter, or if the startParameter explicitly specifies a settings script. If the settings file is not * loaded (executed), then a null is returned. */ private SettingsInternal findSettingsAndLoadIfAppropriate(GradleInternal gradle, StartParameter startParameter) { SettingsLocation settingsLocation = findSettings(startParameter); // We found the desired settings file, now build the associated buildSrc before loading settings. This allows // the settings script to reference classes in the buildSrc. StartParameter buildSrcStartParameter = startParameter.newBuild(); buildSrcStartParameter.setCurrentDir(new File(settingsLocation.getSettingsDir(), DefaultSettings.DEFAULT_BUILD_SRC_DIR)); ClassLoaderScope buildSourceClassLoaderScope = buildSourceBuilder.buildAndCreateClassLoader(buildSrcStartParameter); return settingsProcessor.process(gradle, settingsLocation, buildSourceClassLoaderScope, startParameter); }
private GradleLauncher buildGradleLauncher(StartParameter startParameter) { StartParameter startParameterArg = startParameter.newInstance(); startParameterArg.setProjectProperties(startParameter.getProjectProperties()); startParameterArg.setSearchUpwards(false); startParameterArg.setProfile(startParameter.isProfile()); GradleLauncher gradleLauncher = nestedBuildFactory.nestedInstance(startParameterArg); GradleInternal build = gradleLauncher.getGradle(); if (build.getParent().findIdentityPath() == null) { // When nested inside a nested build, we need to synthesize a path for this build, as the root project is not yet known for the parent build // Use the directory structure to do this. This means that the buildSrc build and its containing build may end up with different paths Path path = build.getParent().getParent().getIdentityPath().child(startParameter.getCurrentDir().getParentFile().getName()).child(startParameter.getCurrentDir().getName()); build.setIdentityPath(path); } return gradleLauncher; }
public SettingsInternal createSettings(GradleInternal gradle, File settingsDir, ScriptSource settingsScript, Map<String, String> gradleProperties, StartParameter startParameter, ClassLoaderScope buildRootClassLoaderScope) { DefaultSettings settings = instantiator.newInstance(DefaultSettings.class, serviceRegistryFactory, gradle, buildRootClassLoaderScope.createChild("settings"), buildRootClassLoaderScope, settingsDir, settingsScript, startParameter ); DynamicObject dynamicObject = ((DynamicObjectAware) settings).getAsDynamicObject(); ((ExtensibleDynamicObject) dynamicObject).addProperties(gradleProperties); return settings; }
public SettingsInternal process(GradleInternal gradle, SettingsLocation settingsLocation, ClassLoaderScope buildRootClassLoaderScope, StartParameter startParameter) { Timer settingsProcessingClock = Timers.startTimer(); Map<String, String> properties = propertiesLoader.mergeProperties(Collections.<String, String>emptyMap()); SettingsInternal settings = settingsFactory.createSettings(gradle, settingsLocation.getSettingsDir(), settingsLocation.getSettingsScriptSource(), properties, startParameter, buildRootClassLoaderScope); applySettingsScript(settingsLocation, settings); LOGGER.debug("Timing: Processing settings took: {}", settingsProcessingClock.getElapsed()); return settings; }