use of org.gradle.api.Project in project atlas by alibaba.
the class AppVariantContext method getAwSourceOutputDir.
public List<ConfigurableFileTree> getAwSourceOutputDir(AwbBundle awbBundle) {
Project project = scope.getGlobalScope().getProject();
// Build the list of source folders.
ImmutableList.Builder<ConfigurableFileTree> sourceSets = ImmutableList.builder();
// then all the generated src folders.
if (getAwbRClassSourceOutputDir(awbBundle) != null) {
sourceSets.add(project.fileTree(getAwbRClassSourceOutputDir(awbBundle)));
}
if (scope.getGlobalScope().getExtension().getDataBinding().isEnabled()) {
sourceSets.add(project.fileTree(getAwbClassOutputForDataBinding(awbBundle)));
}
return sourceSets.build();
}
use of org.gradle.api.Project in project intellij-community by JetBrains.
the class ModelBuildScriptClasspathBuilderImpl method buildAll.
@Nullable
@Override
public Object buildAll(final String modelName, final Project project) {
BuildScriptClasspathModelImpl buildScriptClasspath = cache.get(project.getPath());
if (buildScriptClasspath != null)
return buildScriptClasspath;
if (mySourceSetFinder == null)
mySourceSetFinder = new SourceSetCachedFinder(project);
buildScriptClasspath = new BuildScriptClasspathModelImpl();
final File gradleHomeDir = project.getGradle().getGradleHomeDir();
buildScriptClasspath.setGradleHomeDir(gradleHomeDir);
buildScriptClasspath.setGradleVersion(GradleVersion.current().getVersion());
boolean downloadJavadoc = false;
boolean downloadSources = true;
final IdeaPlugin ideaPlugin = project.getPlugins().findPlugin(IdeaPlugin.class);
if (ideaPlugin != null) {
final IdeaModule ideaModule = ideaPlugin.getModel().getModule();
downloadJavadoc = ideaModule.isDownloadJavadoc();
downloadSources = ideaModule.isDownloadSources();
}
Project parent = project.getParent();
if (parent != null) {
BuildScriptClasspathModelImpl parentBuildScriptClasspath = (BuildScriptClasspathModelImpl) buildAll(modelName, parent);
if (parentBuildScriptClasspath != null) {
for (ClasspathEntryModel classpathEntryModel : parentBuildScriptClasspath.getClasspath()) {
buildScriptClasspath.add(classpathEntryModel);
}
}
}
Configuration classpathConfiguration = project.getBuildscript().getConfigurations().findByName(CLASSPATH_CONFIGURATION_NAME);
if (classpathConfiguration == null)
return null;
Collection<ExternalDependency> dependencies = new DependencyResolverImpl(project, false, downloadJavadoc, downloadSources, mySourceSetFinder).resolveDependencies(classpathConfiguration);
for (ExternalDependency dependency : new DependencyTraverser(dependencies)) {
if (dependency instanceof ExternalLibraryDependency) {
final ExternalLibraryDependency libraryDep = (ExternalLibraryDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(libraryDep.getFile()), pathSet(libraryDep.getSource()), pathSet(libraryDep.getJavadoc())));
}
if (dependency instanceof ExternalMultiLibraryDependency) {
ExternalMultiLibraryDependency multiLibraryDependency = (ExternalMultiLibraryDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(multiLibraryDependency.getFiles()), pathSet(multiLibraryDependency.getSources()), pathSet(multiLibraryDependency.getJavadoc())));
}
if (dependency instanceof FileCollectionDependency) {
FileCollectionDependency fileCollectionDependency = (FileCollectionDependency) dependency;
buildScriptClasspath.add(new ClasspathEntryModelImpl(pathSet(fileCollectionDependency.getFiles()), new HashSet<String>(), new HashSet<String>()));
}
}
cache.put(project.getPath(), buildScriptClasspath);
return buildScriptClasspath;
}
use of org.gradle.api.Project in project meecrowave by apache.
the class MeecrowaveTask method fixConfig.
private void fixConfig() {
final Project project = getProject();
// defaults
if (classpath == null) {
classpath = project.getConfigurations().getByName(MeecrowavePlugin.NAME);
}
if (dir == null) {
dir = new File(project.getBuildDir(), "meecrowave/run").getAbsolutePath();
}
// extension override
final MeecrowaveExtension extension = MeecrowaveExtension.class.cast(project.getExtensions().findByName(MeecrowavePlugin.NAME));
if (extension != null) {
for (final Field f : MeecrowaveTask.class.getDeclaredFields()) {
if (f.isAnnotationPresent(Input.class)) {
try {
final Field extField = MeecrowaveExtension.class.getDeclaredField(f.getName());
if (!extField.isAccessible()) {
extField.setAccessible(true);
}
final Object val = extField.get(extension);
if (val != null) {
if (!f.isAccessible()) {
f.setAccessible(true);
}
f.set(this, val);
}
} catch (final IllegalAccessException | NoSuchFieldException e) {
getLogger().debug("No field " + f.getName() + " in " + extension, e);
}
}
}
}
}
use of org.gradle.api.Project in project gradle by gradle.
the class XCTestConventionPlugin method apply.
@Override
public void apply(ProjectInternal project) {
project.getPluginManager().apply(SwiftBasePlugin.class);
project.getPluginManager().apply(NativeTestingBasePlugin.class);
// Create test suite component
final DefaultSwiftXCTestSuite testComponent = createTestSuite(project);
project.afterEvaluate(new Action<Project>() {
@Override
public void execute(final Project project) {
String operatingSystemSuffix = "";
OperatingSystemFamily operatingSystem = objectFactory.named(OperatingSystemFamily.class, DefaultNativePlatform.getCurrentOperatingSystem().toFamilyName());
Usage runtimeUsage = objectFactory.named(Usage.class, Usage.NATIVE_RUNTIME);
Provider<String> group = project.provider(new Callable<String>() {
@Override
public String call() throws Exception {
return project.getGroup().toString();
}
});
Provider<String> version = project.provider(new Callable<String>() {
@Override
public String call() throws Exception {
return project.getVersion().toString();
}
});
AttributeContainer attributesDebug = attributesFactory.mutable();
attributesDebug.attribute(Usage.USAGE_ATTRIBUTE, runtimeUsage);
attributesDebug.attribute(DEBUGGABLE_ATTRIBUTE, true);
attributesDebug.attribute(OPTIMIZED_ATTRIBUTE, false);
NativeVariantIdentity debugVariant = new NativeVariantIdentity("debug" + operatingSystemSuffix, testComponent.getModule(), group, version, true, false, operatingSystem, null, new DefaultUsageContext("debug" + operatingSystemSuffix + "-runtime", runtimeUsage, attributesDebug));
ToolChainSelector.Result<SwiftPlatform> result = toolChainSelector.select(SwiftPlatform.class);
// Create test suite executable
DefaultSwiftXCTestBinary binary;
if (result.getTargetPlatform().getOperatingSystem().isMacOsX()) {
binary = (DefaultSwiftXCTestBinary) testComponent.addBundle("executable", debugVariant, result.getTargetPlatform(), result.getToolChain(), result.getPlatformToolProvider());
} else {
binary = (DefaultSwiftXCTestBinary) testComponent.addExecutable("executable", debugVariant, result.getTargetPlatform(), result.getToolChain(), result.getPlatformToolProvider());
}
testComponent.getTestBinary().set(binary);
// TODO: Publishing for test executable?
final ProductionSwiftComponent mainComponent = project.getComponents().withType(ProductionSwiftComponent.class).findByName("main");
if (mainComponent != null) {
testComponent.getTestedComponent().set(mainComponent);
// Test configuration extends main configuration
testComponent.getImplementationDependencies().extendsFrom(mainComponent.getImplementationDependencies());
project.getDependencies().add(binary.getImportPathConfiguration().getName(), project);
}
testComponent.getBinaries().whenElementKnown(DefaultSwiftXCTestBinary.class, new Action<DefaultSwiftXCTestBinary>() {
@Override
public void execute(DefaultSwiftXCTestBinary binary) {
// Create test suite test task
XCTest testingTask = createTestingTask(project);
binary.getRunTask().set(testingTask);
// Configure tasks
configureTestingTask(binary, testingTask);
configureTestSuiteBuildingTasks((ProjectInternal) project, binary);
configureTestSuiteWithTestedComponentWhenAvailable(project, testComponent, binary);
}
});
testComponent.getBinaries().realizeNow();
}
});
}
use of org.gradle.api.Project in project gradle by gradle.
the class DefaultTaskExecutionPlan method determineExecutionPlan.
public void determineExecutionPlan() {
List<TaskInfoInVisitingSegment> nodeQueue = Lists.newArrayList(Iterables.transform(entryTasks, new Function<TaskInfo, TaskInfoInVisitingSegment>() {
int index;
public TaskInfoInVisitingSegment apply(TaskInfo taskInfo) {
return new TaskInfoInVisitingSegment(taskInfo, index++);
}
}));
int visitingSegmentCounter = nodeQueue.size();
HashMultimap<TaskInfo, Integer> visitingNodes = HashMultimap.create();
Deque<GraphEdge> walkedShouldRunAfterEdges = new ArrayDeque<GraphEdge>();
Deque<TaskInfo> path = new ArrayDeque<TaskInfo>();
HashMap<TaskInfo, Integer> planBeforeVisiting = new HashMap<TaskInfo, Integer>();
while (!nodeQueue.isEmpty()) {
TaskInfoInVisitingSegment taskInfoInVisitingSegment = nodeQueue.get(0);
int currentSegment = taskInfoInVisitingSegment.visitingSegment;
TaskInfo taskNode = taskInfoInVisitingSegment.taskInfo;
if (taskNode.isIncludeInGraph() || executionPlan.containsKey(taskNode.getTask())) {
nodeQueue.remove(0);
visitingNodes.remove(taskNode, currentSegment);
maybeRemoveProcessedShouldRunAfterEdge(walkedShouldRunAfterEdges, taskNode);
continue;
}
boolean alreadyVisited = visitingNodes.containsKey(taskNode);
visitingNodes.put(taskNode, currentSegment);
if (!alreadyVisited) {
// Have not seen this task before - add its dependencies to the head of the queue and leave this
// task in the queue
recordEdgeIfArrivedViaShouldRunAfter(walkedShouldRunAfterEdges, path, taskNode);
removeShouldRunAfterSuccessorsIfTheyImposeACycle(visitingNodes, taskInfoInVisitingSegment);
takePlanSnapshotIfCanBeRestoredToCurrentTask(planBeforeVisiting, taskNode);
ArrayList<TaskInfo> successors = new ArrayList<TaskInfo>();
addAllSuccessorsInReverseOrder(taskNode, successors);
for (TaskInfo successor : successors) {
if (visitingNodes.containsEntry(successor, currentSegment)) {
if (!walkedShouldRunAfterEdges.isEmpty()) {
// remove the last walked should run after edge and restore state from before walking it
GraphEdge toBeRemoved = walkedShouldRunAfterEdges.pop();
toBeRemoved.from.removeShouldRunAfterSuccessor(toBeRemoved.to);
restorePath(path, toBeRemoved);
restoreQueue(nodeQueue, visitingNodes, toBeRemoved);
restoreExecutionPlan(planBeforeVisiting, toBeRemoved);
break;
} else {
onOrderingCycle();
}
}
nodeQueue.add(0, new TaskInfoInVisitingSegment(successor, currentSegment));
}
path.push(taskNode);
} else {
// Have visited this task's dependencies - add it to the end of the plan
nodeQueue.remove(0);
maybeRemoveProcessedShouldRunAfterEdge(walkedShouldRunAfterEdges, taskNode);
visitingNodes.remove(taskNode, currentSegment);
path.pop();
executionPlan.put(taskNode.getTask(), taskNode);
Project project = taskNode.getTask().getProject();
projectLocks.put(project, getOrCreateProjectLock(project));
TaskMutationInfo taskMutationInfo = getOrCreateMutationsOf(taskNode);
for (TaskInfo dependency : taskNode.getDependencySuccessors()) {
getOrCreateMutationsOf(dependency).consumingTasks.add(taskNode);
taskMutationInfo.consumesOutputOf.add(dependency);
}
// Add any finalizers to the queue
ArrayList<TaskInfo> finalizerTasks = new ArrayList<TaskInfo>();
addAllReversed(finalizerTasks, taskNode.getFinalizers());
for (TaskInfo finalizer : finalizerTasks) {
if (!visitingNodes.containsKey(finalizer)) {
nodeQueue.add(finalizerTaskPosition(finalizer, nodeQueue), new TaskInfoInVisitingSegment(finalizer, visitingSegmentCounter++));
}
}
}
}
executionQueue.clear();
executionQueue.addAll(executionPlan.values());
}
Aggregations