本文整理汇总了Java中org.gradle.model.ModelMap类的典型用法代码示例。如果您正苦于以下问题:Java ModelMap类的具体用法?Java ModelMap怎么用?Java ModelMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelMap类属于org.gradle.model包,在下文中一共展示了ModelMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBinaries
import org.gradle.model.ModelMap; //导入依赖的package包/类
@ComponentBinaries
public void createBinaries(ModelMap<JarBinarySpec> binaries, PlatformResolvers platforms, final JvmLibrarySpecInternal jvmLibrary) {
List<JavaPlatform> selectedPlatforms = resolvePlatforms(platforms, jvmLibrary);
final Set<String> exportedPackages = exportedPackagesOf(jvmLibrary);
final Collection<DependencySpec> apiDependencies = apiDependenciesOf(jvmLibrary);
final Collection<DependencySpec> dependencies = componentDependenciesOf(jvmLibrary);
for (final JavaPlatform platform : selectedPlatforms) {
final BinaryNamingScheme namingScheme = namingSchemeFor(jvmLibrary, selectedPlatforms, platform);
binaries.create(namingScheme.getBinaryName(), new Action<JarBinarySpec>() {
@Override
public void execute(JarBinarySpec jarBinarySpec) {
JarBinarySpecInternal jarBinary = (JarBinarySpecInternal) jarBinarySpec;
jarBinary.setNamingScheme(namingScheme);
jarBinary.setTargetPlatform(platform);
jarBinary.setExportedPackages(exportedPackages);
jarBinary.setApiDependencies(apiDependencies);
jarBinary.setDependencies(dependencies);
}
});
}
}
示例2: execute
import org.gradle.model.ModelMap; //导入依赖的package包/类
@Override
protected void execute(ModelRuleInvoker<?> invoker, final T binary, List<ModelView<?>> inputs) {
NamedEntityInstantiator<Task> taskFactory = Cast.uncheckedCast(ModelViews.getInstance(inputs.get(0), TASK_FACTORY));
ModelMap<Task> cast = DomainObjectCollectionBackedModelMap.wrap(
"tasks",
Task.class,
binary.getTasks(),
taskFactory,
new Task.Namer(),
new Action<Task>() {
@Override
public void execute(Task task) {
binary.getTasks().add(task);
binary.builtBy(task);
}
});
List<ModelView<?>> inputsWithBinary = new ArrayList<ModelView<?>>(inputs.size());
inputsWithBinary.addAll(inputs.subList(1, inputs.size()));
inputsWithBinary.add(InstanceModelView.of(getSubject().getPath(), getSubject().getType(), binary));
invoke(invoker, inputsWithBinary, cast, binary, binary);
}
示例3: visitSubject
import org.gradle.model.ModelMap; //导入依赖的package包/类
protected <V> void visitSubject(RuleMethodDataCollector dataCollector, MethodRuleDefinition<?, ?> ruleDefinition, ModelType<V> typeParameter, RuleSourceValidationProblemCollector problems) {
if (ruleDefinition.getReferences().size() == 0) {
problems.add(ruleDefinition, "A method " + getDescription() + " must have at least two parameters.");
return;
}
ModelType<?> subjectType = ruleDefinition.getSubjectReference().getType();
if (!isModelMap(subjectType)) {
problems.add(ruleDefinition, String.format("The first parameter of a method %s must be of type %s.", getDescription(), ModelMap.class.getName()));
return;
}
List<ModelType<?>> typeVariables = subjectType.getTypeVariables();
if (typeVariables.size() != 1) {
problems.add(ruleDefinition, String.format("Parameter of type %s must declare a type parameter extending %s.", ModelMap.class.getSimpleName(), typeParameter.getDisplayName()));
return;
}
ModelType<?> elementType = typeVariables.get(0);
if (elementType.isWildcard()) {
problems.add(ruleDefinition, String.format("%s type %s cannot be a wildcard type (i.e. cannot use ? super, ? extends etc.).", typeParameter.getDisplayName(), elementType.getDisplayName()));
return;
}
dataCollector.parameterTypes.put(typeParameter, elementType);
}
示例4: invoke
import org.gradle.model.ModelMap; //导入依赖的package包/类
protected void invoke(ModelRuleInvoker<?> ruleInvoker, List<ModelView<?>> inputs, ModelMap<?> modelMap, T baseTypeParameter, Object... ignoredInputs) {
List<Object> ignoredInputsList = Arrays.asList(ignoredInputs);
Object[] args = new Object[inputs.size() + 2 - ignoredInputs.length];
args[0] = modelMap;
args[baseTypeParameterIndex] = baseTypeParameter;
for (ModelView<?> view : inputs) {
Object instance = view.getInstance();
if (ignoredInputsList.contains(instance)) {
continue;
}
for (int i = 0; i < args.length; i++) {
if (args[i] == null) {
args[i] = instance;
break;
}
}
}
ruleInvoker.invoke(args);
}
示例5: extract
import org.gradle.model.ModelMap; //导入依赖的package包/类
@Override
public <T> void extract(ModelSchemaExtractionContext<T> extractionContext) {
ModelType<T> type = extractionContext.getType();
if (MODEL_MAP_MODEL_TYPE.isAssignableFrom(type)) {
if (!type.getRawClass().equals(ModelMap.class)) {
extractionContext.add(String.format("subtyping %s is not supported.", ModelMap.class.getName()));
return;
}
if (type.isHasWildcardTypeVariables()) {
extractionContext.add(String.format("type parameter of %s cannot be a wildcard.", ModelMap.class.getName()));
return;
}
List<ModelType<?>> typeVariables = type.getTypeVariables();
if (typeVariables.isEmpty()) {
extractionContext.add(String.format("type parameter of %s has to be specified.", ModelMap.class.getName()));
return;
}
ModelType<?> elementType = typeVariables.get(0);
extractionContext.found(getModelSchema(extractionContext, elementType));
}
}
示例6: itemType
import org.gradle.model.ModelMap; //导入依赖的package包/类
private ModelType<? extends I> itemType(ModelType<?> targetType) {
Class<?> targetClass = targetType.getRawClass();
if (targetClass.equals(ModelMap.class)) {
ModelType<?> targetItemClass = targetType.getTypeVariables().get(0);
if (targetItemClass.isAssignableFrom(baseItemModelType)) {
return baseItemModelType;
}
if (baseItemModelType.isAssignableFrom(targetItemClass)) {
return targetItemClass.asSubtype(baseItemModelType);
}
return null;
}
if (targetClass.isAssignableFrom(ModelMap.class)) {
return baseItemModelType;
}
return null;
}
示例7: linkTestSuiteBinariesRunTaskToBinariesCheckTasks
import org.gradle.model.ModelMap; //导入依赖的package包/类
@Finalize
void linkTestSuiteBinariesRunTaskToBinariesCheckTasks(@Path("binaries") ModelMap<TestSuiteBinarySpec> binaries) {
binaries.afterEach(new Action<TestSuiteBinarySpec>() {
@Override
public void execute(TestSuiteBinarySpec testSuiteBinary) {
if (testSuiteBinary.isBuildable()) {
if (testSuiteBinary.getTasks() instanceof TestSuiteTaskCollection) {
testSuiteBinary.checkedBy(((TestSuiteTaskCollection) testSuiteBinary.getTasks()).getRun());
}
BinarySpec testedBinary = testSuiteBinary.getTestedBinary();
if (testedBinary != null && testedBinary.isBuildable()) {
testedBinary.checkedBy(testSuiteBinary.getCheckTask());
}
}
}
});
}
示例8: realizePublishingTasks
import org.gradle.model.ModelMap; //导入依赖的package包/类
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(ModelMap<Task> tasks, PublishingExtension extension, @Path("buildDir") File buildDir) {
// Create generatePom tasks for any Maven publication
PublicationContainer publications = extension.getPublications();
Task publishLifecycleTask = tasks.get(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
Task publishLocalLifecycleTask = tasks.get(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
String publicationName = publication.getName();
createGeneratePomTask(tasks, publication, publicationName, buildDir);
createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
}
}
示例9: createPublishTasksForEachMavenRepo
import org.gradle.model.ModelMap; //导入依赖的package包/类
private void createPublishTasksForEachMavenRepo(ModelMap<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication,
final String publicationName) {
for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) {
final String repositoryName = repository.getName();
String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository";
tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() {
public void execute(PublishToMavenRepository publishTask) {
publishTask.setPublication(publication);
publishTask.setRepository(repository);
publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
publishTask.setDescription("Publishes Maven publication '" + publicationName + "' to Maven repository '" + repositoryName + "'.");
}
});
publishLifecycleTask.dependsOn(publishTaskName);
}
}
示例10: createNativeBinaries
import org.gradle.model.ModelMap; //导入依赖的package包/类
public static void createNativeBinaries(
NativeComponentSpec component,
ModelMap<NativeBinarySpec> binaries,
NativeDependencyResolver resolver,
FileCollectionFactory fileCollectionFactory,
BinaryNamingScheme namingScheme,
NativePlatform platform,
BuildType buildType,
Flavor flavor
) {
if (component instanceof NativeLibrarySpec) {
createNativeBinary(SharedLibraryBinarySpec.class, binaries, resolver, fileCollectionFactory, namingScheme.withBinaryType("SharedLibrary").withRole("shared", false), platform, buildType, flavor);
createNativeBinary(StaticLibraryBinarySpec.class, binaries, resolver, fileCollectionFactory, namingScheme.withBinaryType("StaticLibrary").withRole("static", false), platform, buildType, flavor);
} else {
createNativeBinary(NativeExecutableBinarySpec.class, binaries, resolver, fileCollectionFactory, namingScheme.withBinaryType("Executable").withRole("executable", true), platform, buildType, flavor);
}
}
示例11: getBinaries
import org.gradle.model.ModelMap; //导入依赖的package包/类
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
if (components == null) {
return null;
}
String libraryName = libraryIdentifier.getLibraryName();
NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
if (library == null) {
return null;
}
ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
binaries.add((NativeLibraryBinary) nativeBinarySpec);
}
return binaries;
}
示例12: createBuildDependentComponentsTasks
import org.gradle.model.ModelMap; //导入依赖的package包/类
public static void createBuildDependentComponentsTasks(ModelMap<Task> tasks, ComponentSpecContainer components) {
for (final VariantComponentSpec component : components.withType(NativeComponentSpec.class).withType(VariantComponentSpec.class)) {
tasks.create(getAssembleDependentComponentsTaskName(component), DefaultTask.class, new Action<DefaultTask>() {
@Override
public void execute(DefaultTask assembleDependents) {
assembleDependents.setGroup("Build Dependents");
assembleDependents.setDescription("Assemble dependents of " + component.getDisplayName() + ".");
}
});
tasks.create(getBuildDependentComponentsTaskName(component), DefaultTask.class, new Action<DefaultTask>() {
@Override
public void execute(DefaultTask buildDependents) {
buildDependents.setGroup("Build Dependents");
buildDependents.setDescription("Build dependents of " + component.getDisplayName() + ".");
}
});
}
}
示例13: sharedLibraryTasks
import org.gradle.model.ModelMap; //导入依赖的package包/类
@BinaryTasks
public void sharedLibraryTasks(ModelMap<Task> tasks, final SharedLibraryBinarySpecInternal binary) {
String taskName = binary.getNamingScheme().getTaskName("link");
tasks.create(taskName, LinkSharedLibrary.class, new Action<LinkSharedLibrary>() {
@Override
public void execute(LinkSharedLibrary linkTask) {
linkTask.setDescription("Links " + binary.getDisplayName());
linkTask.setToolChain(binary.getToolChain());
linkTask.setTargetPlatform(binary.getTargetPlatform());
linkTask.setOutputFile(binary.getSharedLibraryFile());
linkTask.setInstallName(binary.getSharedLibraryFile().getName());
linkTask.setLinkerArgs(binary.getLinker().getArgs());
linkTask.lib(new NativeComponents.BinaryLibs(binary) {
@Override
protected FileCollection getFiles(NativeDependencySet nativeDependencySet) {
return nativeDependencySet.getLinkFiles();
}
});
}
});
}
示例14: createJvmTestSuiteBinaries
import org.gradle.model.ModelMap; //导入依赖的package包/类
/**
* Create binaries for test suites. TODO: This should really be a @ComponentBinaries rule, but at this point we have no clue what the concrete binary type is, so everything has to be duplicated in
* specific plugins. See usages for example.
*/
public static void createJvmTestSuiteBinaries(ModelMap<BinarySpec> testBinaries,
PlatformResolvers platformResolver,
JvmTestSuiteSpec testSuite,
JavaToolChainRegistry toolChains,
Class<? extends JvmTestSuiteBinarySpec> testSuiteBinary) {
JvmComponentSpec testedComponent = testSuite.getTestedComponent();
if (testedComponent == null) {
// standalone test suite
createJvmTestSuiteBinary(testBinaries, testSuiteBinary, testSuite, null, toolChains, platformResolver);
} else {
// component under test
for (final JvmBinarySpec testedBinary : testedBinariesOf(testSuite)) {
createJvmTestSuiteBinary(testBinaries, testSuiteBinary, testSuite, testedBinary, toolChains, platformResolver);
}
}
}
示例15: createDebugTasks
import org.gradle.model.ModelMap; //导入依赖的package包/类
/**
* Create debug tasks
*
* @param tasks Task container to create new tasks
* @param config Project configuration
* @param project Current project identifier
*/
@Mutate
public void createDebugTasks(ModelMap<Task> tasks, ProjectConfig config, ProjectIdentifier project) {
// Create debug task to dump dependencies
if (config.isEnableDebugTasks()) {
tasks.create("debugDependencies", Task.class, tt -> {
tt.doLast(t -> {
PrintStream out = System.out;
out.print("Project: ");
out.println(project.getName());
for (Configuration configuration : t.getProject().getConfigurations()) {
out.print(" Configuration: ");
out.println(configuration.getName());
for (Dependency dependency : configuration.getDependencies()) {
out.print(" Dependency: ");
out.println(formatDependency(dependency));
}
}
});
});
}
}