org.gradle.api.plugins.Convention Java Examples

The following examples show how to use org.gradle.api.plugins.Convention. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #2
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #3
Source File: ConventionAwareHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #4
Source File: ExtensibleDynamicObject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) {
    this.dynamicDelegate = dynamicDelegate;
    this.convention = convention;
    this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate.getClass(), convention.getExtraProperties());

    updateDelegates();
}
 
Example #5
Source File: DefaultConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #6
Source File: DefaultConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #7
Source File: DefaultConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #8
Source File: ConventionAwareHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #9
Source File: ExtensibleDynamicObject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) {
    this.dynamicDelegate = dynamicDelegate;
    this.convention = convention;
    this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate, this, convention.getExtraProperties());

    updateDelegates();
}
 
Example #10
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #11
Source File: ConventionAwareHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #12
Source File: ConventionAwareHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #13
Source File: ConventionAwareHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #14
Source File: DefaultConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #15
Source File: DefaultConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #16
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #17
Source File: SourceSetUtils.java    From transport with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns the {@link SourceDirectorySet} for a given {@link SourceSet} depending on the language of the sources
 */
static SourceDirectorySet getSourceDirectorySet(SourceSet sourceSet, Language language) {
  switch (language) {
    case JAVA:
      return sourceSet.getJava();
    case SCALA:
      Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
      ScalaSourceSet scalaSourceSet = sourceSetConvention.getPlugin(ScalaSourceSet.class);
      return scalaSourceSet.getScala();
    default:
      throw new UnsupportedOperationException("Language " + language + " not supported");
  }
}
 
Example #18
Source File: QuarkusGradleUtils.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public static SourceSet getSourceSet(Project project, String sourceSetName) {
    final Convention convention = project.getConvention();
    JavaPluginConvention javaConvention = convention.findPlugin(JavaPluginConvention.class);
    if (javaConvention == null) {
        throw new IllegalArgumentException("The project does not include the Java plugin");
    }
    return javaConvention.getSourceSets().getByName(sourceSetName);
}
 
Example #19
Source File: QuarkusPluginExtension.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public Path appJarOrClasses() {
    final Jar jarTask = (Jar) project.getTasks().findByName(JavaPlugin.JAR_TASK_NAME);
    if (jarTask == null) {
        throw new RuntimeException("Failed to locate task 'jar' in the project.");
    }
    final Provider<RegularFile> jarProvider = jarTask.getArchiveFile();
    Path classesDir = null;
    if (jarProvider.isPresent()) {
        final File f = jarProvider.get().getAsFile();
        if (f.exists()) {
            classesDir = f.toPath();
        }
    }
    if (classesDir == null) {
        final Convention convention = project.getConvention();
        JavaPluginConvention javaConvention = convention.findPlugin(JavaPluginConvention.class);
        if (javaConvention != null) {
            final SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir());
            if (classesPath != null) {
                classesDir = Paths.get(classesPath);
            }
        }
    }
    if (classesDir == null) {
        throw new RuntimeException("Failed to locate project's classes directory");
    }
    return classesDir;
}
 
Example #20
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #21
Source File: ExtensibleDynamicObject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) {
    this.dynamicDelegate = dynamicDelegate;
    this.convention = convention;
    this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate.getClass(), convention.getExtraProperties());

    updateDelegates();
}
 
Example #22
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #23
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #24
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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;
}
 
Example #25
Source File: DefaultConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #26
Source File: DefaultConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #27
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #28
Source File: ExtensibleDynamicObject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExtensibleDynamicObject(Object delegate, AbstractDynamicObject dynamicDelegate, Convention convention) {
    this.dynamicDelegate = dynamicDelegate;
    this.convention = convention;
    this.extraPropertiesDynamicObject = new ExtraPropertiesDynamicObjectAdapter(delegate, this, convention.getExtraProperties());

    updateDelegates();
}
 
Example #29
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}
 
Example #30
Source File: ConventionAwareHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
            }
        }
    });
}