Java 类org.gradle.api.plugins.ExtraPropertiesExtension 实例源码

项目:Reer    文件:ProjectPropertySettingBuildLoader.java   
void configureProperty(Project project, String name, Object value) {
    Class<? extends Project> clazz = project.getClass();
    if (clazz != projectClazz) {
        mutators.clear();
        projectClazz = clazz;
    }
    PropertyMutator propertyMutator = mutators.get(name);
    if (propertyMutator != null) {
        propertyMutator.setValue(project, value);
    } else {
        if (!mutators.containsKey(name)) {
            propertyMutator = JavaReflectionUtil.writeablePropertyIfExists(clazz, name);
            mutators.put(name, propertyMutator);
            if (propertyMutator != null) {
                propertyMutator.setValue(project, value);
                return;
            }
        }
        ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
        extraProperties.set(name, value);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FindMainClassTask.java   
@TaskAction
public void setMainClassNameProperty() {
    Project project = getProject();
    if (!project.hasProperty("mainClassName")
            || project.property("mainClassName") == null) {
        String mainClass = findMainClass();
        if (project.hasProperty("mainClassName")) {
            project.setProperty("mainClassName", mainClass);
        }
        else {
            ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            extraProperties.set("mainClassName", mainClass);
        }
    }
}
项目:spring-boot-concourse    文件:FindMainClassTask.java   
@TaskAction
public void setMainClassNameProperty() {
    Project project = getProject();
    if (!project.hasProperty("mainClassName")
            || project.property("mainClassName") == null) {
        String mainClass = findMainClass();
        if (project.hasProperty("mainClassName")) {
            project.setProperty("mainClassName", mainClass);
        }
        else {
            ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            extraProperties.set("mainClassName", mainClass);
        }
    }
}
项目:speedment-gradle-plugin    文件:PluginUtils.java   
@SuppressWarnings("unchecked")
public static <T> T getExtraProperty(Project project, String name, T value, Class<T> returnType) {
    LOGGER.debug("Getting extra property " + name + " from project " + project.getName());
    ExtraPropertiesExtension ext = project.getExtensions().getExtraProperties();
    if (ext != null && ext.has(name)) {
        Object property = ext.get(name);
        if (property == null) {
            LOGGER.debug("Extra property {} is null.", name);
        } else if (!returnType.isInstance(property)) {
            LOGGER.warn("Extra property {} is not {}. It's value will be ignored!", name, returnType.getName());
        } else {
            return (T) property;
        }
    } else {
        LOGGER.debug("Extra property {} is not set.", name);
    }
    return value;
}
项目:contestparser    文件:RepackageTask.java   
private void setMainClass(Repackager repackager) {
    String mainClass;
    if (getProject().hasProperty("mainClassName")) {
        mainClass = (String) getProject().property("mainClassName");
    }
    else {
        ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
                .getExtensions().getByName("ext");
        mainClass = (String) extraProperties.get("mainClassName");
    }
    if (RepackageTask.this.mainClass != null) {
        mainClass = RepackageTask.this.mainClass;
    }
    else if (this.extension.getMainClass() != null) {
        mainClass = this.extension.getMainClass();
    }
    else {
        Task runTask = getProject().getTasks().findByName("run");
        if (runTask != null && runTask.hasProperty("main")) {
            mainClass = (String) getProject().getTasks().getByName("run")
                    .property("main");
        }
    }
    getLogger().info("Setting mainClass: " + mainClass);
    repackager.setMainClass(mainClass);
}
项目:contestparser    文件:FindMainClassTask.java   
@TaskAction
public void setMainClassNameProperty() {
    Project project = getProject();
    if (!project.hasProperty("mainClassName")
            || project.property("mainClassName") == null) {
        String mainClass = findMainClass();
        if (project.hasProperty("mainClassName")) {
            project.setProperty("mainClassName", mainClass);
        }
        else {
            ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            extraProperties.set("mainClassName", mainClass);
        }
    }
}
项目:Pushjet-Android    文件:ScalaCompile.java   
@SuppressWarnings("unchecked")
private Map<File, File> getOrCreateGlobalAnalysisMap() {
    ExtraPropertiesExtension extraProperties = getProject().getRootProject().getExtensions().getExtraProperties();
    Map<File, File> analysisMap;

    if (extraProperties.has("scalaCompileAnalysisMap")) {
        analysisMap = (Map) extraProperties.get("scalaCompileAnalysisMap");
    } else {
        analysisMap = Maps.newHashMap();
        for (Project project : getProject().getRootProject().getAllprojects()) {
            for (ScalaCompile task : project.getTasks().withType(ScalaCompile.class)) {
                if (task.getScalaCompileOptions().isUseAnt()) { continue; }
                File publishedCode = task.getScalaCompileOptions().getIncrementalOptions().getPublishedCode();
                File analysisFile = task.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile();
                analysisMap.put(publishedCode, analysisFile);
            }
        }
        extraProperties.set("scalaCompileAnalysisMap", Collections.unmodifiableMap(analysisMap));
    }
    return analysisMap;
}
项目:Pushjet-Android    文件:ProjectPropertySettingBuildLoader.java   
private void addPropertiesToProject(Project 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!");
    }

    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        try {
            project.setProperty(entry.getKey(), entry.getValue());
        } catch (MissingPropertyException e) {
            if (!entry.getKey().equals(e.getProperty())) {
                throw e;
            }
            // Ignore and define as an extra property
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
项目:Pushjet-Android    文件:ScalaCompile.java   
@SuppressWarnings("unchecked")
private Map<File, File> getOrCreateGlobalAnalysisMap() {
    ExtraPropertiesExtension extraProperties = getProject().getRootProject().getExtensions().getExtraProperties();
    Map<File, File> analysisMap;

    if (extraProperties.has("scalaCompileAnalysisMap")) {
        analysisMap = (Map) extraProperties.get("scalaCompileAnalysisMap");
    } else {
        analysisMap = Maps.newHashMap();
        for (Project project : getProject().getRootProject().getAllprojects()) {
            for (ScalaCompile task : project.getTasks().withType(ScalaCompile.class)) {
                if (task.getScalaCompileOptions().isUseAnt()) { continue; }
                File publishedCode = task.getScalaCompileOptions().getIncrementalOptions().getPublishedCode();
                File analysisFile = task.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile();
                analysisMap.put(publishedCode, analysisFile);
            }
        }
        extraProperties.set("scalaCompileAnalysisMap", Collections.unmodifiableMap(analysisMap));
    }
    return analysisMap;
}
项目:Pushjet-Android    文件:ProjectPropertySettingBuildLoader.java   
private void addPropertiesToProject(Project 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!");
    }

    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        if (project.hasProperty(entry.getKey())) {
            project.setProperty(entry.getKey(), entry.getValue());    
        } else {
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
项目:Reer    文件:IdePlugin.java   
/**
 * Executes the provided Action after all projects have been evaluated.
 * Action will only be added once per provided key. Any subsequent calls for the same key will be ignored.
 * This permits the plugin to be applied in multiple subprojects, with the postprocess action executed once only.
 */
protected void postProcess(String key, final Action<? super Gradle> action) {
    Project rootProject = project.getRootProject();
    ExtraPropertiesExtension rootExtraProperties = rootProject.getExtensions().getByType(ExtraPropertiesExtension.class);
    String extraPropertyName = "org.gradle." + key + ".postprocess.applied";
    if (!rootExtraProperties.has(extraPropertyName)) {
        project.getGradle().addBuildListener(new BuildAdapter() {
            @Override
            public void projectsEvaluated(Gradle gradle) {
                action.execute(gradle);
            }
        });
        rootExtraProperties.set(extraPropertyName, true);
    }
}
项目:gradle-lazy-credentials    文件:PasswordPromptTest.java   
@Before
public void setUp() {
    project = mock(Project.class);
    // project.getExtensions().getExtraProperties().set(passwordProperty, pass);
    ExtensionContainer extensionContainer = mock(ExtensionContainer.class);
    when(project.getExtensions()).thenReturn(extensionContainer);
    extraProperties = mock(ExtraPropertiesExtension.class);
    when(extensionContainer.getExtraProperties()).thenReturn(extraProperties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RepackageTask.java   
private String getMainClassNameProperty() {
    if (getProject().hasProperty("mainClassName")) {
        return (String) getProject().property("mainClassName");
    }
    ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
            .getExtensions().getByName("ext");
    if (extraProperties.has("mainClassName")) {
        return (String) extraProperties.get("mainClassName");
    }
    return null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RunPluginFeatures.java   
private void addBootRunTask(final Project project) {
    final JavaPluginConvention javaConvention = project.getConvention()
            .getPlugin(JavaPluginConvention.class);

    BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
    run.setDescription("Run the project with support for "
            + "auto-detecting main class and reloading static resources");
    run.setGroup("application");
    run.setClasspath(
            javaConvention.getSourceSets().findByName("main").getRuntimeClasspath());
    run.getConventionMapping().map("main", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("mainClassName")
                    && project.property("mainClassName") != null) {
                return project.property("mainClassName");
            }
            ExtraPropertiesExtension extraPropertiesExtension = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            if (extraPropertiesExtension.has("mainClassName")
                    && extraPropertiesExtension.get("mainClassName") != null) {
                return extraPropertiesExtension.get("mainClassName");
            }
            return null;
        }
    });
    run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("applicationDefaultJvmArgs")) {
                return project.property("applicationDefaultJvmArgs");
            }
            return Collections.emptyList();
        }
    });
}
项目:spring-boot-concourse    文件:RepackageTask.java   
private String getMainClassNameProperty() {
    if (getProject().hasProperty("mainClassName")) {
        return (String) getProject().property("mainClassName");
    }
    ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
            .getExtensions().getByName("ext");
    return (String) extraProperties.get("mainClassName");
}
项目:spring-boot-concourse    文件:RunPluginFeatures.java   
private void addBootRunTask(final Project project) {
    final JavaPluginConvention javaConvention = project.getConvention()
            .getPlugin(JavaPluginConvention.class);

    BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
    run.setDescription("Run the project with support for "
            + "auto-detecting main class and reloading static resources");
    run.setGroup("application");
    run.setClasspath(
            javaConvention.getSourceSets().findByName("main").getRuntimeClasspath());
    run.getConventionMapping().map("main", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("mainClassName")
                    && project.property("mainClassName") != null) {
                return project.property("mainClassName");
            }
            ExtraPropertiesExtension extraPropertiesExtension = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            if (extraPropertiesExtension.has("mainClassName")
                    && extraPropertiesExtension.get("mainClassName") != null) {
                return extraPropertiesExtension.get("mainClassName");
            }
            return null;
        }
    });
    run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("applicationDefaultJvmArgs")) {
                return project.property("applicationDefaultJvmArgs");
            }
            return Collections.emptyList();
        }
    });
}
项目:speedment-gradle-plugin    文件:PluginUtils.java   
public static void setExtraProperty(Project project, String name, Object value) {
    LOGGER.debug("Setting extra property {}={} to project {}", name, value.toString(), project.getName());
    ExtraPropertiesExtension ext = project.getExtensions().getExtraProperties();
    if (ext != null) {
        if (ext.has(name)) {
            LOGGER.warn("Extra property {} is already set it will be overwritten.", name);
        }
        ext.set(name, value);
    } else {
        LOGGER.debug("Extra properties in project {} are not available.", project.getName());
    }
}
项目:contestparser    文件:RunPluginFeatures.java   
private void addBootRunTask(final Project project) {
    final JavaPluginConvention javaConvention = project.getConvention()
            .getPlugin(JavaPluginConvention.class);

    BootRunTask run = project.getTasks().create(RUN_APP_TASK_NAME, BootRunTask.class);
    run.setDescription("Run the project with support for "
            + "auto-detecting main class and reloading static resources");
    run.setGroup("application");
    run.setClasspath(
            javaConvention.getSourceSets().findByName("main").getRuntimeClasspath());
    run.getConventionMapping().map("main", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("mainClassName")
                    && project.property("mainClassName") != null) {
                return project.property("mainClassName");
            }
            ExtraPropertiesExtension extraPropertiesExtension = (ExtraPropertiesExtension) project
                    .getExtensions().getByName("ext");
            if (extraPropertiesExtension.has("mainClassName")
                    && extraPropertiesExtension.get("mainClassName") != null) {
                return extraPropertiesExtension.get("mainClassName");
            }
            return null;
        }
    });
    run.getConventionMapping().map("jvmArgs", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            if (project.hasProperty("applicationDefaultJvmArgs")) {
                return project.property("applicationDefaultJvmArgs");
            }
            return Collections.emptyList();
        }
    });
}
项目:checkstyle-addons    文件:BuildUtil.java   
/**
 * Read the value of an extra property of the project.
 *
 * @param pExtraPropName the reference to the extra property name
 * @param <T> type of the property value
 * @return the property's value
 */
@SuppressWarnings("unchecked")
public <T> T getExtraPropertyValue(@Nonnull final ExtProp pExtraPropName)
{
    ExtraPropertiesExtension extraProps = project.getExtensions().getByType(ExtraPropertiesExtension.class);
    if (extraProps.has(pExtraPropName.getPropertyName())) {
        return (T) extraProps.get(pExtraPropName.getPropertyName());
    }
    throw new GradleException(
        "Reference to non-existent project extra property '" + pExtraPropName.getPropertyName() + "'");
}
项目:Reer    文件:ExtensibleDynamicObject.java   
public ExtraPropertiesExtension getDynamicProperties() {
    return convention.getExtraProperties();
}
项目:Reer    文件:DefaultConvention.java   
public DefaultConvention(Instantiator instantiator) {
    this.instantiator = instantiator;
    add(ExtraPropertiesExtension.EXTENSION_NAME, extraProperties);
}
项目:Reer    文件:DefaultConvention.java   
public ExtraPropertiesExtension getExtraProperties() {
    return extraProperties;
}
项目:Reer    文件:ExtraPropertiesDynamicObjectAdapter.java   
public ExtraPropertiesDynamicObjectAdapter(Class<?> delegateType, ExtraPropertiesExtension extension) {
    this.delegateType = delegateType;
    this.extension = extension;
}
项目:Reer    文件:DefaultExtraPropertiesExtension.java   
public void setProperty(String name, Object newValue) {
    if (name.equals("properties")) {
        throw new ReadOnlyPropertyException("name", ExtraPropertiesExtension.class);
    }
    set(name, newValue);
}
项目:Pushjet-Android    文件:ExtensibleDynamicObject.java   
public ExtraPropertiesExtension getDynamicProperties() {
    return convention.getExtraProperties();
}
项目:Pushjet-Android    文件:DefaultConvention.java   
public DefaultConvention(Instantiator instantiator) {
    this.instantiator = instantiator;
    add(ExtraPropertiesExtension.EXTENSION_NAME, extraProperties);
}
项目:Pushjet-Android    文件:DefaultConvention.java   
public ExtraPropertiesExtension getExtraProperties() {
    return extraProperties;
}
项目:Pushjet-Android    文件:ExtraPropertiesDynamicObjectAdapter.java   
public ExtraPropertiesDynamicObjectAdapter(Class<?> delegateType, ExtraPropertiesExtension extension) {
    super(extension);
    this.delegateType = delegateType;
    this.extension = extension;
}
项目:Pushjet-Android    文件:DefaultExtraPropertiesExtension.java   
public void setProperty(String name, Object newValue) {
    if (name.equals("properties")) {
        throw new ReadOnlyPropertyException("name", ExtraPropertiesExtension.class);
    }
    set(name, newValue);
}
项目:Pushjet-Android    文件:ExtensibleDynamicObject.java   
public ExtraPropertiesExtension getDynamicProperties() {
    return convention.getExtraProperties();
}
项目:Pushjet-Android    文件:DefaultConvention.java   
public DefaultConvention(Instantiator instantiator) {
    this.instantiator = instantiator;
    add(ExtraPropertiesExtension.EXTENSION_NAME, extraProperties);
}
项目:Pushjet-Android    文件:DefaultConvention.java   
public ExtraPropertiesExtension getExtraProperties() {
    return extraProperties;
}
项目:Pushjet-Android    文件:ExtraPropertiesDynamicObjectAdapter.java   
public ExtraPropertiesDynamicObjectAdapter(Object delegate, DynamicObject dynamicOwner, ExtraPropertiesExtension extension) {
    super(extension);
    this.delegate = delegate;
    this.dynamicOwner = dynamicOwner;
    this.extension = extension;
}
项目:Pushjet-Android    文件:DefaultExtraPropertiesExtension.java   
public void setProperty(String name, Object newValue) {
    if (name.equals("properties")) {
        throw new ReadOnlyPropertyException("name", ExtraPropertiesExtension.class);
    }
    set(name, newValue);
}
项目:gradle-stdproject-plugin    文件:StdProjectPlugin.java   
public static <T> T getExtraPropertyOrNull(@Nonnull Project project, @Nonnull String name) {
    ExtraPropertiesExtension properties = project.getExtensions().getExtraProperties();
    if (properties.has(name))
        return (T) properties.get(name);
    return null;
}
项目:gradle-defaults    文件:ExtLicensePlugin.java   
private static ExtraPropertiesExtension ext(Object licenseExt) {
    val metaClass = ((GroovyObject)licenseExt).getMetaClass();
    val conExtPropsProp = metaClass.getMetaProperty("extensions");
    val convExtensions = (Convention)conExtPropsProp.getProperty(licenseExt);
    return convExtensions.getExtraProperties();
}
项目:jenetics    文件:PropertiesLoader.java   
public PropertiesLoader(final ExtraPropertiesExtension ext) {
    _ext = requireNonNull(ext, "Properties must not be null.");
}