Search in sources :

Example 6 with ModuleDescriptorReader

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();
    }
}
Also used : ModuleDescriptorReader(org.eclipse.ceylon.common.ModuleDescriptorReader) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) File(java.io.File)

Example 7 with ModuleDescriptorReader

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;
    }
}
Also used : ModuleDescriptorReader(org.eclipse.ceylon.common.ModuleDescriptorReader)

Example 8 with ModuleDescriptorReader

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());
    }
}
Also used : ModuleDescriptorReader(org.eclipse.ceylon.common.ModuleDescriptorReader) CeylonClassLoader(org.eclipse.ceylon.launcher.CeylonClassLoader) NoSuchModuleException(org.eclipse.ceylon.common.ModuleDescriptorReader.NoSuchModuleException) BuildException(org.apache.tools.ant.BuildException) ClassLoaderSetupException(org.eclipse.ceylon.launcher.ClassLoaderSetupException)

Aggregations

ModuleDescriptorReader (org.eclipse.ceylon.common.ModuleDescriptorReader)8 File (java.io.File)4 NoSuchModuleException (org.eclipse.ceylon.common.ModuleDescriptorReader.NoSuchModuleException)3 ClassLoaderSetupException (org.eclipse.ceylon.launcher.ClassLoaderSetupException)3 CeylonClassLoader (org.eclipse.ceylon.launcher.CeylonClassLoader)2 URI (java.net.URI)1 LinkedHashSet (java.util.LinkedHashSet)1 TreeSet (java.util.TreeSet)1 BuildException (org.apache.tools.ant.BuildException)1 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)1 FileSet (org.apache.tools.ant.types.FileSet)1 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)1 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)1 Backends (org.eclipse.ceylon.common.Backends)1 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)1 Test (org.junit.Test)1