本文整理匯總了Java中org.gradle.api.Project.getProjectDir方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.getProjectDir方法的具體用法?Java Project.getProjectDir怎麽用?Java Project.getProjectDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.gradle.api.Project
的用法示例。
在下文中一共展示了Project.getProjectDir方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addPropertiesToProject
import org.gradle.api.Project; //導入方法依賴的package包/類
private void addPropertiesToProject(Project project, CachingPropertyApplicator applicator) {
Properties projectProperties = new Properties();
File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
if (projectPropertiesFile.isFile()) {
projectProperties = GUtil.loadProperties(projectPropertiesFile);
LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
projectProperties.keySet());
} else {
LOGGER.debug("project property file does not exists. We continue!");
}
// this should really be <String, Object>, however properties loader signature expects a <String, String>
// even if in practice it was never enforced (one can pass other property types, such as boolean) an
// fixing the method signature would be a binary breaking change in a public API.
Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
for (Map.Entry<String, String> entry : mergedProperties.entrySet()) {
applicator.configureProperty(project, entry.getKey(), entry.getValue());
}
}
示例2: setupSession
import org.gradle.api.Project; //導入方法依賴的package包/類
public RepositorySystemSession setupSession(Project project, RepositorySystem system) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
File dir = new File(project.getProjectDir(), "aether/repository");
LocalRepository localRepo = new LocalRepository(dir);
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
return session;
}
示例3: buildProjectOutput
import org.gradle.api.Project; //導入方法依賴的package包/類
private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) {
DefaultProjectOutcomes projectOutput = new DefaultProjectOutcomes(project.getName(), project.getPath(),
project.getDescription(), project.getProjectDir(), getFileOutcomes(project), parent);
for (Project child : project.getChildProjects().values()) {
projectOutput.addChild(buildProjectOutput(child, projectOutput));
}
return projectOutput;
}
示例4: createArtifact
import org.gradle.api.Project; //導入方法依賴的package包/類
private static LocalComponentArtifactMetadata createArtifact(String extension, ProjectComponentIdentifier projectId, String projectName, Project project) {
File projectFile = new File(project.getProjectDir(), "." + extension);
Task byName = project.getTasks().getByName("eclipseProject");
String type = "eclipse." + extension;
PublishArtifact publishArtifact = new DefaultPublishArtifact(projectName, extension, type, null, null, projectFile, byName);
return new PublishArtifactLocalArtifactMetadata(projectId, publishArtifact);
}
示例5: createImlArtifact
import org.gradle.api.Project; //導入方法依賴的package包/類
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);
}
示例6: configureIdeaModule
import org.gradle.api.Project; //導入方法依賴的package包/類
private void configureIdeaModule(final Project project) {
final GenerateIdeaModule task = project.getTasks().create("ideaModule", GenerateIdeaModule.class);
task.setDescription("Generates IDEA module files (IML)");
IdeaModuleIml iml = new IdeaModuleIml(task.getXmlTransformer(), project.getProjectDir());
final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
task.setModule(module);
ideaModel.setModule(module);
ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("name", new Callable<String>() {
@Override
public String call() throws Exception {
return project.getName();
}
});
conventionMapping.map("contentRoot", new Callable<File>() {
@Override
public File call() throws Exception {
return project.getProjectDir();
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet(project.getBuildDir(), project.file(".gradle"));
}
});
conventionMapping.map("pathFactory", new Callable<PathFactory>() {
@Override
public PathFactory call() throws Exception {
final PathFactory factory = new PathFactory();
factory.addPathVariable("MODULE_DIR", task.getOutputFile().getParentFile());
for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
factory.addPathVariable(entry.getKey(), entry.getValue());
}
return factory;
}
});
addWorker(task);
}
示例7: getBuildCacheDir
import org.gradle.api.Project; //導入方法依賴的package包/類
private File getBuildCacheDir(Project rootProject) {
if (buildCacheDir != null) {
return buildCacheDir;
}
return new File(rootProject.getProjectDir(), ".gradle");
}
示例8: setupPackageTasks
import org.gradle.api.Project; //導入方法依賴的package包/類
void setupPackageTasks(Project project, Task generateTask) {
final File buildDir = new File(project.getBuildDir(), "npm_compile");
final File distDir = getNpmOutputDir(project);
project.getTasks().create(PublishTypescriptStubsTask.NAME, PublishTypescriptStubsTask.class);
TSGeneratorConfig config = project.getExtensions().getByType(TSGeneratorConfig.class);
Copy copySources = project.getTasks().create("processTypescript", Copy.class);
copySources.from(config.getGenDir());
copySources.into(buildDir);
copySources.dependsOn(generateTask);
// copy .npmrc file from root to working directory if available
final File npmrcFile = new File(project.getProjectDir(), ".npmrc");
if (npmrcFile.exists()) {
copySources.getInputs().file(npmrcFile);
copySources.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
File targetFile = new File(buildDir, ".npmrc");
buildDir.mkdirs();
TypescriptUtils.copyFile(npmrcFile, targetFile);
}
});
}
CompileTypescriptStubsTask compileTypescriptTask = project.getTasks().create(CompileTypescriptStubsTask.NAME,
CompileTypescriptStubsTask.class);
try {
NpmInstallTask npmInstall = (NpmInstallTask) project.getTasks().getByName("npmInstall");
npmInstall.setWorkingDir(buildDir);
npmInstall.dependsOn(copySources);
npmInstall.getInputs().file(new File(buildDir, "package.json"));
npmInstall.getOutputs().dir(new File(buildDir, "node_modules"));
compileTypescriptTask.dependsOn(npmInstall);
}
catch (UnknownTaskException e) {
LOGGER.warn("task not found, ok in testing", e);
}
ConfigurableFileTree fileTree = project.fileTree(buildDir);
fileTree.include("package.json");
fileTree.include(".npmrc");
fileTree.include("**/*.ts");
fileTree.exclude("**/*.d.ts");
compileTypescriptTask.getInputs().files(fileTree);
compileTypescriptTask.setWorkingDir(buildDir);
compileTypescriptTask.getOutputs().dir(buildDir);
ConfigurableFileTree assembleFileTree = project.fileTree(new File(buildDir, "src"));
assembleFileTree.include("**/*.ts");
assembleFileTree.include("**/*.js");
assembleFileTree.include("**/*.js.map");
Copy assembleSources = project.getTasks().create("assembleTypescript", Copy.class);
assembleSources.from(assembleFileTree);
assembleSources.from(new File(buildDir, "package.json"));
assembleSources.into(distDir);
assembleSources.dependsOn(compileTypescriptTask);
}