Examples of BundleResolver


Examples of org.apache.geronimo.mavenplugins.osgi.utils.BundleResolver

       
        if (!target.exists()) {
            return;
        }
               
        BundleResolver stateController = new BundleResolver(getLogger());
               
        try {
            stateController.addBundle(target);
        } catch (BundleException e) {
            log.error(e.getMessage(), e);
        }       
        stateController.resolveState();
        BundleDescription b = stateController.getBundleDescription(target);               
        if (b != null) {
            displayManifest(b);
        }   
    }
View Full Code Here

Examples of org.apache.geronimo.mavenplugins.osgi.utils.BundleResolver

       
        if (profileName != null) {
            System.setProperty("osgi.java.profile", profileName);
        }
       
        BundleResolver stateController = new BundleResolver(getLogger());
       
        List<String> classpath;
        try {
            classpath = (List<String>)project.getCompileClasspathElements();
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
       
        for (String path : classpath) {
            try {
                File cp = new File(path);
                if (log.isDebugEnabled()) {
                    log.debug("Adding bundle: " + cp);
                }
                if (cp.exists()) {
                    stateController.addBundle(cp);
                }
            } catch (BundleException e) {
                log.error(e.getMessage(), e);
            }
        }
       
        stateController.resolveState();
        BundleDescription b = stateController.getBundleDescription(targetDir);               
        if (b != null) {
            log.info("Resolving OSGi bundle: " + b.getSymbolicName());
            try {
                stateController.assertResolved(b);
                log.info("OSGi bundle is resolved: " + b.getSymbolicName());
            } catch (BundleException e) {
                stateController.analyzeErrors(b);
                if (failOnError) {
                    throw new MojoExecutionException("OSGi bundle resolution failed");
                }
            }
        }   
View Full Code Here

Examples of org.apache.geronimo.mavenplugins.osgi.utils.BundleResolver

       
        if (!target.exists()) {
            return;
        }
               
        BundleResolver stateController = new BundleResolver(getLogger());
               
        try {
            stateController.addBundle(target);
        } catch (BundleException e) {
            log.error(e.getMessage(), e);
        }       
        stateController.resolveState();
        BundleDescription b = stateController.getBundleDescription(target);               
        if (b != null) {
            displayManifest(b);
        }   
    }
View Full Code Here

Examples of org.apache.tuscany.sca.tools.maven.compiler.osgi.BundleResolver

    public JavaCompiler() {
        super(ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null);
    }

    public List<CompilerError> compile(CompilerConfiguration configuration) throws CompilerException {
        BundleResolver stateController = new BundleResolver(getLogger());

        getLogger().info("Invoking Tuscany Eclipse JDT compiler");

        List<URL> urls = new ArrayList<URL>();
        try {
            for (String entry : (List<String>)configuration.getClasspathEntries()) {
                urls.add(new File(entry).toURI().toURL());
            }
        } catch (MalformedURLException e) {
            throw new CompilerException(e.getMessage(), e);
        }

        ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]));

        // Determine compiler configuration
        Map<String, String> settings = new HashMap<String, String>();
        String sourceVersion = configuration.getSourceVersion();
        if (sourceVersion != null && sourceVersion.length() != 0) {
            settings.put(OPTION_Source, sourceVersion);
        }
        String targetVersion = configuration.getTargetVersion();
        if (targetVersion != null && targetVersion.length() != 0) {
            settings.put(OPTION_TargetPlatform, targetVersion);
        }
        settings.put(OPTION_LineNumberAttribute, GENERATE);
        settings.put(OPTION_SourceFileAttribute, GENERATE);
        if (configuration.isDebug()) {
            settings.put(OPTION_LocalVariableAttribute, GENERATE);
        }
        if (configuration.getSourceEncoding() != null && !(configuration.getSourceEncoding().length() == 0)) {
            settings.put(OPTION_Encoding, configuration.getSourceEncoding());
        }
        if (configuration.isShowDeprecation()) {
            settings.put(OPTION_ReportDeprecation, WARNING);
        } else {
            settings.put(OPTION_ReportDeprecation, IGNORE);
        }

        // Create a compiler
        List<CompilerError> compilerErrors = new ArrayList<CompilerError>();
        INameEnvironment nameEnvironment =
            new ClassLoaderNameEnvironment(classLoader, configuration.getSourceLocations());
        ICompilerRequestor requestor =
            new CompilerRequestor(configuration.getOutputLocation(), configuration.isShowWarnings(), compilerErrors);
        Compiler compiler =
            new Compiler(nameEnvironment, proceedWithAllProblems(), new CompilerOptions(settings), requestor,
                         new DefaultProblemFactory(Locale.getDefault()));

        // Create compilation units for the source files
        List<FileCompilationUnit> compilationUnits = new ArrayList<FileCompilationUnit>();

        // Go over the input source locations
        List<String> sourceLocations = (List<String>)configuration.getSourceLocations();
        for (String sourceLocation : sourceLocations) {

            // Exclude nested source locations
            List<String> excludeLocations = new ArrayList<String>();
            for (String nestedLocation : sourceLocations) {
                if (nestedLocation != sourceLocation && nestedLocation.startsWith(sourceLocation)) {
                    excludeLocations.add(nestedLocation);
                }
            }

            // List source files in each source location
            for (String sourceFile : (Set<String>)getSourceFilesForSourceRoot(configuration, sourceLocation)) {

                // Exclude files from excluded nested locations
                boolean excluded = false;
                for (String excludeLocation : excludeLocations) {
                    if (sourceFile.startsWith(excludeLocation)) {
                        excluded = true;
                    }
                }
                if (!excluded) {

                    // Create a compilation unit for the source file
                    FileCompilationUnit compilationUnit =
                        new FileCompilationUnit(sourceFile, makeClassName(sourceFile, sourceLocation));
                    compilationUnits.add(compilationUnit);
                }
            }
        }

        // Compile all the compilation units
        getLogger().info("Compiling " + compilationUnits.size() + " to " + configuration.getOutputLocation());
        compiler.compile((ICompilationUnit[])compilationUnits.toArray(new ICompilationUnit[compilationUnits.size()]));

        // getLogger().info(configuration.getCustomCompilerArguments().toString());
        boolean osgi = "true".equals(configuration.getCustomCompilerArguments().get("-osgi"));
        File proj = new File(configuration.getOutputLocation());

        String symbol = null;
        try {
            // Don't trigger the resolution for test-compile
            if (!"test-classes".equals(proj.getName())) {
                symbol = BundleUtil.getBundleSymbolicName(proj);
            }
        } catch (IOException e1) {
            symbol = null;
        }

        if (osgi && symbol != null) {
            getLogger().info("Resolving OSGi bundle: "+symbol);
            for (String entry : (List<String>)configuration.getClasspathEntries()) {
                try {
                    File cp = new File(entry);
                    if (cp.exists()) {
                        stateController.addBundle(cp);
                    }
                } catch (BundleException e) {
                    getLogger().error(e.getMessage(), e);
                }
            }

            stateController.resolveState();
            BundleDescription b = stateController.getBundleDescription(proj);
            if (b != null) {
                try {
                    stateController.assertResolved(b);
                    getLogger().info("OSGi bundle is resolved: " + b.getSymbolicName());
                } catch (BundleException e) {
                    stateController.analyzeErrors(b);
                    if(getLogger().isDebugEnabled()) {
                        getLogger().debug(stateController.reportErrors(b));
                    }
                    // FIXME: For now, only a warning is reported
                    // throw new CompilerException(e.getMessage(), e);
                }
            }
View Full Code Here

Examples of org.sonatype.sisu.bl.support.resolver.BundleResolver

            return testIndex().getDirectory();
          }

        });
    binder.bind(BundleResolver.class).annotatedWith(NexusSpecific.class).toInstance(
        new BundleResolver()
        {
          @Override
          public File resolve() {
            final BundleResolver resolver;
            if (filteredNexusBundleCoordinates == null) {
              resolver = nexusBundleResolver;
            }
            else {
              resolver = new MavenBridgedBundleResolver(filteredNexusBundleCoordinates, artifactResolver);
            }
            return resolver.resolve();
          }
        }
    );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.