Package org.apache.maven.shared.osgi

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


     * @param newBnd
     */
    private void add(StartLevel mergeStartLevel, Bundle newBnd) {
        Bundle current = get(newBnd, false);
        if (current != null) {
            final Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();

            // compare versions, the highest will be used
            final Version newVersion = new Version(converter.getVersion(newBnd.getVersion()));
            final Version oldVersion = new Version(converter.getVersion(current.getVersion()));
            if ( newVersion.compareTo(oldVersion) > 0 ) {
                current.setVersion(newBnd.getVersion());
            }
        } else {
            StartLevel startLevel = null;
View Full Code Here


        File baseDirectory = new File( getBasedir() );
        File buildDirectory = new File( baseDirectory, "target" );
        plugin.setBuildDirectory( buildDirectory.getPath() );
        File outputDirectory = new File( buildDirectory, "test-classes" );
        plugin.setOutputDirectory( outputDirectory );
        plugin.setMaven2OsgiConverter( new DefaultMaven2OsgiConverter() );
    }
View Full Code Here

    protected void setUp() throws Exception
    {
        super.setUp();
        plugin = new BundlePlugin();
        plugin.setMaven2OsgiConverter( new DefaultMaven2OsgiConverter() );
        plugin.setBuildDirectory( "." );
        plugin.setOutputDirectory( new File( getBasedir(), "target" + File.separatorChar + "scratch" ) );
    }
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(
                    '/' ).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

     * @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(
                    '/' ).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

    }


    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

    }


    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 );

        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

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.