Beispiel #1
0
  @Override
  public void apply(final Project project) {
    this.project = project;
    project.getPluginManager().apply(JavaPlugin.class);
    project.getPluginManager().apply(DistributionPlugin.class);

    addPluginConvention();
    addRunTask();
    addCreateScriptsTask();

    Distribution distribution =
        ((DistributionContainer) project.getExtensions().getByName("distributions"))
            .getByName(DistributionPlugin.MAIN_DISTRIBUTION_NAME);

    ((IConventionAware) distribution)
        .getConventionMapping()
        .map(
            "baseName",
            new Callable<Object>() {
              @Override
              public Object call() throws Exception {
                return pluginConvention.getApplicationName();
              }
            });
    configureDistSpec(distribution.getContents());
    configureInstallTask(project.getTasks().getAt(TASK_INSTALL_NAME));
  }
 public void apply(Project project) {
   project.getExtensions().create("flyway", FlywayExtension.class);
   project.getTasks().create("flywayClean", FlywayCleanTask.class);
   project.getTasks().create("flywayInit", FlywayInitTask.class);
   project.getTasks().create("flywayMigrate", FlywayMigrateTask.class);
   project.getTasks().create("flywayValidate", FlywayValidateTask.class);
   project.getTasks().create("flywayInfo", FlywayInfoTask.class);
   project.getTasks().create("flywayRepair", FlywayRepairTask.class);
 }
 public DomainObjectSet<NativeBinary> getBinaries(NativeLibraryRequirement requirement) {
   Project project = findProject(requirement);
   LibraryContainer libraryContainer =
       (LibraryContainer) project.getExtensions().findByName("libraries");
   if (libraryContainer == null) {
     throw new LibraryResolveException(
         String.format("Project does not have a libraries container: '%s'", project.getPath()));
   }
   return libraryContainer.getByName(requirement.getLibraryName()).getBinaries();
 }
 public void apply(Project project) {
   RepositoryHandler repositories =
       artifactPublicationServicesFactory.create().getRepositoryHandler();
   PublicationContainer publications =
       instantiator.newInstance(DefaultPublicationContainer.class, instantiator);
   project
       .getExtensions()
       .create(
           PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);
 }
Beispiel #5
0
 @Override
 public void apply(Project project) {
   project.getExtensions().create(BugVMPluginExtension.NAME, BugVMPluginExtension.class, project);
   project.task(
       Collections.singletonMap("type", IPhoneSimulatorTask.class), "launchIPhoneSimulator");
   project.task(Collections.singletonMap("type", IPadSimulatorTask.class), "launchIPadSimulator");
   project.task(Collections.singletonMap("type", IOSDeviceTask.class), "launchIOSDevice");
   project.task(Collections.singletonMap("type", ConsoleTask.class), "launchConsole");
   project.task(Collections.singletonMap("type", ArchiveTask.class), "createIPA");
   project.task(Collections.singletonMap("type", ArchiveTask.class), "bugvmArchive");
   project.task(Collections.singletonMap("type", InstallTask.class), "bugvmInstall");
 }
Beispiel #6
0
  @TaskAction
  public void report() {
    Project project = getProject();

    StyledTextOutput textOutput = getTextOutputFactory().create(ComponentReport.class);
    ComponentReportRenderer renderer = new ComponentReportRenderer(getFileResolver());
    renderer.setOutput(textOutput);

    renderer.startProject(project);

    Collection<ProjectComponent> components = new ArrayList<ProjectComponent>();
    ProjectComponentContainer projectComponents =
        project.getExtensions().findByType(ProjectComponentContainer.class);
    if (projectComponents != null) {
      components.addAll(projectComponents);
    }

    try {
      TestSuiteContainer testSuites =
          getModelRegistry().get(ModelReference.of("testSuites", TestSuiteContainer.class));
      components.addAll(testSuites);
    } catch (IllegalStateException e) {
      // TODO - need a better contract here
      // Ignore for now
    }

    renderer.renderComponents(components);

    ProjectSourceSet sourceSets = project.getExtensions().findByType(ProjectSourceSet.class);
    if (sourceSets != null) {
      renderer.renderSourceSets(sourceSets);
    }
    BinaryContainer binaries = project.getExtensions().findByType(BinaryContainer.class);
    if (binaries != null) {
      renderer.renderBinaries(binaries);
    }

    renderer.completeProject(project);
    renderer.complete();
  }
  @Override
  public void apply(Project project) {
    project.getPlugins().apply(DependencyManagementPlugin.class);
    DependencyManagementExtension dependencyManagement =
        project.getExtensions().findByType(DependencyManagementExtension.class);
    dependencyManagement.imports(
        new Action<ImportsHandler>() {

          @Override
          public void execute(ImportsHandler importsHandler) {
            importsHandler.mavenBom(SPRING_BOOT_BOM);
          }
        });
  }
Beispiel #8
0
  public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications =
        instantiator.newInstance(DefaultPublicationContainer.class, instantiator);

    // TODO Registering an extension should register it with the model registry as well
    final PublishingExtension extension =
        project
            .getExtensions()
            .create(
                PublishingExtension.NAME,
                DefaultPublishingExtension.class,
                repositories,
                publications);

    project.afterEvaluate(
        new Action<Project>() {
          public void execute(Project project) {
            for (Publication publication : extension.getPublications()) {
              PublicationInternal internalPublication = (PublicationInternal) publication;
              publicationRegistry.registerPublication(
                  project.getPath(),
                  new DefaultProjectPublication(internalPublication.getCoordinates()));
            }
          }
        });

    ModelPath extensionModelPath = ModelPath.path(PublishingExtension.NAME);

    modelRules.register(extensionModelPath.toString(), extension);

    modelRules.rule(
        new ModelRule() {
          public void triggerDeferredConfigurables(PublishingExtension publishingExtension) {
            project.getExtensions().getByType(DefaultPublishingExtension.class);
          }
        });

    Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME);
    publishLifecycleTask.setDescription("Publishes all publications produced by this project.");
    publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP);
  }
Beispiel #9
0
  @TaskAction
  public void repackage() {
    Project project = getProject();
    final SpringBootPluginExtension extension =
        project.getExtensions().getByType(SpringBootPluginExtension.class);
    final ProjectLibraries libraries = new ProjectLibraries(project);
    if (extension.getProvidedConfiguration() != null) {
      libraries.setProvidedConfigurationName(extension.getProvidedConfiguration());
    }
    project
        .getTasks()
        .withType(
            Jar.class,
            new Action<Jar>() {

              @Override
              public void execute(Jar archive) {
                if ("".equals(archive.getClassifier())) {
                  File file = archive.getArchivePath();
                  if (file.exists()) {
                    Repackager repackager = new Repackager(file);
                    repackager.setMainClass(extension.getMainClass());
                    if (extension.convertLayout() != null) {
                      repackager.setLayout(extension.convertLayout());
                    }
                    repackager.setBackupSource(extension.isBackupSource());
                    try {
                      repackager.repackage(libraries);
                    } catch (IOException ex) {
                      throw new IllegalStateException(ex.getMessage(), ex);
                    }
                  }
                }
              }
            });
  }
 @Override
 public void apply(Project target) {
   target.getExtensions().create("generator", GeneratorPluginExtension.class);
   target.task("javaTask");
 }
 private AmazonRDS initClient() {
   AwsPluginExtension aws = project.getExtensions().getByType(AwsPluginExtension.class);
   AmazonRDSClient client = aws.createClient(AmazonRDSClient.class, profileName);
   client.setRegion(aws.getActiveRegion(region));
   return client;
 }
  private void configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final ProjectSourceSet projectSourceSet =
        project.getExtensions().getByType(ProjectSourceSet.class);

    pluginConvention
        .getSourceSets()
        .all(
            new Action<SourceSet>() {
              public void execute(final SourceSet sourceSet) {
                ConventionMapping outputConventionMapping =
                    ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

                ConfigurationContainer configurations = project.getConfigurations();

                defineConfigurationsForSourceSet(sourceSet, configurations);
                definePathsForSourceSet(sourceSet, outputConventionMapping, project);
                sourceSet.compiledBy(sourceSet.getClassesTaskName());

                Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
                DefaultJavaSourceSet javaSourceSet =
                    instantiator.newInstance(
                        DefaultJavaSourceSet.class,
                        "java",
                        sourceSet.getName(),
                        sourceSet.getJava(),
                        compileClasspath);
                projectSourceSet.add(javaSourceSet);
                JvmResourceSet resourceSet =
                    instantiator.newInstance(
                        DefaultJvmResourceSet.class,
                        "resources",
                        sourceSet.getName(),
                        sourceSet.getResources());
                projectSourceSet.add(resourceSet);

                createProcessResourcesTaskForBinary(sourceSet, resourceSet, project);
                createCompileJavaTaskForBinary(sourceSet, javaSourceSet, project);
                createBinaryLifecycleTask(sourceSet, project);

                ClassDirectoryBinarySpecInternal binary =
                    instantiator.newInstance(
                        DefaultClassDirectoryBinarySpec.class,
                        String.format("%sClasses", sourceSet.getName()),
                        sourceSet,
                        javaToolChain,
                        DefaultJavaPlatform.current(),
                        instantiator,
                        taskFactory);

                binary.addSourceSet(javaSourceSet);
                binary.addSourceSet(resourceSet);

                BinaryContainer binaryContainer =
                    project.getExtensions().getByType(BinaryContainer.class);
                binaryContainer.add(binary);

                attachTasksToBinary(binary, sourceSet, project);
              }
            });
  }
Beispiel #13
0
  private void configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final ProjectSourceSet projectSourceSet =
        project.getExtensions().getByType(ProjectSourceSet.class);

    pluginConvention
        .getSourceSets()
        .all(
            new Action<SourceSet>() {
              public void execute(final SourceSet sourceSet) {
                ConventionMapping outputConventionMapping =
                    ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

                ConfigurationContainer configurations = project.getConfigurations();

                Configuration compileConfiguration =
                    configurations.findByName(sourceSet.getCompileConfigurationName());
                if (compileConfiguration == null) {
                  compileConfiguration =
                      configurations.add(sourceSet.getCompileConfigurationName());
                }
                compileConfiguration.setVisible(false);
                compileConfiguration.setDescription(
                    String.format("Classpath for compiling the %s sources.", sourceSet.getName()));

                Configuration runtimeConfiguration =
                    configurations.findByName(sourceSet.getRuntimeConfigurationName());
                if (runtimeConfiguration == null) {
                  runtimeConfiguration =
                      configurations.add(sourceSet.getRuntimeConfigurationName());
                }
                runtimeConfiguration.setVisible(false);
                runtimeConfiguration.extendsFrom(compileConfiguration);
                runtimeConfiguration.setDescription(
                    String.format(
                        "Classpath for running the compiled %s classes.", sourceSet.getName()));

                sourceSet.setCompileClasspath(compileConfiguration);
                sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration));

                outputConventionMapping.map(
                    "classesDir",
                    new Callable<Object>() {
                      public Object call() throws Exception {
                        String classesDirName = String.format("classes/%s", sourceSet.getName());
                        return new File(project.getBuildDir(), classesDirName);
                      }
                    });
                outputConventionMapping.map(
                    "resourcesDir",
                    new Callable<Object>() {
                      public Object call() throws Exception {
                        String classesDirName = String.format("resources/%s", sourceSet.getName());
                        return new File(project.getBuildDir(), classesDirName);
                      }
                    });

                sourceSet.getJava().srcDir(String.format("src/%s/java", sourceSet.getName()));
                sourceSet
                    .getResources()
                    .srcDir(String.format("src/%s/resources", sourceSet.getName()));
                sourceSet.compiledBy(sourceSet.getClassesTaskName());

                FunctionalSourceSet functionalSourceSet =
                    projectSourceSet.create(sourceSet.getName());
                Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
                DefaultJavaSourceSet javaSourceSet =
                    instantiator.newInstance(
                        DefaultJavaSourceSet.class,
                        "java",
                        sourceSet.getJava(),
                        compileClasspath,
                        functionalSourceSet);
                functionalSourceSet.add(javaSourceSet);
                ResourceSet resourceSet =
                    instantiator.newInstance(
                        DefaultResourceSet.class,
                        "resources",
                        sourceSet.getResources(),
                        functionalSourceSet);
                functionalSourceSet.add(resourceSet);

                JvmBinaryContainer jvmBinaryContainer =
                    project.getPlugins().getPlugin(JvmLanguagePlugin.class).getJvmBinaryContainer();
                ClassDirectoryBinary binary =
                    jvmBinaryContainer.create(sourceSet.getName(), ClassDirectoryBinary.class);
                ConventionMapping conventionMapping = new DslObject(binary).getConventionMapping();
                conventionMapping.map(
                    "classesDir",
                    new Callable<File>() {
                      public File call() throws Exception {
                        return sourceSet.getOutput().getClassesDir();
                      }
                    });
                conventionMapping.map(
                    "resourcesDir",
                    new Callable<File>() {
                      public File call() throws Exception {
                        return sourceSet.getOutput().getResourcesDir();
                      }
                    });

                binary.getSource().add(javaSourceSet);
                binary.getSource().add(resourceSet);

                binary.getClassesTask().dependsOn(sourceSet.getOutput().getDirs());
              }
            });
  }
 public void apply(Project project) {
   project.getPluginManager().apply(AwsPlugin.class);
   project
       .getExtensions()
       .create(AmazonRDSPluginExtension.NAME, AmazonRDSPluginExtension.class, project);
 }