public void apply(final ProjectInternal project) {
    project.getPlugins().apply(NativeBinariesModelPlugin.class);

    modelRules.rule(new CreateTestBinaries(instantiator, resolver, project));

    project.getExtensions().create("testSuites", DefaultTestSuiteContainer.class, instantiator);
  }
Exemplo n.º 2
0
  public void apply(ProjectInternal project) {
    project.getPluginManager().apply(ReportingBasePlugin.class);
    this.project = project;
    addJacocoConfigurations();
    JacocoAgentJar agent = instantiator.newInstance(JacocoAgentJar.class, project);
    JacocoPluginExtension extension =
        project
            .getExtensions()
            .create(PLUGIN_EXTENSION_NAME, JacocoPluginExtension.class, project, agent);
    final ReportingExtension reportingExtension =
        (ReportingExtension) project.getExtensions().getByName(ReportingExtension.NAME);
    ((IConventionAware) extension)
        .getConventionMapping()
        .map(
            "reportsDir",
            new Callable<File>() {
              @Override
              public File call() {
                return reportingExtension.file("jacoco");
              }
            });

    configureAgentDependencies(agent, extension);
    configureTaskClasspathDefaults(extension);
    applyToDefaultTasks(extension);
    configureDefaultOutputPathForJacocoMerge();
    configureJacocoReportsDefaults(extension);
    addDefaultReportTasks(extension);
  }
Exemplo n.º 3
0
 protected ScriptHandler createScriptHandler() {
   ScriptHandlerFactory factory =
       new DefaultScriptHandlerFactory(
           get(DependencyManagementServices.class),
           get(FileResolver.class),
           get(DependencyMetaDataProvider.class));
   return factory.create(project.getBuildScriptSource(), project.getClassLoaderScope(), project);
 }
Exemplo n.º 4
0
 public void projectsLoaded(Gradle gradle) {
   ProjectInternal projectInternal = (ProjectInternal) gradle.getRootProject();
   logger.info(
       String.format(
           "Projects loaded. Root project using %s.",
           projectInternal.getBuildScriptSource().getDisplayName()));
   logger.info(String.format("Included projects: %s", projectInternal.getAllprojects()));
 }
 @Override
 public void graphPopulated(TaskExecutionGraph graph) {
   Set<Project> seen = Sets.newHashSet();
   for (Task task : graph.getAllTasks()) {
     if (seen.add(task.getProject())) {
       ProjectInternal projectInternal = (ProjectInternal) task.getProject();
       projectInternal.bindAllModelRules();
     }
   }
 }
 public VisualStudioProjectConfiguration lookupProjectConfiguration(
     NativeBinarySpec nativeBinary) {
   // Looks in the correct project registry for this binary
   ProjectInternal componentProject = getComponentProject(nativeBinary);
   VisualStudioExtension visualStudioExtension =
       componentProject
           .getModelRegistry()
           .get(ModelPath.path("visualStudio"), ModelType.of(VisualStudioExtension.class));
   VisualStudioProjectRegistry projectRegistry =
       ((VisualStudioExtensionInternal) visualStudioExtension).getProjectRegistry();
   return projectRegistry.getProjectConfiguration(nativeBinary);
 }
Exemplo n.º 7
0
 @Override
 public void configureHierarchyFully(ProjectInternal project) {
   configureFully(project);
   for (Project sub : project.getSubprojects()) {
     configureFully((ProjectInternal) sub);
   }
 }
Exemplo n.º 8
0
  public void apply(ProjectInternal project) {
    project.getPluginManager().apply(BasePlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);
    project.getPluginManager().apply(LanguageBasePlugin.class);

    JavaPluginConvention javaConvention = new JavaPluginConvention(project, instantiator);
    project.getConvention().getPlugins().put("java", javaConvention);

    configureCompileDefaults(project, javaConvention);
    configureSourceSetDefaults(javaConvention);

    configureJavaDoc(project, javaConvention);
    configureTest(project, javaConvention);
    configureBuildNeeded(project);
    configureBuildDependents(project);
  }
 @Override
 public void addConfiguration(Runnable runnable, boolean deferrable) {
   if (deferrable) {
     target.addDeferredConfiguration(runnable);
   } else {
     runnable.run();
   }
 }
Exemplo n.º 10
0
 protected DefaultFileOperations createFileOperations() {
   return new DefaultFileOperations(
       get(FileResolver.class),
       project.getTasks(),
       get(TemporaryFileProvider.class),
       get(Instantiator.class),
       get(FileLookup.class));
 }
Exemplo n.º 11
0
 private void addPropertiesToProject(
     Map<String, String> externalProperties, ProjectInternal project) {
   Properties projectProperties = new Properties();
   File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
   logger.debug("Looking for project properties from: {}", projectPropertiesFile);
   if (projectPropertiesFile.isFile()) {
     projectProperties = GUtil.loadProperties(projectPropertiesFile);
     logger.debug(
         "Adding project properties (if not overwritten by user properties): {}",
         projectProperties.keySet());
   } else {
     logger.debug("project property file does not exists. We continue!");
   }
   projectProperties.putAll(externalProperties);
   for (Object key : projectProperties.keySet()) {
     project.setProperty((String) key, projectProperties.get(key));
   }
 }
Exemplo n.º 12
0
  public DefaultCppSourceSet(String name, ProjectInternal project) {
    this.name = name;

    this.exportedHeaders =
        new DefaultSourceDirectorySet("exported headers", project.getFileResolver());
    this.source = new DefaultSourceDirectorySet("source", project.getFileResolver());
    this.libs = new DefaultDomainObjectSet<NativeDependencySet>(NativeDependencySet.class);
    this.configurationDependencySet = new ConfigurationBasedNativeDependencySet(project, name);

    libs.add(configurationDependencySet);
  }
Exemplo n.º 13
0
  private Compiler<JavaCompileSpec> createTargetCompiler(CompileOptions options) {
    if (options.isFork() && options.getForkOptions().getExecutable() != null) {
      return new CommandLineJavaCompiler(
          createSerializableTempFileProvider(), project.getProjectDir());
    }

    Compiler<JavaCompileSpec> compiler = inProcessCompilerFactory.create(options);
    if (options.isFork() && !jointCompilation) {
      return new DaemonJavaCompiler(project, compiler, compilerDaemonManager);
    }

    return compiler;
  }
  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();
  }
Exemplo n.º 15
0
  public TaskSelection getSelection(String path) {
    SetMultimap<String, Task> tasksByName;
    String baseName;
    String prefix;

    ProjectInternal project = gradle.getDefaultProject();

    if (path.contains(Project.PATH_SEPARATOR)) {
      project = projectFinder.findProject(path, project);
      baseName = StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR);
      prefix = project.getPath() + Project.PATH_SEPARATOR;

      tasksByName = taskNameResolver.select(baseName, project);
    } else {
      baseName = path;
      prefix = "";

      tasksByName = taskNameResolver.selectAll(path, project);
    }

    Set<Task> tasks = tasksByName.get(baseName);
    if (!tasks.isEmpty()) {
      // An exact match
      return new TaskSelection(path, tasks);
    }

    NameMatcher matcher = new NameMatcher();
    String actualName = matcher.find(baseName, tasksByName.keySet());

    if (actualName != null) {
      // A partial match
      return new TaskSelection(prefix + actualName, tasksByName.get(actualName));
    }

    throw new TaskSelectionException(matcher.formatErrorMessage("task", project));
  }
Exemplo n.º 16
0
 private void addProjects(
     ProjectInternal parent,
     ProjectDescriptor parentProjectDescriptor,
     GradleInternal gradle,
     ClassLoaderScope buildRootClassLoaderScope) {
   for (ProjectDescriptor childProjectDescriptor : parentProjectDescriptor.getChildren()) {
     ProjectInternal childProject =
         projectFactory.createProject(
             childProjectDescriptor,
             parent,
             gradle,
             parent
                 .getClassLoaderScope()
                 .createChild("project-" + childProjectDescriptor.getName()),
             buildRootClassLoaderScope);
     addProjects(childProject, childProjectDescriptor, gradle, buildRootClassLoaderScope);
   }
 }
Exemplo n.º 17
0
 public void configure(ProjectInternal project) {
   if (cancellationToken.isCancellationRequested()) {
     throw new BuildCancelledException();
   }
   project.evaluate();
 }
Exemplo n.º 18
0
 public void apply(ProjectInternal project) {
   project.getPlugins().apply(NativeComponentModelPlugin.class);
 }
Exemplo n.º 19
0
 protected PluginRegistry createPluginRegistry(PluginRegistry parentRegistry) {
   return parentRegistry.createChild(project.getClassLoaderScope().createChild("plugins").lock());
 }
Exemplo n.º 20
0
 protected FileResolver createFileResolver() {
   return new BaseDirFileResolver(get(FileSystem.class), project.getProjectDir());
 }
Exemplo n.º 21
0
 @Override
 public void attachScript(Script script) {
   target.setScript(script);
 }
Exemplo n.º 22
0
 @Override
 public PluginManagerInternal getPluginManager() {
   return target.getPluginManager();
 }
Exemplo n.º 23
0
 private TemporaryFileProvider createSerializableTempFileProvider() {
   return new DefaultTemporaryFileProvider(new FileFactory(project.getBuildDir()));
 }
Exemplo n.º 24
0
 public Object buildAll(Class<?> type, ProjectInternal project) {
   return buildProjectOutput(project.getRootProject(), null);
 }
Exemplo n.º 25
0
 private void discoverTasks(ProjectInternal project) {
   if (cancellationToken.isCancellationRequested()) {
     throw new BuildCancelledException();
   }
   project.getTasks().discoverTasks();
 }
Exemplo n.º 26
0
 public void configureHierarchy(ProjectInternal project) {
   configure(project);
   for (Project sub : project.getSubprojects()) {
     configure((ProjectInternal) sub);
   }
 }
Exemplo n.º 27
0
 private void bindAllModelRules(ProjectInternal project) {
   if (cancellationToken.isCancellationRequested()) {
     throw new BuildCancelledException();
   }
   project.bindAllModelRules();
 }