本文整理匯總了Java中org.gradle.api.Project類的典型用法代碼示例。如果您正苦於以下問題:Java Project類的具體用法?Java Project怎麽用?Java Project使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Project類屬於org.gradle.api包,在下文中一共展示了Project類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import org.gradle.api.Project; //導入依賴的package包/類
@Before
public void setup() {
Project project = Mockito.mock(Project.class);
TSGeneratorExtension config = new TSGeneratorExtension(project, null);
File outputDir = testProjectDir.getRoot();
MetaModuleConfig metaConfig = new MetaModuleConfig();
metaConfig.addMetaProvider(new ResourceMetaProvider());
MetaModule metaModule = MetaModule.createServerModule(metaConfig);
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(new EmptyServiceDiscovery());
boot.addModule(metaModule);
boot.boot();
generator = new TSGenerator(outputDir, metaModule.getLookup(), config);
}
示例2: getTasksByName
import org.gradle.api.Project; //導入依賴的package包/類
public Set<Task> getTasksByName(final String name, boolean recursive) {
if (!isTrue(name)) {
throw new InvalidUserDataException("Name is not specified!");
}
final Set<Task> foundTasks = new HashSet<Task>();
Action<Project> action = new Action<Project>() {
public void execute(Project project) {
// Don't force evaluation of rules here, let the task container do what it needs to
((ProjectInternal) project).evaluate();
Task task = project.getTasks().findByName(name);
if (task != null) {
foundTasks.add(task);
}
}
};
if (recursive) {
allprojects(action);
} else {
action.execute(this);
}
return foundTasks;
}
示例3: getBaseApFile
import org.gradle.api.Project; //導入依賴的package包/類
private File getBaseApFile(Project project, TBuildType tBuildType) {
File apBaseFile;
File buildTypeBaseApFile = tBuildType.getBaseApFile();
if (null != buildTypeBaseApFile && buildTypeBaseApFile.exists()) {
apBaseFile = buildTypeBaseApFile;
} else if (!isNullOrEmpty(tBuildType.getBaseApDependency())) {
String apDependency = tBuildType.getBaseApDependency();
// Preconditions.checkNotNull(apDependency,
// "You have to specify the baseApFile property or the baseApDependency
// dependency");
Dependency dependency = project.getDependencies().create(apDependency);
Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
configuration.setTransitive(false);
apBaseFile = Iterables.getOnlyElement(Collections2.filter(configuration.getFiles(), new Predicate<File>() {
@Override
public boolean apply(@Nullable File file) {
return file.getName().endsWith(".ap");
}
}));
} else {
throw new IllegalStateException("AP is missing");
}
return apBaseFile;
}
示例4: onApply
import org.gradle.api.Project; //導入依賴的package包/類
@Override
protected void onApply(Project project) {
getLifecycleTask().setDescription("Generates IDEA project files (IML, IPR, IWS)");
getCleanTask().setDescription("Cleans IDEA project files (IML, IPR)");
ideaModel = project.getExtensions().create("idea", IdeaModel.class);
configureIdeaWorkspace(project);
configureIdeaProject(project);
configureIdeaModule(project);
configureForJavaPlugin(project);
configureForScalaPlugin();
postProcess("idea", new Action<Gradle>() {
@Override
public void execute(Gradle gradle) {
performPostEvaluationActions();
}
});
}
示例5: resolvePath
import org.gradle.api.Project; //導入依賴的package包/類
/**
* @param path the task path, e.g. 'someTask', 'sT', ':sT', ':foo:bar:sT'
* @param startFrom the starting project the task should be found recursively
* @return resolved task path
*/
public ResolvedTaskPath resolvePath(String path, ProjectInternal startFrom) {
ProjectInternal project;
String taskName; //eg. 'someTask' or 'sT'
String prefix; //eg. '', ':' or ':foo:bar'
if (path.contains(Project.PATH_SEPARATOR)) {
int idx = path.lastIndexOf(Project.PATH_SEPARATOR);
taskName = path.substring(idx + 1);
prefix = path.substring(0, idx+1);
String projectPath = Project.PATH_SEPARATOR.equals(prefix) ? prefix : path.substring(0, idx);
project = projectFinder.findProject(projectPath, startFrom);
} else {
project = startFrom;
taskName = path;
prefix = "";
}
return new ResolvedTaskPath(prefix, taskName, project);
}
示例6: wireEarTaskConventions
import org.gradle.api.Project; //導入依賴的package包/類
private void wireEarTaskConventions(Project project, final EarPluginConvention earConvention) {
project.getTasks().withType(Ear.class, new Action<Ear>() {
public void execute(Ear task) {
task.getConventionMapping().map("libDirName", new Callable<String>() {
public String call() throws Exception {
return earConvention.getLibDirName();
}
});
task.getConventionMapping().map("deploymentDescriptor", new Callable<DeploymentDescriptor>() {
public DeploymentDescriptor call() throws Exception {
return earConvention.getDeploymentDescriptor();
}
});
}
});
}
示例7: getBaseDirectory
import org.gradle.api.Project; //導入依賴的package包/類
public File getBaseDirectory(Object scope, String key, VersionStrategy versionStrategy) {
if (key.equalsIgnoreCase("projects") || key.equalsIgnoreCase("tasks") || !key.matches("\\p{Alpha}+[-//.\\w]*")) {
throw new IllegalArgumentException(String.format("Unsupported cache key '%s'.", key));
}
File cacheRootDir = getRootDirectory(scope);
String subDir = key;
if (scope instanceof Project) {
Project project = (Project) scope;
subDir = "projects/" + project.getPath().replace(':', '_') + "/" + key;
}
if (scope instanceof Task) {
Task task = (Task) scope;
subDir = "tasks/" + task.getPath().replace(':', '_') + "/" + key;
}
return getCacheDir(cacheRootDir, versionStrategy, subDir);
}
示例8: generate
import org.gradle.api.Project; //導入依賴的package包/類
@TaskAction
public void generate() {
ProjectReportGenerator projectReportGenerator = new ProjectReportGenerator() {
@Override
public void generateReport(Project project) throws IOException {
Configuration configuration = getProject().getBuildscript().getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION);
renderer.startConfiguration(configuration);
renderer.render(configuration);
renderer.completeConfiguration(configuration);
}
};
ReportGenerator reportGenerator = new ReportGenerator(renderer, getClientMetaData(), null,
getTextOutputFactory(), projectReportGenerator);
reportGenerator.generateReport(Collections.singleton(getProject()));
}
示例9: apply
import org.gradle.api.Project; //導入依賴的package包/類
public void apply(Project project) {
Task hello = project.getTasks().create("hello");
hello.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
task.getLogger().lifecycle("Hello!");
}
});
}
示例10: configureTestDefaults
import org.gradle.api.Project; //導入依賴的package包/類
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
DslObject htmlReport = new DslObject(test.getReports().getHtml());
DslObject xmlReport = new DslObject(test.getReports().getJunitXml());
xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName());
}
});
htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestReportDir(), test.getName());
}
});
test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName() + "/binary");
}
});
test.workingDir(project.getProjectDir());
}
示例11: configureSourceSets
import org.gradle.api.Project; //導入依賴的package包/類
private void configureSourceSets(final JavaPluginConvention pluginConvention) {
final Project project = pluginConvention.getProject();
SourceSet main = pluginConvention.getSourceSets().create(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = pluginConvention.getSourceSets().create(SourceSet.TEST_SOURCE_SET_NAME);
test.setCompileClasspath(project.files(main.getOutput(), project.getConfigurations().getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
test.setRuntimeClasspath(project.files(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(TEST_RUNTIME_CONFIGURATION_NAME)));
}
示例12: doZipAlign
import org.gradle.api.Project; //導入依賴的package包/類
public static synchronized File doZipAlign(final AndroidBuilder androidBuilder, Project project, final File apkFile) {
final File zipalignedFile = new File(apkFile.getParent(), apkFile.getName().replace(".apk", "-zipaligned.apk"));
project.exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
String path = androidBuilder.getTargetInfo()
.getBuildTools().getPath(ZIP_ALIGN);
execSpec.executable(new File(path));
execSpec.args("-f", "4");
execSpec.args(apkFile);
execSpec.args(zipalignedFile);
}
});
return zipalignedFile;
}
示例13: apply
import org.gradle.api.Project; //導入依賴的package包/類
public void apply(Project project) {
project.getPluginManager().apply(ReportingBasePlugin.class);
final ReportingExtension reportingExtension = project.getExtensions().findByType(ReportingExtension.class);
project.getTasks().withType(CompareGradleBuilds.class, new Action<CompareGradleBuilds>() {
@Override
public void execute(final CompareGradleBuilds task) {
((IConventionAware) task).getConventionMapping().map("reportDir", new Callable<File>() {
@Override
public File call() throws Exception {
return reportingExtension.file(task.getName());
}
});
}
});
project.getTasks().create("compareGradleBuilds", CompareGradleBuilds.class);
}
示例14: onApply
import org.gradle.api.Project; //導入依賴的package包/類
@Override
protected void onApply(Project project) {
getLifecycleTask().setDescription("Generates all Eclipse files.");
getCleanTask().setDescription("Cleans all Eclipse files.");
EclipseModel model = project.getExtensions().create("eclipse", EclipseModel.class);
configureEclipseProject(project, model);
configureEclipseJdt(project, model);
configureEclipseClasspath(project, model);
postProcess("eclipse", new Action<Gradle>() {
@Override
public void execute(Gradle gradle) {
performPostEvaluationActions();
}
});
applyEclipseWtpPluginOnWebProjects(project);
}
示例15: report
import org.gradle.api.Project; //導入依賴的package包/類
@TaskAction
public void report() {
// Output reports per execution, not mixed.
// Cross-project ModelRegistry operations do not happen concurrently.
synchronized (DependentComponentsReport.class) {
Project project = getProject();
ModelRegistry modelRegistry = getModelRegistry();
DependentBinariesResolver dependentBinariesResolver = modelRegistry.find("dependentBinariesResolver", DependentBinariesResolver.class);
StyledTextOutput textOutput = getTextOutputFactory().create(DependentComponentsReport.class);
TextDependentComponentsReportRenderer reportRenderer = new TextDependentComponentsReportRenderer(dependentBinariesResolver, showNonBuildable, showTestSuites);
reportRenderer.setOutput(textOutput);
reportRenderer.startProject(project);
Set<ComponentSpec> allComponents = getAllComponents(modelRegistry);
if (showTestSuites) {
allComponents.addAll(getAllTestSuites(modelRegistry));
}
reportRenderer.renderComponents(getReportedComponents(allComponents));
reportRenderer.renderLegend();
reportRenderer.completeProject(project);
reportRenderer.complete();
}
}