/** * @param project * @return the list of PublishingExtension(s), if some are defined: this will depend on the project (could be empty). */ private static PublishingExtension extractPublishingExtension(final Project project) { final ExtensionContainer extensions = project.getExtensions(); final Object publishing = extensions.findByName( "publishing" ); if ( publishing == null ) { return null; } if ( ! PublishingExtension.class.isAssignableFrom( publishing.getClass() ) ) { throw new RuntimeException( "The registered 'publishing' extension is not of the expected type PublishingExtension" ); } return (PublishingExtension) publishing; }
/** * Uses the project to get GradleExtension and runs the generator * * @param project - gradle project */ public static void doCompileRocker(Project project, File templateDir, File outputDir, File classDir) { RockerConfiguration ext = (RockerConfiguration) project.getExtensions().findByName("rocker"); runJavaGeneratorMain(ext, templateDir, outputDir, classDir); }
private PluginTestExtension getExtension(Test testTask) { return (PluginTestExtension) testTask.getProject().getExtensions().findByName("pluginTest"); }
@Override public void apply(Project project) { project.getExtensions().create("download", DownloadExtension.class, project); if (project.getExtensions().findByName("verifyChecksum") == null) { project.getExtensions().create("verifyChecksum", VerifyExtension.class, project); } //register top-level properties 'Download' and 'Verify' for our tasks ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties(); extraProperties.set(Download.class.getSimpleName(), Download.class); extraProperties.set(Verify.class.getSimpleName(), Verify.class); } }
@Override public void apply(Project project) { project.getExtensions().create("download", DownloadExtension.class, project); if (project.getExtensions().findByName("verifyChecksum") == null) { project.getExtensions().create("verifyChecksum", VerifyExtension.class, project); } //register top-level properties 'Download' and 'Verify' for our tasks ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties(); extraProperties.set(Download.class.getSimpleName(), Download.class); extraProperties.set(Verify.class.getSimpleName(), Verify.class); } }
@Override public void apply(Project project) { this.project = project; this.project.getExtensions().add(YarnExtension.NAME, YarnExtension.class); YarnExtension yarnExtension = (YarnExtension) this.project.getExtensions().findByName(YarnExtension.NAME); yarnExtension.setProject(this.project); addTasks(); }
@Override public void apply(Project project) { // don't try to see if the task was added to any project in the hierarchy. It will try to resolve recursively the configuration of all the projects, failing // if a project has a sonarqube configuration since the extension wasn't added to it yet. if (project.getExtensions().findByName(SonarQubeExtension.SONARQUBE_EXTENSION_NAME) == null) { addExtensions(project); LOGGER.debug("Adding " + SonarQubeExtension.SONARQUBE_TASK_NAME + " task to " + project); SonarQubeTask sonarQubeTask = project.getTasks().create(SonarQubeExtension.SONARQUBE_TASK_NAME, SonarQubeTask.class); sonarQubeTask.setDescription("Analyzes " + project + " and its subprojects with SonarQube."); configureTask(sonarQubeTask, project); } }
@Override public void apply(Project project) { // don't try to see if the task was added to any project in the hierarchy. It will try to resolve recursively the configuration of all the projects, failing // if a project has a sonarqube configuration since the extension wasn't added to it yet. if (project.getExtensions().findByName(SonarQubeExtension.SONARQUBE_EXTENSION_NAME) == null) { addExtensions(project); LOGGER.debug("Adding " + SonarQubeExtension.SONARQUBE_TASK_NAME + " task to " + project); SonarQubeTask sonarQubeTask = project.getTasks().create(SonarQubeExtension.SONARQUBE_TASK_NAME, SonarQubeTask.class); sonarQubeTask.setDescription("Analyzes " + project + " and its subprojects with SonarQube."); configureTask(sonarQubeTask, project); } }
@TaskAction public void uploadArtifactTask() { AirWatchPluginExtension extension = (AirWatchPluginExtension)getProject().getExtensions().findByName("airWatch"); System.out.println("Starting AirWatch upload task."); AirWatch airWatch = new AirWatch(extension.endpoint, extension.username, extension.password, extension.apiKey, extension.groupId, extension.smartGroupId); try { //Upload File Long blobId = airWatch.uploadFile(extension.artifactPath); //Insert MetaData airWatch.insertMetaData(blobId, extension.applicationName, extension.pushMode, extension.applicationDesc, extension.deviceType, extension.supportedModels); } catch (IOException e) { System.out.println(e.toString()); } System.out.println("Finished AirWatch upload task."); } }
final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(project.getExtensions().findByName(MeecrowavePlugin.NAME)); if (extension != null) { for (final Field f : MeecrowaveTask.class.getDeclaredFields()) {
final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(actionProject.getExtensions().findByName(NAME)); if (extension != null && extension.isSkipMavenCentral()) { return;
@Test public void deviceFarmPluginAddsTestServerToProject() { gradleProject.getPluginManager().apply("com.android.application"); gradleProject.getPluginManager().apply("devicefarm"); assertTrue(((AppExtension) gradleProject.getExtensions().findByName("android")).getTestServers().get(0) instanceof DeviceFarmServer); }
@Test public void deviceFarmPluginAddsTestServerToProject() { gradleProject.getPluginManager().apply("com.android.application"); gradleProject.getPluginManager().apply("devicefarm"); assertTrue(((AppExtension) gradleProject.getExtensions().findByName("android")).getTestServers().get(0) instanceof DeviceFarmServer); }