use of org.gradle.api.Task in project hibernate-orm by hibernate.
the class HibernatePlugin method applyEnhancement.
private void applyEnhancement(final Project project, final HibernateExtension hibernateExtension) {
if (!hibernateExtension.enhance.shouldApply()) {
project.getLogger().warn("Skipping Hibernate bytecode enhancement since no feature is enabled");
return;
}
for (final SourceSet sourceSet : hibernateExtension.getSourceSets()) {
project.getLogger().debug("Applying Hibernate enhancement action to SourceSet.{}", sourceSet.getName());
final Task compileTask = project.getTasks().findByName(sourceSet.getCompileJavaTaskName());
compileTask.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
project.getLogger().debug("Starting Hibernate enhancement on SourceSet.{}", sourceSet.getName());
final ClassLoader classLoader = toClassLoader(sourceSet.getRuntimeClasspath());
EnhancementContext enhancementContext = new DefaultEnhancementContext() {
@Override
public ClassLoader getLoadingClassLoader() {
return classLoader;
}
@Override
public boolean doBiDirectionalAssociationManagement(UnloadedField field) {
return hibernateExtension.enhance.getEnableAssociationManagement();
}
@Override
public boolean doDirtyCheckingInline(UnloadedClass classDescriptor) {
return hibernateExtension.enhance.getEnableDirtyTracking();
}
@Override
public boolean hasLazyLoadableAttributes(UnloadedClass classDescriptor) {
return hibernateExtension.enhance.getEnableLazyInitialization();
}
@Override
public boolean isLazyLoadable(UnloadedField field) {
return hibernateExtension.enhance.getEnableLazyInitialization();
}
@Override
public boolean doExtendedEnhancement(UnloadedClass classDescriptor) {
return hibernateExtension.enhance.getEnableExtendedEnhancement();
}
};
if (hibernateExtension.enhance.getEnableExtendedEnhancement()) {
logger.warn("Extended enhancement is enabled. Classes other than entities may be modified. You should consider access the entities using getter/setter methods and disable this property. Use at your own risk.");
}
final Enhancer enhancer = Environment.getBytecodeProvider().getEnhancer(enhancementContext);
final FileTree fileTree = project.fileTree(sourceSet.getOutput().getClassesDir());
for (File file : fileTree) {
if (!file.getName().endsWith(".class")) {
continue;
}
final byte[] enhancedBytecode = doEnhancement(sourceSet.getOutput().getClassesDir(), file, enhancer);
if (enhancedBytecode != null) {
writeOutEnhancedClass(enhancedBytecode, file);
logger.info("Successfully enhanced class [" + file + "]");
} else {
logger.info("Skipping class [" + file.getAbsolutePath() + "], not an entity nor embeddable");
}
}
}
});
}
}
use of org.gradle.api.Task in project gradle by gradle.
the class BuildInvocationsBuilder method findTasks.
private void findTasks(Project project, Map<String, LaunchableGradleTaskSelector> taskSelectors, Collection<String> visibleTasks) {
for (Project child : project.getChildProjects().values()) {
findTasks(child, taskSelectors, visibleTasks);
}
for (Task task : taskLister.listProjectTasks(project)) {
// this way, for each task selector, its description will be the one from the selected task with the 'smallest' path
if (!taskSelectors.containsKey(task.getName())) {
LaunchableGradleTaskSelector taskSelector = new LaunchableGradleTaskSelector().setDescription(task.getDescription()).setPath(task.getPath());
taskSelectors.put(task.getName(), taskSelector);
} else {
LaunchableGradleTaskSelector taskSelector = taskSelectors.get(task.getName());
if (hasPathWithLowerOrdering(task, taskSelector)) {
taskSelector.setDescription(task.getDescription()).setPath(task.getPath());
}
}
// visible tasks are specified as those that have a non-empty group
if (PublicTaskSpecification.INSTANCE.isSatisfiedBy(task)) {
visibleTasks.add(task.getName());
}
}
}
use of org.gradle.api.Task in project gradle by gradle.
the class IdeaPlugin method createImlArtifact.
private static LocalComponentArtifactMetadata createImlArtifact(ProjectComponentIdentifier projectId, Project project) {
String moduleName = project.getExtensions().getByType(IdeaModel.class).getModule().getName();
File imlFile = new File(project.getProjectDir(), moduleName + ".iml");
Task byName = project.getTasks().getByName("ideaModule");
PublishArtifact publishArtifact = new DefaultPublishArtifact(moduleName, "iml", "iml", null, null, imlFile, byName);
return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
use of org.gradle.api.Task in project gradle by gradle.
the class IdeaScalaConfigurer method configure.
public void configure() {
rootProject.getGradle().addBuildListener(new BuildAdapter() {
public void projectsEvaluated(Gradle gradle) {
VersionNumber ideaTargetVersion = findIdeaTargetVersion();
final boolean useScalaSdk = ideaTargetVersion == null || IDEA_VERSION_WHEN_SCALA_SDK_WAS_INTRODUCED.compareTo(ideaTargetVersion) <= 0;
final Collection<Project> scalaProjects = findProjectsApplyingIdeaAndScalaPlugins();
final Map<String, ProjectLibrary> scalaCompilerLibraries = Maps.newHashMap();
rootProject.getTasks().getByName("ideaProject").doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
if (scalaProjects.size() > 0) {
scalaCompilerLibraries.clear();
scalaCompilerLibraries.putAll(resolveScalaCompilerLibraries(scalaProjects, useScalaSdk));
declareUniqueProjectLibraries(Sets.newLinkedHashSet(scalaCompilerLibraries.values()));
}
}
});
rootProject.configure(scalaProjects, new Action<Project>() {
@Override
public void execute(final Project project) {
project.getExtensions().getByType(IdeaModel.class).getModule().getIml().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
if (useScalaSdk) {
declareScalaSdk(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
} else {
declareScalaFacet(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
}
}
});
}
});
}
});
}
use of org.gradle.api.Task in project gradle by gradle.
the class ProjectConverter method addTasks.
/**
* Adds the tasks from the project to the GradleProject.
*
* @param project the source parent project. Where we get the sub projects from.
* @param projectView the destination of the tasks from project.
*/
private void addTasks(Project project, ProjectView projectView) {
List<String> defaultTasks = project.getDefaultTasks();
for (Task task : taskLister.listProjectTasks(project)) {
String taskName = task.getName();
boolean isDefault = defaultTasks.contains(taskName);
projectView.createTask(taskName, task.getDescription(), isDefault);
}
}
Aggregations