Пример #1
0
  /**
   * Creates the project.
   *
   * @return The project
   */
  public Project build() {
    if (projectDir == null) {
      try {
        projectDir = GFileUtils.canonicalise(File.createTempFile("gradle", "projectDir"));
        projectDir.delete();
        projectDir.mkdir();
        projectDir.deleteOnExit();
      } catch (IOException e) {
        throw new UncheckedIOException(e);
      }
    }

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

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

    ServiceRegistryFactory topLevelRegistry =
        new TestTopLevelBuildServiceRegistry(startParameter, homeDir);
    GradleInternal gradle = new DefaultGradle(null, startParameter, topLevelRegistry);

    DefaultProjectDescriptor projectDescriptor =
        new DefaultProjectDescriptor(
            null, "test", projectDir, new DefaultProjectDescriptorRegistry());
    ProjectInternal project =
        topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle);

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

    return project;
  }
 protected CacheRepository createCacheRepository() {
   CacheFactory factory = get(CacheFactory.class);
   return new DefaultCacheRepository(
       startParameter.getGradleUserHomeDir(),
       startParameter.getProjectCacheDir(),
       startParameter.getCacheUsage(),
       factory);
 }
 private DaemonParameters constructDaemonParameters(StartParameter startParameter) {
   Map<String, String> mergedSystemProperties = startParameter.getMergedSystemProperties();
   DaemonParameters daemonParameters = new DaemonParameters();
   daemonParameters.configureFromBuildDir(
       startParameter.getCurrentDir(), startParameter.isSearchUpwards());
   daemonParameters.configureFromGradleUserHome(startParameter.getGradleUserHomeDir());
   daemonParameters.configureFromSystemProperties(mergedSystemProperties);
   return daemonParameters;
 }
  @Override
  public void apply(Project project) {
    String appDescription = null;
    String appTitle = null;
    String appVersion = null;

    File appBndFile = project.file("app.bnd");

    if (appBndFile.exists()) {
      Properties properties = GUtil.loadProperties(appBndFile);

      appDescription = properties.getProperty("Liferay-Releng-App-Description");
    }

    Properties appProperties = null;

    Project privateProject = project.findProject(":private" + project.getPath());

    if (privateProject != null) {
      appProperties = _getAppProperties(privateProject);
    }

    if (appProperties == null) {
      appProperties = _getAppProperties(project);
    }

    if (appProperties != null) {
      appTitle = appProperties.getProperty("app.marketplace.title");
      appVersion = appProperties.getProperty("app.marketplace.version");
    }

    _applyPlugins(project);

    LiferayOSGiDefaultsPlugin.configureRepositories(project);

    _configureAppJavadocBuilder(project, privateProject);
    _configureAppTLDDocBuilder(project, privateProject);
    _configureProject(project, appDescription, appVersion);
    _configureTaskAppJavadoc(project, appTitle, appVersion);

    if (privateProject != null) {
      Gradle gradle = project.getGradle();

      StartParameter startParameter = gradle.getStartParameter();

      List<String> taskNames = startParameter.getTaskNames();

      if (taskNames.contains(AppJavadocBuilderPlugin.APP_JAVADOC_TASK_NAME)
          || taskNames.contains(AppJavadocBuilderPlugin.JAR_APP_JAVADOC_TASK_NAME)
          || taskNames.contains(AppTLDDocBuilderPlugin.APP_TLDDOC_TASK_NAME)
          || taskNames.contains(AppTLDDocBuilderPlugin.JAR_APP_TLDDOC_TASK_NAME)) {

        _forceProjectHierarchyEvaluation(privateProject);
      }
    }
  }
Пример #5
0
 TaskPlanExecutor createTaskExecutorFactory(
     StartParameter startParameter,
     ExecutorFactory executorFactory,
     BuildOperationWorkerRegistry buildOperationWorkerRegistry) {
   int parallelThreads =
       startParameter.isParallelProjectExecutionEnabled() ? startParameter.getMaxWorkerCount() : 1;
   return new TaskPlanExecutorFactory(
           parallelThreads, executorFactory, buildOperationWorkerRegistry)
       .create();
 }
 WorkerProcessFactory createWorkerProcessFactory(
     StartParameter startParameter,
     MessagingServer messagingServer,
     ClassPathRegistry classPathRegistry,
     TemporaryFileProvider temporaryFileProvider,
     ExecHandleFactory execHandleFactory) {
   return new DefaultWorkerProcessFactory(
       startParameter.getLogLevel(),
       messagingServer,
       classPathRegistry,
       new LongIdGenerator(),
       startParameter.getGradleUserHomeDir(),
       temporaryFileProvider,
       execHandleFactory);
 }
Пример #7
0
 BuildOperationProcessor createBuildOperationProcessor(
     StartParameter startParameter, ExecutorFactory executorFactory) {
   return new DefaultBuildOperationProcessor(
       new DefaultBuildOperationQueueFactory(),
       executorFactory,
       startParameter.getMaxWorkerCount());
 }
 protected void checkConversion(String... args) {
   actualStartParameter = new StartParameter();
   actualStartParameter.setCurrentDir(currentDir);
   commandLineConverter.convert(Arrays.asList(args), actualStartParameter);
   // We check the params passed to the build factory
   checkStartParameter(actualStartParameter);
 }
  @Test
  public void withSpecifiedSettingsFileName() throws IOException {
    File expectedSettingsFile = currentDir.file("somesettings");
    expectedProjectDir = expectedSettingsFile.getParentFile();

    checkConversion("-c", "somesettings");

    assertThat(actualStartParameter.getSettingsFile(), equalTo(expectedSettingsFile));
  }
 protected Factory<WorkerProcessBuilder> createWorkerProcessFactory() {
   ClassPathRegistry classPathRegistry = get(ClassPathRegistry.class);
   return new DefaultWorkerProcessFactory(
       startParameter.getLogLevel(),
       get(MessagingServer.class),
       classPathRegistry,
       new IdentityFileResolver(),
       new LongIdGenerator());
 }
 public void addResolutionRules(ResolutionRules resolutionRules) {
   if (startParameter.isOffline()) {
     resolutionRules.eachDependency(
         new Action<DependencyResolutionControl>() {
           public void execute(DependencyResolutionControl dependencyResolutionControl) {
             dependencyResolutionControl.useCachedResult();
           }
         });
     resolutionRules.eachModule(
         new Action<ModuleResolutionControl>() {
           public void execute(ModuleResolutionControl moduleResolutionControl) {
             moduleResolutionControl.useCachedResult();
           }
         });
     resolutionRules.eachArtifact(
         new Action<ArtifactResolutionControl>() {
           public void execute(ArtifactResolutionControl artifactResolutionControl) {
             artifactResolutionControl.useCachedResult();
           }
         });
   } else if (startParameter.isRefreshDependencies()) {
     resolutionRules.eachDependency(
         new Action<DependencyResolutionControl>() {
           public void execute(DependencyResolutionControl dependencyResolutionControl) {
             dependencyResolutionControl.cacheFor(0, TimeUnit.SECONDS);
           }
         });
     resolutionRules.eachModule(
         new Action<ModuleResolutionControl>() {
           public void execute(ModuleResolutionControl moduleResolutionControl) {
             moduleResolutionControl.cacheFor(0, TimeUnit.SECONDS);
           }
         });
     resolutionRules.eachArtifact(
         new Action<ArtifactResolutionControl>() {
           public void execute(ArtifactResolutionControl artifactResolutionControl) {
             artifactResolutionControl.cacheFor(0, TimeUnit.SECONDS);
           }
         });
   }
 }
 public BuildSessionScopeServices(
     final ServiceRegistry parent,
     final StartParameter startParameter,
     ClassPath injectedPluginClassPath) {
   super(parent);
   register(
       new Action<ServiceRegistration>() {
         @Override
         public void execute(ServiceRegistration registration) {
           add(StartParameter.class, startParameter);
           for (PluginServiceRegistry pluginServiceRegistry :
               parent.getAll(PluginServiceRegistry.class)) {
             pluginServiceRegistry.registerBuildSessionServices(registration);
           }
         }
       });
   add(InjectedPluginClasspath.class, new InjectedPluginClasspath(injectedPluginClassPath));
   addProvider(
       new CacheRepositoryServices(
           startParameter.getGradleUserHomeDir(), startParameter.getProjectCacheDir()));
 }
Пример #13
0
 private Runnable runBuild(
     StartParameter startParameter,
     DaemonParameters daemonParameters,
     BuildActionExecuter<BuildActionParameters> executer,
     ServiceRegistry sharedServices) {
   BuildActionParameters parameters =
       new DefaultBuildActionParameters(
           daemonParameters.getEffectiveSystemProperties(),
           System.getenv(),
           SystemProperties.getInstance().getCurrentDir(),
           startParameter.getLogLevel(),
           daemonParameters.getDaemonUsage(),
           startParameter.isContinuous(),
           daemonParameters.isInteractive(),
           ClassPath.EMPTY);
   return new RunBuildAction(
       executer,
       startParameter,
       clientMetaData(),
       getBuildStartTime(),
       parameters,
       sharedServices);
 }
 protected DependencyFactory createDependencyFactory() {
   ClassGenerator classGenerator = get(ClassGenerator.class);
   DefaultProjectDependencyFactory projectDependencyFactory =
       new DefaultProjectDependencyFactory(
           startParameter.getProjectDependenciesBuildInstruction(), classGenerator);
   return new DefaultDependencyFactory(
       WrapUtil.<IDependencyImplementationFactory>toSet(
           new ModuleDependencyFactory(classGenerator),
           new SelfResolvingDependencyFactory(classGenerator),
           new ClassPathDependencyFactory(
               classGenerator, get(ClassPathRegistry.class), new IdentityFileResolver()),
           projectDependencyFactory),
       new DefaultClientModuleFactory(classGenerator),
       projectDependencyFactory);
 }
  public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();

    for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
      if (!request.getArgs().isEmpty()) {
        context.proceed();
        return;
      }
    }

    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();
    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
      defaultTasks = Arrays.asList(ImplicitTasksConfigurer.HELP_TASK);
      LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
      LOGGER.info(
          "No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }

    startParameter.setTaskNames(defaultTasks);
    context.proceed();
  }
Пример #16
0
 /**
  * Creates the {@link BuildInternal} and {@link ProjectInternal} instances for the given root
  * project, ready for the projects to be evaluated.
  */
 public BuildInternal load(
     ProjectDescriptor rootProjectDescriptor,
     ClassLoader buildScriptClassLoader,
     StartParameter startParameter,
     Map<String, String> externalProjectProperties) {
   logger.debug("Loading Project objects");
   Clock clock = new Clock();
   DefaultBuild build =
       createProjects(
           rootProjectDescriptor,
           buildScriptClassLoader,
           startParameter,
           externalProjectProperties);
   ProjectInternal currentProject =
       (ProjectInternal)
           build.getRootProject().getProjectRegistry().getProject(startParameter.getCurrentDir());
   assert currentProject != null;
   build.setCurrentProject(currentProject);
   logger.debug("Timing: Loading projects took: " + clock.getTime());
   return build;
 }
Пример #17
0
 private BuildResult doRun(
     final OutputListenerImpl outputListener,
     OutputListenerImpl errorListener,
     BuildListenerImpl listener) {
   assertCanExecute();
   if (isQuiet()) {
     parameter.setLogLevel(LogLevel.QUIET);
   }
   DefaultGradleLauncherFactory factory =
       (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
   factory.addListener(listener);
   GradleLauncher gradleLauncher = GradleLauncher.newInstance(parameter);
   gradleLauncher.addStandardOutputListener(outputListener);
   gradleLauncher.addStandardErrorListener(errorListener);
   try {
     return gradleLauncher.run();
   } finally {
     System.clearProperty("test.single");
     factory.removeListener(listener);
   }
 }
Пример #18
0
  private Runnable runBuildInProcess(
      StartParameter startParameter,
      DaemonParameters daemonParameters,
      ServiceRegistry loggingServices) {
    ServiceRegistry globalServices =
        ServiceRegistryBuilder.builder()
            .displayName("Global services")
            .parent(loggingServices)
            .parent(NativeServices.getInstance())
            .provider(new GlobalScopeServices(startParameter.isContinuous()))
            .build();

    BuildActionExecuter<BuildActionParameters> executer = globalServices.get(BuildExecuter.class);
    StyledTextOutputFactory textOutputFactory = globalServices.get(StyledTextOutputFactory.class);
    DocumentationRegistry documentationRegistry = globalServices.get(DocumentationRegistry.class);
    DaemonUsageSuggestingBuildActionExecuter daemonUsageSuggestingExecuter =
        new DaemonUsageSuggestingBuildActionExecuter(
            executer, textOutputFactory, documentationRegistry);

    return runBuild(
        startParameter, daemonParameters, daemonUsageSuggestingExecuter, globalServices);
  }
Пример #19
0
 @Override
 public GradleExecuter withTasks(List<String> names) {
   parameter.setTaskNames(names);
   return this;
 }
Пример #20
0
 @Override
 public GradleExecuter usingProjectDirectory(File projectDir) {
   parameter.setProjectDir(projectDir);
   return this;
 }
Пример #21
0
 @Override
 public GradleExecuter usingInitScript(File initScript) {
   parameter.addInitScript(initScript);
   return this;
 }
Пример #22
0
 @Override
 public InProcessGradleExecuter usingSettingsFile(File settingsFile) {
   parameter.setSettingsFile(settingsFile);
   return this;
 }
Пример #23
0
 @Override
 public InProcessGradleExecuter withDependencyList() {
   parameter.setTaskNames(toList("dependencies"));
   return this;
 }
Пример #24
0
 public GradleBuild() {
   this.gradleLauncherFactory = getServices().get(GradleLauncherFactory.class);
   this.startParameter = getServices().get(StartParameter.class).newBuild();
   startParameter.setCurrentDir(getProject().getProjectDir());
 }
Пример #25
0
 @Override
 public InProcessGradleExecuter withSearchUpwards() {
   parameter.setSearchUpwards(true);
   return this;
 }
Пример #26
0
 @Override
 public GradleExecuter inDirectory(File directory) {
   parameter.setCurrentDir(directory);
   return this;
 }
Пример #27
0
 @Override
 public GradleExecuter usingBuildScript(String scriptText) {
   parameter.useEmbeddedBuildFile(scriptText);
   return this;
 }
Пример #28
0
 @Override
 public GradleExecuter usingBuildScript(File buildScript) {
   parameter.setBuildFile(buildScript);
   return this;
 }
Пример #29
0
 @Override
 public GradleExecuter withUserHomeDir(File userHomeDir) {
   parameter.setGradleUserHomeDir(userHomeDir);
   return this;
 }
Пример #30
0
 @Override
 public InProcessGradleExecuter withTaskList() {
   parameter.setTaskNames(toList("tasks"));
   return this;
 }