private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) { final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class); project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { @Override public void execute(final SourceSet sourceSet) { String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null); Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory); sourceSetConvention.getPlugins().put("scala", scalaSourceSet); final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala(); scalaDirectorySet.srcDir(new Callable<File>() { @Override public File call() throws Exception { return project.file("src/" + sourceSet.getName() + "/scala"); } }); sourceSet.getAllJava().source(scalaDirectorySet); sourceSet.getAllSource().source(scalaDirectorySet); sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { @Override public boolean isSatisfiedBy(FileTreeElement element) { return scalaDirectorySet.contains(element.getFile()); } }); configureScalaCompile(project, javaPlugin, sourceSet); } }); }
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) { String taskName = sourceSet.getCompileTaskName("scala"); final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class); scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName()); javaPlugin.configureForSourceSet(sourceSet, scalaCompile); Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention"); ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class); scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + "."); scalaCompile.setSource(scalaSourceSet.getScala()); project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName); // cannot use convention mapping because the resulting object won't be serializable // cannot compute at task execution time because we need association with source set project.getGradle().addBuildListener(new BuildAdapter() { @Override public void projectsEvaluated(Gradle gradle) { IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions(); if (incrementalOptions.getAnalysisFile() == null) { String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis"; incrementalOptions.setAnalysisFile(new File(analysisFilePath)); } if (incrementalOptions.getPublishedCode() == null) { Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName()); incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath()); } } }); }
public void apply(Project project) { DeprecationLogger.nagUserOfPluginReplacedWithExternalOne("Jetty", "Gretty (https://github.com/akhikhl/gretty)"); project.getPluginManager().apply(WarPlugin.class); JettyPluginConvention jettyConvention = new JettyPluginConvention(); Convention convention = project.getConvention(); convention.getPlugins().put("jetty", jettyConvention); configureMappingRules(project, jettyConvention); configureJettyRun(project); configureJettyRunWar(project); configureJettyStop(project, jettyConvention); }
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) { this.dynamicDelegate = dynamicDelegate; this.convention = convention; this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate.getClass(), convention.getExtraProperties()); updateDelegates(); }
public MappedProperty map(String propertyName, final Closure<?> value) { return map(propertyName, new Value<Object>() { public Object getValue(Convention convention, IConventionAware conventionAwareObject) { switch (value.getMaximumNumberOfParameters()) { case 0: return value.call(); case 1: return value.call(convention); default: return value.call(convention, conventionAwareObject); } } }); }
public MappedProperty map(String propertyName, final Callable<?> value) { return map(propertyName, new Value<Object>() { public Object getValue(Convention convention, IConventionAware conventionAwareObject) { return uncheckedCall(value); } }); }
public Object getValue(Convention convention, IConventionAware conventionAwareObject) { if (!cache) { return value.getValue(convention, conventionAwareObject); } if (!haveValue) { cachedValue = value.getValue(convention, conventionAwareObject); haveValue = true; } return cachedValue; }
public void apply(Project project) { project.getPlugins().apply(WarPlugin.class); JettyPluginConvention jettyConvention = new JettyPluginConvention(); Convention convention = project.getConvention(); convention.getPlugins().put("jetty", jettyConvention); configureMappingRules(project, jettyConvention); configureJettyRun(project); configureJettyRunWar(project); configureJettyStop(project, jettyConvention); }
public MappedProperty map(String propertyName, final Callable<?> value) { return map(propertyName, new Value<Object>() { public Object getValue(Convention convention, IConventionAware conventionAwareObject) { try { return value.call(); } catch (Exception e) { throw UncheckedException.throwAsUncheckedException(e); } } }); }
public Object getProperty(String name) throws MissingPropertyException { if (extensionsStorage.hasExtension(name)) { return extensionsStorage.getByName(name); } for (Object object : plugins.values()) { DynamicObject dynamicObject = new BeanDynamicObject(object); if (dynamicObject.hasProperty(name)) { return dynamicObject.getProperty(name); } } throw new MissingPropertyException(name, Convention.class); }
public void setProperty(String name, Object value) { extensionsStorage.checkExtensionIsNotReassigned(name); for (Object object : plugins.values()) { BeanDynamicObject dynamicObject = new BeanDynamicObject(object); if (dynamicObject.hasProperty(name)) { dynamicObject.setProperty(name, value); return; } } throw new MissingPropertyException(name, Convention.class); }
public Object invokeMethod(String name, Object... args) { if (extensionsStorage.isConfigureExtensionMethod(name, args)) { return extensionsStorage.configureExtension(name, args); } for (Object object : plugins.values()) { BeanDynamicObject dynamicObject = new BeanDynamicObject(object); if (dynamicObject.hasMethod(name, args)) { return dynamicObject.invokeMethod(name, args); } } throw new MissingMethodException(name, Convention.class, args); }
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) { this.dynamicDelegate = dynamicDelegate; this.convention = convention; this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate, this, convention.getExtraProperties()); updateDelegates(); }
public Convention getConvention() { return extensibleDynamicObject.getConvention(); }
public Convention getConvention() { return convention; }
public Convention getConvention() { assertDynamicObject(); return extensibleDynamicObject.getConvention(); }
public ConventionAwareHelper(IConventionAware source, Convention convention) { this._source = source; this._convention = convention; }
public Convention getConvention() { return _convention; }
public Convention getConvention() { if (convention == null) { this.convention = toType(object, HasConvention.class).getConvention(); } return convention; }
@Override public Convention getConvention() { return convention; }