Package org.apache.maven.shared.osgi

Examples of org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter


    }


    public void execute() throws MojoExecutionException
    {
        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
        completeArtifactItems( artifactItems );
        for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext(); )
        {
            ArtifactItem item = artifactItem.next();
            try
            {
                final File tmpDir = new File( outputDirectory.getAbsoluteFile() + File.separator
                    + maven2OsgiConverter.getBundleSymbolicName( item.getArtifact() ) + "_"
                    + maven2OsgiConverter.getVersion( item.getArtifact() ) );
                unpackToLocation( tmpDir, item.getArtifact().getFile() );
            }
            catch ( Exception e )
            {
                throw new MojoExecutionException( "", e );
View Full Code Here


                                    projectBuilder, archiverManager, inputHandler, log );
        try
        {
            Field field = InstallPluginsMojo.class.getDeclaredField( "maven2OsgiConverter" );
            field.setAccessible( true );
            field.set( mojo, new DefaultMaven2OsgiConverter() );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Unable to configure maven2OsgiConverter", e );
        }
View Full Code Here

    }


    public void execute() throws MojoExecutionException
    {
        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
        completeArtifactItems( artifactItems );
        for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext(); )
        {
            ArtifactItem item = artifactItem.next();
            try
            {
                final File tmpDir = new File( outputDirectory.getAbsoluteFile() + File.separator
                    + maven2OsgiConverter.getBundleSymbolicName( item.getArtifact() ) + "_"
                    + maven2OsgiConverter.getVersion( item.getArtifact() ) );
                unpackToLocation( tmpDir, item.getArtifact().getFile() );
            }
            catch ( Exception e )
            {
                throw new MojoExecutionException( "", e );
View Full Code Here

    }


    public void execute() throws MojoExecutionException
    {
        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
        completeArtifactItems( artifactItems );

        if ( !destinationDirectory.exists() && !destinationDirectory.mkdirs() )
        {
            throw new MojoExecutionException( "Can't create directory " + destinationDirectory );
        }

        for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext(); )
        {
            ArtifactItem item = artifactItem.next();
            final File destFile = new File( destinationDirectory.getAbsoluteFile() + File.separator
                + maven2OsgiConverter.getBundleFileName( item.getArtifact() ) );
            getLog().info(
                "Copying artifact " + item.getArtifactId() + " to\n               " + destFile.getAbsolutePath() );
            try
            {
                FileUtils.copyFile( item.getArtifact().getFile(), destFile );
View Full Code Here

    }


    public void execute() throws MojoExecutionException
    {
        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();

        completeArtifactItems( artifactItems );

        // Add file to packed file
        for ( Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext(); )
        {
            ArtifactItem item = artifactItem.next();
            try
            {
                final File zipFile = new File( destinationDirectory.getAbsoluteFile() + File.separator
                    + maven2OsgiConverter.getBundleFileName( item.getArtifact() ) );
                final File tmpDir = new File( pluginWorkDir + item.getArtifact().getArtifactId() );
                unpackToLocation( tmpDir, zipFile );
                getLog().info( "Adding " + inputFile + " to\n              " + zipFile );
                FileUtils.copyFileToDirectory( inputFile, tmpDir );
                packFromLocation( tmpDir, zipFile );
View Full Code Here

     * @throws FileNotFoundException
     * @throws IOException
     */
    private void updateManifest( final List<Artifact> list ) throws FileNotFoundException, IOException
    {
        final Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter();
        final File manifestFile = new File( project.getBasedir(), "META-INF/MANIFEST.MF" );
        getLog().info( "Update Bundle-Classpath in " + manifestFile );

        // Build Bundle-ClassPath entry
        final StringBuilder bundleClasspath = new StringBuilder( " ." );
        for ( Artifact artifact : list )
        {
            if ( !artifact.getScope().equalsIgnoreCase( "test" ) )
            {
                bundleClasspath.append( "," ).append( NEWLINE ).append( " " ).append( libraryPath ).append(
                    File.separator ).append( artifact.getFile().getName() );
            }
        }

        boolean inBundleClasspathEntry = false;

        // Read existing MANIFEST.MF and add existing entries
        // to StringBuilder exept Bundle-ClassPath entry
        StringBuilder manifestSb = new StringBuilder();
        BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( manifestFile ), "UTF-8" ) );
        String line;
        while ( ( line = in.readLine() ) != null )
        {
            if ( inBundleClasspathEntry && line.indexOf( ":" ) > -1 )
            {
                inBundleClasspathEntry = false;
            }
            else if ( inBundleClasspathEntry )
            {
                continue;
            }

            String name = line.substring( 0, line.indexOf( ":" ) + 1 );

            if ( !name.equalsIgnoreCase( ENTRY_BUNDLE_CLASSPATH ) )
            {
                if ( name.equalsIgnoreCase( ENTRY_BUNDLE_SYMBOLICNAME ) )
                {
                    // get OSGI Bundle Name
                    manifestSb.append( ENTRY_BUNDLE_SYMBOLICNAME );
                    manifestSb.append( " " );
                    manifestSb.append( maven2OsgiConverter.getBundleSymbolicName( project.getArtifact() ) );
                    manifestSb.append( ";singleton:=true" );
                    manifestSb.append( NEWLINE );
                }
                else
                {
View Full Code Here

                                    projectBuilder, archiverManager, inputHandler, log );
        try
        {
            Field field = InstallPluginsMojo.class.getDeclaredField( "maven2OsgiConverter" );
            field.setAccessible( true );
            field.set( mojo, new DefaultMaven2OsgiConverter() );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Unable to configure maven2OsgiConverter", e );
        }
View Full Code Here

    private static String formatString4Osgi(String s){
        return s.replaceAll("-", "_").replaceAll("\\.", "_");
    }
   
    public String convertToOsgi(COMPONENT comToDrop) {
        Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();

        if (comToDrop != null) {
            switch (comToDrop) {
                case major: {
                    return converter.getVersion("0.0.0");
                }
                case minor: {
                    return converter.getVersion(String.valueOf(getMajorVersion()));
                }
                case micro: {
                    return converter.getVersion(String.format("%s.%s",
                            getMajorVersion(),
                            getMinorVersion()));
                }
                case qualifier: {
                    return converter.getVersion(String.format("%s.%s.%s",
                            getMajorVersion(),
                            getMinorVersion(),
                            getIncrementalVersion()));
                }
            }
        }
       
        // init version major.minor.micro
        String version = String.format("%s.%s.%s",
                getMajorVersion(),
                getMinorVersion(),
                getIncrementalVersion());
       
        // if there is a qualifier, add it
        if(!getQualifier().isEmpty()){
            version = String.format("%s.%s",
                    version,
                    formatString4Osgi(getQualifier()));
        }
        return converter.getVersion(version);
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter

Copyright © 2018 www.massapicom. 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.