use of org.eclipse.ceylon.common.ModuleDescriptorReader in project ceylon by eclipse.
the class RepoUsingTool method collectModule.
private void collectModule(File sourceRoot, File sourceFile, Map<String, ModuleSpec> modules) {
File relativeFile = FileUtil.relativeFile(sourceRoot, sourceFile);
String name = relativeFile.getPath().replace(File.separatorChar, '.');
if (modules.containsKey(name))
return;
try {
ModuleDescriptorReader mdr = new ModuleDescriptorReader(name, sourceRoot);
String version = mdr.getModuleVersion();
if (version != null) {
modules.put(name, new ModuleSpec(null, name, version));
}
} catch (ModuleDescriptorReader.NoSuchModuleException x) {
// skip this source folder and look in the next one
x.printStackTrace();
}
}
use of org.eclipse.ceylon.common.ModuleDescriptorReader in project ceylon by eclipse.
the class RepoUsingTool method isSourceModule.
private boolean isSourceModule(File srcDir, String name, String version) {
try {
ModuleDescriptorReader mdr = new ModuleDescriptorReader(name, srcDir);
String declaredVersion = mdr.getModuleVersion();
return name.equals("default") || version.equals(declaredVersion);
} catch (ModuleDescriptorReader.NoSuchModuleException x) {
return false;
}
}
use of org.eclipse.ceylon.common.ModuleDescriptorReader in project ceylon by eclipse.
the class CeylonModuleDescriptorTask method execute.
/**
* Executes the task.
* @exception BuildException if an error occurs
*/
@Override
public void execute() throws BuildException {
Java7Checker.check();
ModuleDescriptorReader reader;
try {
CeylonClassLoader loader = Util.getCeylonClassLoaderCachedInProject(getProject());
try {
reader = new ModuleDescriptorReader(loader, module.getName(), getSrc());
} catch (NoSuchModuleException e) {
throw new BuildException("Failed to load module", e);
}
} catch (ClassLoaderSetupException x) {
throw new BuildException("Failed to set up Ceylon class loader", x);
}
if (versionProperty != null) {
setProjectProperty(versionProperty, reader.getModuleVersion());
}
if (nameProperty != null) {
setProjectProperty(nameProperty, reader.getModuleName());
}
if (licenseProperty != null) {
setProjectProperty(licenseProperty, reader.getModuleLicense());
}
}
Aggregations