Howto deploy plugins to 1.3.6

View: New views
9 Messages — Rating Filter:   Alert me  

Howto deploy plugins to 1.3.6

by Steffen Stundzig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've installed and package the sample kungfu repository customizer. Now
I need to deploy them to nexus. But how can I do that?

Blog and Wiki and Nabble say's

copy the bundle zip to <nexus>/plugin-repository, unzip it und restart nexus

So I've added a hosted repository named plugin-repository and unzipped
the bundle.zip into it and also restarted my nexus.

But the virusscanner isn't loaded. I added some System.err.println into
the virusscanner-classes to track it. ;)

What must I do?

And finally I've tried the same with nexus 1.4.0-SNAPSHOT, with same
results.

Next I analysed the generated META-INF/nexus/plugin.xml from the bundle.
It looks like:

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
  <modelVersion>1.0.0</modelVersion>
  <groupId>org.sonatype.nexus.plugins.samples</groupId>
  <artifactId>nexus-kungfu-virusscanner-plugin</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <name>Nexus Sample Plugins :: KungFu VirusScanner</name>

<pluginSite>http://www.sonatype.com/people/2009/06/writing-plugins-for-nexus-part-1/</pluginSite>
  <applicationId>nexus</applicationId>
  <applicationEdition>OSS</applicationEdition>
  <applicationMinVersion>1.4.0</applicationMinVersion>
</plugin>


but should them also contain some components like in
https://docs.sonatype.com/display/NX/Nexus+Plugin+Packaging

I've generated the plugin.xml with mvn package. Maven is version 2.2.1.

regards

---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: Howto deploy plugins to 1.3.6

by Brian Fox :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This will only work with 1.4+. The plugin repository is a folder in
sonatype-work/nexus/plugin-repository...so not a repo in nexus in the
traditional sense, although that raises some interesting
possibilities.

On Tue, Aug 18, 2009 at 10:21 AM, Steffen
Stundzig<steffen.stundzig@...> wrote:

> Hi,
>
> I've installed and package the sample kungfu repository customizer. Now
> I need to deploy them to nexus. But how can I do that?
>
> Blog and Wiki and Nabble say's
>
> copy the bundle zip to <nexus>/plugin-repository, unzip it und restart nexus
>
> So I've added a hosted repository named plugin-repository and unzipped
> the bundle.zip into it and also restarted my nexus.
>
> But the virusscanner isn't loaded. I added some System.err.println into
> the virusscanner-classes to track it. ;)
>
> What must I do?
>
> And finally I've tried the same with nexus 1.4.0-SNAPSHOT, with same
> results.
>
> Next I analysed the generated META-INF/nexus/plugin.xml from the bundle.
> It looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <plugin>
>  <modelVersion>1.0.0</modelVersion>
>  <groupId>org.sonatype.nexus.plugins.samples</groupId>
>  <artifactId>nexus-kungfu-virusscanner-plugin</artifactId>
>  <version>1.0.0-SNAPSHOT</version>
>  <name>Nexus Sample Plugins :: KungFu VirusScanner</name>
>
> <pluginSite>http://www.sonatype.com/people/2009/06/writing-plugins-for-nexus-part-1/</pluginSite>
>  <applicationId>nexus</applicationId>
>  <applicationEdition>OSS</applicationEdition>
>  <applicationMinVersion>1.4.0</applicationMinVersion>
> </plugin>
>
>
> but should them also contain some components like in
> https://docs.sonatype.com/display/NX/Nexus+Plugin+Packaging
>
> I've generated the plugin.xml with mvn package. Maven is version 2.2.1.
>
> regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
> For additional commands, e-mail: nexus-dev-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: Howto deploy plugins to 1.3.6

by Steffen Stundzig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thanks brian,

if it were a repo unzipping uploaded plugins with e repo customizer
plugin would be a simple installation mechanism?

And the missing components section in the generated plugin.xml? Is it a
problem or scans nexus the plugin.jar itself for the named annotation?

regards


Brian Fox schrieb:

> This will only work with 1.4+. The plugin repository is a folder in
> sonatype-work/nexus/plugin-repository...so not a repo in nexus in the
> traditional sense, although that raises some interesting
> possibilities.
>
> On Tue, Aug 18, 2009 at 10:21 AM, Steffen
> Stundzig<steffen.stundzig@...> wrote:
>> Hi,
>>
>> I've installed and package the sample kungfu repository customizer. Now
>> I need to deploy them to nexus. But how can I do that?
>>
>> Blog and Wiki and Nabble say's
>>
>> copy the bundle zip to <nexus>/plugin-repository, unzip it und restart nexus
>>
>> So I've added a hosted repository named plugin-repository and unzipped
>> the bundle.zip into it and also restarted my nexus.
>>
>> But the virusscanner isn't loaded. I added some System.err.println into
>> the virusscanner-classes to track it. ;)
>>
>> What must I do?
>>
>> And finally I've tried the same with nexus 1.4.0-SNAPSHOT, with same
>> results.
>>
>> Next I analysed the generated META-INF/nexus/plugin.xml from the bundle.
>> It looks like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <plugin>
>>  <modelVersion>1.0.0</modelVersion>
>>  <groupId>org.sonatype.nexus.plugins.samples</groupId>
>>  <artifactId>nexus-kungfu-virusscanner-plugin</artifactId>
>>  <version>1.0.0-SNAPSHOT</version>
>>  <name>Nexus Sample Plugins :: KungFu VirusScanner</name>
>>
>> <pluginSite>http://www.sonatype.com/people/2009/06/writing-plugins-for-nexus-part-1/</pluginSite>
>>  <applicationId>nexus</applicationId>
>>  <applicationEdition>OSS</applicationEdition>
>>  <applicationMinVersion>1.4.0</applicationMinVersion>
>> </plugin>
>>
>>
>> but should them also contain some components like in
>> https://docs.sonatype.com/display/NX/Nexus+Plugin+Packaging
>>
>> I've generated the plugin.xml with mvn package. Maven is version 2.2.1.
>>
>> regards
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
>> For additional commands, e-mail: nexus-dev-help@...
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
> For additional commands, e-mail: nexus-dev-help@...
>

--
Steffen Stundzig
Leiter Niederlassung Leipzig

Telefon: +49 (0) 341 / 231-0183-401
Telefax: +49 (0) 341 / 231-0183-411
Mobil:   +49 (0) 151 / 173-9673-1

http://itemis.de
http://twitter.com/itemis
steffen.stundzig@...
https://xing.com/profile/Steffen_Stundzig

itemis AG
Niederlassung Leipzig
Ludwig-Erhard-Straße 51
04103 Leipzig

Rechtlicher Hinweis:
Registergericht: Amtsgericht Dortmund HRB 20621
Sitz der Gesellschaft: 44536 Lünen, Am Brambusch 15-24
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vorsitzender), Stephan Grollmann,
Michael Neuhaus



---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: auto deploy plugins

by Steffen Stundzig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

attached you can find my first nexus plugin which installs on the fly
deployed nexus bundles. ;)

regards

Brian Fox schrieb:

> This will only work with 1.4+. The plugin repository is a folder in
> sonatype-work/nexus/plugin-repository...so not a repo in nexus in the
> traditional sense, although that raises some interesting
> possibilities.
>
> On Tue, Aug 18, 2009 at 10:21 AM, Steffen
> Stundzig<steffen.stundzig@...> wrote:
>> Hi,
>>
>> I've installed and package the sample kungfu repository customizer. Now
>> I need to deploy them to nexus. But how can I do that?
>>
>> Blog and Wiki and Nabble say's
>>
>> copy the bundle zip to <nexus>/plugin-repository, unzip it und restart nexus
>>
>> So I've added a hosted repository named plugin-repository and unzipped
>> the bundle.zip into it and also restarted my nexus.
>>
>> But the virusscanner isn't loaded. I added some System.err.println into
>> the virusscanner-classes to track it. ;)
>>
>> What must I do?
>>
>> And finally I've tried the same with nexus 1.4.0-SNAPSHOT, with same
>> results.
>>
>> Next I analysed the generated META-INF/nexus/plugin.xml from the bundle.
>> It looks like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <plugin>
>>  <modelVersion>1.0.0</modelVersion>
>>  <groupId>org.sonatype.nexus.plugins.samples</groupId>
>>  <artifactId>nexus-kungfu-virusscanner-plugin</artifactId>
>>  <version>1.0.0-SNAPSHOT</version>
>>  <name>Nexus Sample Plugins :: KungFu VirusScanner</name>
>>
>> <pluginSite>http://www.sonatype.com/people/2009/06/writing-plugins-for-nexus-part-1/</pluginSite>
>>  <applicationId>nexus</applicationId>
>>  <applicationEdition>OSS</applicationEdition>
>>  <applicationMinVersion>1.4.0</applicationMinVersion>
>> </plugin>
>>
>>
>> but should them also contain some components like in
>> https://docs.sonatype.com/display/NX/Nexus+Plugin+Packaging
>>
>> I've generated the plugin.xml with mvn package. Maven is version 2.2.1.
>>
>> regards
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
>> For additional commands, e-mail: nexus-dev-help@...
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
> For additional commands, e-mail: nexus-dev-help@...
>
--
Steffen Stundzig
Leiter Niederlassung Leipzig

Telefon: +49 (0) 341 / 231-0183-401
Telefax: +49 (0) 341 / 231-0183-411
Mobil:   +49 (0) 151 / 173-9673-1

http://itemis.de
http://twitter.com/itemis
steffen.stundzig@...
https://xing.com/profile/Steffen_Stundzig

itemis AG
Niederlassung Leipzig
Ludwig-Erhard-Straße 51
04103 Leipzig

Rechtlicher Hinweis:
Registergericht: Amtsgericht Dortmund HRB 20621
Sitz der Gesellschaft: 44536 Lünen, Am Brambusch 15-24
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vorsitzender), Stephan Grollmann,
Michael Neuhaus



package de.itemis.nexus.p2;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.inject.Inject;
import javax.inject.Named;

import org.slf4j.Logger;
import org.sonatype.nexus.logging.LoggerProvider;
import org.sonatype.nexus.proxy.attributes.StorageFileItemInspector;
import org.sonatype.nexus.proxy.item.StorageFileItem;
import org.sonatype.nexus.proxy.item.StorageItem;

@Named("bundleInstaller")
public class BundleInstaller implements StorageFileItemInspector {


        @Inject
        private LoggerProvider log;
       
        public Set<String> getIndexableKeywords() {
                // TODO Auto-generated method stub
                return null;
        }

        public boolean isHandled(StorageItem item) {
                return item.getName().toLowerCase().endsWith( "-bundle.zip" );
        }

        public void processStorageFileItem(StorageFileItem item, File file)
                        throws Exception {

                Enumeration<? extends ZipEntry> entries;
                ZipFile zipFile;
                String pluginDir;

                try {

                        pluginDir = (item.getRepositoryItemUid().getRepository()
                                        .getLocalUrl()
                                        + "../../plugin-repository/").substring("file:".length());
                        zipFile = new ZipFile(file);

                        entries = zipFile.entries();

                        while (entries.hasMoreElements()) {
                                ZipEntry entry = (ZipEntry) entries.nextElement();

                                if (entry.isDirectory()) {
                                        // Assume directories are stored parents first then
                                        // children.
                                        getLogger().info("Extracting directory: " + pluginDir
                                                        + entry.getName());
                                        // This is not robust, just for demonstration purposes.
                                        (new File(pluginDir + entry.getName())).mkdir();
                                        continue;
                                }

                                getLogger().info("Extracting file: "
                                                + entry.getName());
                                copyInputStream(zipFile.getInputStream(entry),
                                                new BufferedOutputStream(new FileOutputStream(pluginDir
                                                                + entry.getName())));
                               
                                getLogger().info("Bundle " + item.getName() + " was installed, please restart nexus.");
                        }

                        zipFile.close();
                } catch (IOException ioe) {
                        getLogger().error("Unhandled exception:", ioe);
                        ioe.printStackTrace();
                        return;
                }
        }

        public static final void copyInputStream(InputStream in, OutputStream out)
                        throws IOException {
                byte[] buffer = new byte[1024];
                int len;

                while ((len = in.read(buffer)) >= 0)
                        out.write(buffer, 0, len);

                in.close();
                out.close();
        }
       

        private Logger getLogger() {
                return log.getLogger(BundleInstaller.class
                                .getName());
        }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...

Re: auto deploy plugins

by Tamás Cservenák :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stefan, this is really cool what you did here!

But you can go one step further:
Look at the PM API:

nexusPluginManager.installBundle(File file);

;)

Also, alternative path would be to invoke activatePlugin (since you already installed it, but the above is the preferred way to go).

~t~

On Tue, Aug 18, 2009 at 5:48 PM, Steffen Stundzig <steffen.stundzig@...> wrote:
hi,

attached you can find my first nexus plugin which installs on the fly
deployed nexus bundles. ;)

regards

Brian Fox schrieb:
> This will only work with 1.4+. The plugin repository is a folder in
> sonatype-work/nexus/plugin-repository...so not a repo in nexus in the
> traditional sense, although that raises some interesting
> possibilities.
>
> On Tue, Aug 18, 2009 at 10:21 AM, Steffen
> Stundzig<steffen.stundzig@...> wrote:
>> Hi,
>>
>> I've installed and package the sample kungfu repository customizer. Now
>> I need to deploy them to nexus. But how can I do that?
>>
>> Blog and Wiki and Nabble say's
>>
>> copy the bundle zip to <nexus>/plugin-repository, unzip it und restart nexus
>>
>> So I've added a hosted repository named plugin-repository and unzipped
>> the bundle.zip into it and also restarted my nexus.
>>
>> But the virusscanner isn't loaded. I added some System.err.println into
>> the virusscanner-classes to track it. ;)
>>
>> What must I do?
>>
>> And finally I've tried the same with nexus 1.4.0-SNAPSHOT, with same
>> results.
>>
>> Next I analysed the generated META-INF/nexus/plugin.xml from the bundle.
>> It looks like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <plugin>
>>  <modelVersion>1.0.0</modelVersion>
>>  <groupId>org.sonatype.nexus.plugins.samples</groupId>
>>  <artifactId>nexus-kungfu-virusscanner-plugin</artifactId>
>>  <version>1.0.0-SNAPSHOT</version>
>>  <name>Nexus Sample Plugins :: KungFu VirusScanner</name>
>>
>> <pluginSite>http://www.sonatype.com/people/2009/06/writing-plugins-for-nexus-part-1/</pluginSite>
>>  <applicationId>nexus</applicationId>
>>  <applicationEdition>OSS</applicationEdition>
>>  <applicationMinVersion>1.4.0</applicationMinVersion>
>> </plugin>
>>
>>
>> but should them also contain some components like in
>> https://docs.sonatype.com/display/NX/Nexus+Plugin+Packaging
>>
>> I've generated the plugin.xml with mvn package. Maven is version 2.2.1.
>>
>> regards
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
>> For additional commands, e-mail: nexus-dev-help@...
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: nexus-dev-unsubscribe@...
> For additional commands, e-mail: nexus-dev-help@...
>

--
Steffen Stundzig
Leiter Niederlassung Leipzig

Telefon: +49 (0) 341 / 231-0183-401
Telefax: +49 (0) 341 / 231-0183-411
Mobil:   +49 (0) 151 / 173-9673-1

http://itemis.de
http://twitter.com/itemis
steffen.stundzig@...
https://xing.com/profile/Steffen_Stundzig

itemis AG
Niederlassung Leipzig
Ludwig-Erhard-Straße 51
04103 Leipzig

Rechtlicher Hinweis:
Registergericht: Amtsgericht Dortmund HRB 20621
Sitz der Gesellschaft: 44536 Lünen, Am Brambusch 15-24
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vorsitzender), Stephan Grollmann,
Michael Neuhaus



package de.itemis.nexus.p2;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.inject.Inject;
import javax.inject.Named;

import org.slf4j.Logger;
import org.sonatype.nexus.logging.LoggerProvider;
import org.sonatype.nexus.proxy.attributes.StorageFileItemInspector;
import org.sonatype.nexus.proxy.item.StorageFileItem;
import org.sonatype.nexus.proxy.item.StorageItem;

@Named("bundleInstaller")
public class BundleInstaller implements StorageFileItemInspector {


       @Inject
       private LoggerProvider log;

       public Set<String> getIndexableKeywords() {
               // TODO Auto-generated method stub
               return null;
       }

       public boolean isHandled(StorageItem item) {
               return item.getName().toLowerCase().endsWith( "-bundle.zip" );
       }

       public void processStorageFileItem(StorageFileItem item, File file)
                       throws Exception {

               Enumeration<? extends ZipEntry> entries;
               ZipFile zipFile;
               String pluginDir;

               try {

                       pluginDir = (item.getRepositoryItemUid().getRepository()
                                       .getLocalUrl()
                                       + "../../plugin-repository/").substring("file:".length());
                       zipFile = new ZipFile(file);

                       entries = zipFile.entries();

                       while (entries.hasMoreElements()) {
                               ZipEntry entry = (ZipEntry) entries.nextElement();

                               if (entry.isDirectory()) {
                                       // Assume directories are stored parents first then
                                       // children.
                                       getLogger().info("Extracting directory: " + pluginDir
                                                       + entry.getName());
                                       // This is not robust, just for demonstration purposes.
                                       (new File(pluginDir + entry.getName())).mkdir();
                                       continue;
                               }

                               getLogger().info("Extracting file: "
                                               + entry.getName());
                               copyInputStream(zipFile.getInputStream(entry),
                                               new BufferedOutputStream(new FileOutputStream(pluginDir
                                                               + entry.getName())));

                               getLogger().info("Bundle " + item.getName() + " was installed, please restart nexus.");
                       }

                       zipFile.close();
               } catch (IOException ioe) {
                       getLogger().error("Unhandled exception:", ioe);
                       ioe.printStackTrace();
                       return;
               }
       }

       public static final void copyInputStream(InputStream in, OutputStream out)
                       throws IOException {
               byte[] buffer = new byte[1024];
               int len;

               while ((len = in.read(buffer)) >= 0)
                       out.write(buffer, 0, len);

               in.close();
               out.close();
       }


       private Logger getLogger() {
               return log.getLogger(BundleInstaller.class
                               .getName());
       }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: auto deploy plugins

by Steffen Stundzig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

ok, and the nexusPluginManager I got per @Inject right?



Tamás Cservenák schrieb:
> Stefan, this is really cool what you did here!
> But you can go one step further:
> Look at the PM API:
> http://scm.sonatype.org/showfile.svn?path=/trunk/nexus/nexus-plugins/nexus-plugin-manager/src/main/java/org/sonatype/nexus/plugins/NexusPluginManager.java&revision=HEAD&name=Nexus
>
> nexusPluginManager.installBundle(File file);

is this file the zipped file or the unpacked directory?

regards

---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: auto deploy plugins

by Tamás Cservenák :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yup, true.


~t~

On Wed, Aug 19, 2009 at 9:23 AM, Steffen Stundzig <steffen.stundzig@...> wrote:
hi,

ok, and the nexusPluginManager I got per @Inject right?



Tamás Cservenák schrieb:
> Stefan, this is really cool what you did here!
> But you can go one step further:
> Look at the PM API:
> http://scm.sonatype.org/showfile.svn?path=/trunk/nexus/nexus-plugins/nexus-plugin-manager/src/main/java/org/sonatype/nexus/plugins/NexusPluginManager.java&revision=HEAD&name=Nexus
>
> nexusPluginManager.installBundle(File file);

is this file the zipped file or the unpacked directory?

regards

---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...



Re: auto deploy plugins

by Steffen Stundzig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

my other questions was:


>> Tamás Cservenák schrieb:
>>> nexusPluginManager.installBundle(File file);
>> is this file the zipped file or the unpacked directory?


---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...


Re: auto deploy plugins

by Tamás Cservenák :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry,

the input parameter is the ZIP File (so, not the unpacked dir).

~t~

On Wed, Aug 19, 2009 at 10:39 AM, Steffen Stundzig <steffen.stundzig@...> wrote:
hi,

my other questions was:


>> Tamás Cservenák schrieb:
>>> nexusPluginManager.installBundle(File file);
>> is this file the zipped file or the unpacked directory?


---------------------------------------------------------------------
To unsubscribe, e-mail: nexus-dev-unsubscribe@...
For additional commands, e-mail: nexus-dev-help@...