org.gradle.api.attributes.Usage Java Examples

The following examples show how to use org.gradle.api.attributes.Usage. 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: CppPublicMacrosPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
private static Configuration createElementsConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) {
    return configurations.create("cppPublicMacrosElements", new Action<Configuration>() {
        @Override
        public void execute(Configuration configuration) {
            configurations.all(new Action<Configuration>() {
                @Override
                public void execute(Configuration it) {
                    if (it.getName().toLowerCase().endsWith("implementation")) {
                        configuration.extendsFrom(it);
                    }
                }
            });
            configuration.setCanBeConsumed(true);
            configuration.setCanBeResolved(false);
            configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros"));
        }
    });
}
 
Example #2
Source File: OptionalDependenciesPlugin.java    From reactor-core with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
	Configuration optional = project.getConfigurations().create(OPTIONAL_CONFIGURATION_NAME);
	optional.attributes((attributes) -> attributes.attribute(Usage.USAGE_ATTRIBUTE,
			project.getObjects().named(Usage.class, Usage.JAVA_RUNTIME)));
	project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
		SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
		                                       .getSourceSets();
		sourceSets.all((sourceSet) -> {
			sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(optional));
			sourceSet.setRuntimeClasspath(sourceSet.getRuntimeClasspath().plus(optional));
		});
		project.getTasks().withType(Javadoc.class)
		       .all((javadoc) -> javadoc.setClasspath(javadoc.getClasspath().plus(optional)));
	});
	project.getPlugins().withType(EclipsePlugin.class,
			(eclipsePlugin) -> project.getExtensions().getByType(EclipseModel.class)
			                          .classpath((classpath) -> classpath.getPlusConfigurations().add(optional)));
}
 
Example #3
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
@Override
public Set<? extends UsageContext> getUsages() {
    Set<UsageContext> result = new HashSet<>();

    AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes());
    linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
    linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link));

    AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes());
    runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
    runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime));

    return result;
}
 
Example #4
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
@Override
public Set<? extends UsageContext> getUsages() {
    Set<UsageContext> result = new HashSet<>();

    AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes());
    linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
    linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link));

    AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes());
    runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
    runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime));

    return result;
}
 
Example #5
Source File: CppPublicMacrosPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
private static Configuration createConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) {
    return configurations.create("cppPublicMacros", new Action<Configuration>() {
        @Override
        public void execute(Configuration configuration) {
            configurations.all(new Action<Configuration>() {
                @Override
                public void execute(Configuration it) {
                    if (it.getName().toLowerCase().endsWith("implementation")) {
                        configuration.extendsFrom(it);
                    }
                }
            });
            configuration.setCanBeConsumed(false);
            configuration.setCanBeResolved(true);
            configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros"));
        }
    });
}
 
Example #6
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
@Override
public Set<? extends UsageContext> getUsages() {
    Set<UsageContext> result = new HashSet<>();

    AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes());
    linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
    linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link));

    AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes());
    runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
    runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime));

    return result;
}
 
Example #7
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 6 votes vote down vote up
@Override
public Set<? extends UsageContext> getUsages() {
    Set<UsageContext> result = new HashSet<>();

    AttributeContainer linkAttributes = attributesFactory.mutable((AttributeContainerInternal) link.getAttributes().getAttributes());
    linkAttributes.attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
    linkAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Link", linkAttributes, link.getArtifacts(), link));

    AttributeContainer runtimeAttributes = attributesFactory.mutable((AttributeContainerInternal) runtime.getAttributes().getAttributes());
    runtimeAttributes.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
    runtimeAttributes.attribute(LINKAGE_ATTRIBUTE, Linkage.SHARED);
    result.add(new DefaultUsageContext(variantName + "Runtime", runtimeAttributes, runtime.getArtifacts(), runtime));

    return result;
}
 
Example #8
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultWrappedPublishableComponent(String variantName, Object group, String projectName, Object version, Usage linkUsage, Configuration link, Usage runtimeUsage, Configuration runtime, ImmutableAttributesFactory attributesFactory) {
    this.attributesFactory = attributesFactory;
    this.variantName = variantName;
    this.group = group;
    this.projectName = projectName;
    this.version = version;
    this.linkUsage = linkUsage;
    this.link = link;
    this.runtimeUsage = runtimeUsage;
    this.runtime = runtime;
}
 
Example #9
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) {
    this.baseName = baseName;

    AttributeContainer publicationAttributes = immutableAttributesFactory.mutable();
    publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage);
    publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE);
    this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory);
}
 
Example #10
Source File: WrappedNativeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-base");

    // Add configurations for incoming dependencies
    final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API);
    final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK);

    Configuration implementation = project.getConfigurations().create("implementation", it -> {
        it.setCanBeConsumed(false);
        it.setCanBeResolved(false);
    });

    // incoming compile time headers
    project.getConfigurations().create("cppCompile", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage);
        it.extendsFrom(implementation);
    });

    // incoming link files
    project.getConfigurations().create("linkDebug", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false);
        it.extendsFrom(implementation);
    });
    project.getConfigurations().create("linkRelease", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true);
        it.extendsFrom(implementation);
    });
}
 
Example #11
Source File: WrappedNativeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-base");

    // Add configurations for incoming dependencies
    final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API);
    final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK);

    Configuration implementation = project.getConfigurations().create("implementation", it -> {
        it.setCanBeConsumed(false);
        it.setCanBeResolved(false);
    });

    // incoming compile time headers
    project.getConfigurations().create("cppCompile", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage);
        it.extendsFrom(implementation);
    });

    // incoming link files
    project.getConfigurations().create("linkDebug", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false);
        it.extendsFrom(implementation);
    });
    project.getConfigurations().create("linkRelease", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true);
        it.extendsFrom(implementation);
    });
}
 
Example #12
Source File: AndroidComponent.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AndroidComponent(Configuration compileConfiguration, DependencySet compileDependencies, Project project) {
    this.compileConfiguration = compileConfiguration;
    this.compileDependencies = compileDependencies;
    this.project = project;
    ObjectFactory factory = project.getObjects();
    apiUsage = factory.named(Usage.class, Usage.JAVA_API);
    runtimeUsage = factory.named(Usage.class, Usage.JAVA_RUNTIME);

}
 
Example #13
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) {
    this.baseName = baseName;

    AttributeContainer publicationAttributes = immutableAttributesFactory.mutable();
    publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage);
    publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE);
    this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory);
}
 
Example #14
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultWrappedPublishableComponent(String variantName, Object group, String projectName, Object version, Usage linkUsage, Configuration link, Usage runtimeUsage, Configuration runtime, ImmutableAttributesFactory attributesFactory) {
    this.attributesFactory = attributesFactory;
    this.variantName = variantName;
    this.group = group;
    this.projectName = projectName;
    this.version = version;
    this.linkUsage = linkUsage;
    this.link = link;
    this.runtimeUsage = runtimeUsage;
    this.runtime = runtime;
}
 
Example #15
Source File: WrappedNativeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-base");

    // Add configurations for incoming dependencies
    final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API);
    final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK);

    Configuration implementation = project.getConfigurations().create("implementation", it -> {
        it.setCanBeConsumed(false);
        it.setCanBeResolved(false);
    });

    // incoming compile time headers
    project.getConfigurations().create("cppCompile", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage);
        it.extendsFrom(implementation);
    });

    // incoming link files
    project.getConfigurations().create("linkDebug", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false);
        it.extendsFrom(implementation);
    });
    project.getConfigurations().create("linkRelease", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true);
        it.extendsFrom(implementation);
    });
}
 
Example #16
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) {
    this.baseName = baseName;

    AttributeContainer publicationAttributes = immutableAttributesFactory.mutable();
    publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage);
    publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE);
    this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory);
}
 
Example #17
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultWrappedPublishableComponent(String variantName, Object group, String projectName, Object version, Usage linkUsage, Configuration link, Usage runtimeUsage, Configuration runtime, ImmutableAttributesFactory attributesFactory) {
    this.attributesFactory = attributesFactory;
    this.variantName = variantName;
    this.group = group;
    this.projectName = projectName;
    this.version = version;
    this.linkUsage = linkUsage;
    this.link = link;
    this.runtimeUsage = runtimeUsage;
    this.runtime = runtime;
}
 
Example #18
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultWrappedPublishableComponent(String variantName, Object group, String projectName, Object version, Usage linkUsage, Configuration link, Usage runtimeUsage, Configuration runtime, ImmutableAttributesFactory attributesFactory) {
    this.attributesFactory = attributesFactory;
    this.variantName = variantName;
    this.group = group;
    this.projectName = projectName;
    this.version = version;
    this.linkUsage = linkUsage;
    this.link = link;
    this.runtimeUsage = runtimeUsage;
    this.runtime = runtime;
}
 
Example #19
Source File: WrappedNativeApplicationPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPluginManager().apply("org.gradle.samples.wrapped-native-base");

    // Add configurations for incoming dependencies
    final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API);
    final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK);

    Configuration implementation = project.getConfigurations().create("implementation", it -> {
        it.setCanBeConsumed(false);
        it.setCanBeResolved(false);
    });

    // incoming compile time headers
    project.getConfigurations().create("cppCompile", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage);
        it.extendsFrom(implementation);
    });

    // incoming link files
    project.getConfigurations().create("linkDebug", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false);
        it.extendsFrom(implementation);
    });
    project.getConfigurations().create("linkRelease", it -> {
        it.setCanBeConsumed(false);
        it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage);
        it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true);
        it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true);
        it.extendsFrom(implementation);
    });
}
 
Example #20
Source File: WrappedNativeLibraryPlugin.java    From native-samples with Apache License 2.0 5 votes vote down vote up
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) {
    this.baseName = baseName;

    AttributeContainer publicationAttributes = immutableAttributesFactory.mutable();
    publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage);
    publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE);
    this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory);
}