use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class TalendProcessJavaProject method createFolder.
private IFolder createFolder(String path) {
IProject p = getProject();
if (p != null) {
try {
IFolder folder = p.getFolder(path);
createSubFolder(null, folder);
return folder;
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
return null;
}
use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class JavaProcessor method initCodePath.
public void initCodePath(IContext c) throws ProcessorException {
if (buildChildrenJobs != null) {
buildChildrenJobs.clear();
}
ITalendProcessJavaProject tProcessJavaProject = getTalendJavaProject();
IProgressMonitor monitor = new NullProgressMonitor();
IFolder srcFolder = null;
IFolder resourcesFolder = null;
IFolder outputFolder = null;
if (isTestJob) {
srcFolder = tProcessJavaProject.getTestSrcFolder();
resourcesFolder = tProcessJavaProject.getTestResourcesFolder();
outputFolder = tProcessJavaProject.getTestOutputFolder();
} else {
srcFolder = tProcessJavaProject.getSrcFolder();
resourcesFolder = tProcessJavaProject.getResourcesFolder();
outputFolder = tProcessJavaProject.getOutputFolder();
}
/*
* assume the job is "TestJob 0.1", project is "Test" .
*/
String jobClassPackageFolder = null;
String jobClassFilePath = null;
// only for "standard" job
if (isStandardJob()) {
Item item = property.getItem();
// test/testjob_0_1
jobClassPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(item, isTestJob);
// test/testjob_0_1/TestJob.java
jobClassFilePath = JavaResourcesHelper.getJobClassFilePath(item, filenameFromLabel, isTestJob);
// test.testjob_0_1.TestJob
this.mainClass = JavaResourcesHelper.getJobPackagedClass(item, filenameFromLabel, isTestJob);
} else {
// for shadow process, or preview process
// test/shadowfileinputtodelimitedoutput_0_1, test/preview_data
jobClassPackageFolder = JavaResourcesHelper.getProjectFolderName(property) + JavaUtils.PATH_SEPARATOR + JavaResourcesHelper.getJobFolderName(process.getName(), process.getVersion());
// test/shadowfileinputtodelimitedoutput_0_1/ShadowFileInputToDelimitedOutput.java,
// test/preview_data/Preview_Data.java
jobClassFilePath = jobClassPackageFolder + JavaUtils.PATH_SEPARATOR + (filenameFromLabel ? JavaResourcesHelper.escapeFileName(process.getName()) : process.getId()) + JavaUtils.JAVA_EXTENSION;
// test.shadowfileinputtodelimitedoutput_0_1.ShadowFileInputToDelimitedOutput,
// test.preview_data.Preview_Data
this.mainClass = new Path(jobClassFilePath).removeFileExtension().toString().replace('/', '.');
}
// create job packages, src/main/java/test/testjob_0_1
// or test job packages, src/main/java/test/testjob_0_1/testjunitjob_0_1
tProcessJavaProject.createSubFolder(monitor, srcFolder, jobClassPackageFolder);
// src/main/java/test/testjob_0_1/TestJob.java
// or src/main/java/test/testjob_0_1/testjunitjob_0_1/TestjunitJob.java
this.codePath = srcFolder.getProjectRelativePath().append(jobClassFilePath);
// target/classes/test/testjob_0_1
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1
IFolder jobClassFolder = outputFolder.getFolder(jobClassPackageFolder);
// TestJob
String jobName = new Path(jobClassFilePath).removeFileExtension().lastSegment();
// target/classes/test/testjob_0_1/TestJob
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1/TestjunitJob
this.compiledCodePath = jobClassFolder.getProjectRelativePath().append(jobName);
if (isTestJob) {
// test/testjob_0_1/datas
IPath dataPath = new Path(jobClassPackageFolder).append(JavaUtils.JAVA_DATAS_DIRECTORY);
this.dataFilePath = resourcesFolder.getFolder(dataPath).getProjectRelativePath();
}
/*
* for context.
*/
// test/testjob_0_1/contexts
// or test/testjob_0_1/testjunitjob_0_1/contexts
IPath jobContextFolderPath = new Path(jobClassPackageFolder).append(JavaUtils.JAVA_CONTEXTS_DIRECTORY);
// src/main/resources/test/testjob_0_1/contexts
// or src/test/resources/test/testjob_0_1/testjunitjob_0_1/contexts
tProcessJavaProject.createSubFolder(monitor, resourcesFolder, jobContextFolderPath.toString());
// for example, Default
String contextFileName = JavaResourcesHelper.getJobContextFileName(c);
// test/testjob_0_1/contexts/Default.properties
// or test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
IPath jobContextPath = jobContextFolderPath.append(contextFileName);
// src/main/resources/test/testjob_0_1/contexts/Default.properties
// or src/test/resources/test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
this.contextPath = resourcesFolder.getFile(jobContextPath).getProjectRelativePath();
// target/classes/test/testjob_0_1/contexts/Default.properties
// or target/test-classes/test/testjob_0_1/testjunitjob_0_1/contexts/Default.properties
this.compiledContextPath = outputFolder.getFile(jobContextPath).getProjectRelativePath();
}
use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class TalendProcessJavaProject method createSubFolder.
/**
*
* will try to create the sub folders which under the base folder.
*/
@Override
public IFolder createSubFolder(IProgressMonitor monitor, IFolder baseFolder, String path) {
if (baseFolder != null && path != null && path.length() > 0) {
try {
IFolder subFolder = baseFolder.getFolder(path);
createSubFolder(monitor, subFolder);
return subFolder;
} catch (CoreException e) {
ExceptionHandler.process(e);
return null;
}
}
return null;
}
use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class JavaProcessor method writeCodesToFile.
/**
*
* Test the formating source codes,only when talend debug mode
*/
private void writeCodesToFile(String contents, String fileBaseName) {
if (!CommonsPlugin.isDebugMode()) {
return;
}
//$NON-NLS-1$
IFolder folder = this.getTalendJavaProject().getTempFolder().getFolder("--CodesFormat");
File codesDir = folder.getLocation().toFile();
codesDir.mkdirs();
FileWriter fw = null;
try {
fw = new FileWriter(new File(codesDir, this.getProcess().getName() + '_' + fileBaseName));
fw.write(contents);
fw.flush();
} catch (IOException e) {
ExceptionHandler.process(e);
} finally {
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
//
}
}
}
}
use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class MavenJavaProcessor method getBasePathClasspath.
@Override
protected String getBasePathClasspath() throws ProcessorException {
final boolean exportingJob = ProcessorUtilities.isExportConfig();
String basePathClasspath = super.getBasePathClasspath();
if (!exportingJob && isTestJob) {
// for test job, need add the test-classes in classpath.
final String classPathSeparator = extractClassPathSeparator();
ITalendProcessJavaProject tProcessJvaProject = this.getTalendJavaProject();
IFolder testClassesFolder = tProcessJvaProject.getTestOutputFolder();
String testOutputPath = testClassesFolder.getLocation().toPortableString();
basePathClasspath = testOutputPath + classPathSeparator + basePathClasspath;
}
return basePathClasspath;
}
Aggregations