move nb-repository-plugin to his directory
diff --git a/.gitignore b/.gitignore
index a6f89c2..0fac148 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-/target/
\ No newline at end of file
+
+/target/
+/nbactions.xml
+
diff --git a/nb-repository-plugin/README.md b/nb-repository-plugin/README.md
new file mode 100644
index 0000000..fb922b3
--- /dev/null
+++ b/nb-repository-plugin/README.md
@@ -0,0 +1,45 @@
+#NetBeans Repository plugin
+
+The plugin is capable of populating the local or remote maven repository with module jars and NBM files from a given NetBeans installation. Useful for
+module development, modules with public APIs are separated from those without a public API.
+See the `populate` goal.
+
+ To get access to a repository with NetBeans.org module artifacts and metadata, add [http://bits.netbeans.org/maven2/](http://bits.netbeans.org/maven2/) repository to your project POM
+or the repository manager you are using. The repository hosts binaries of NetBeans 6.5 and later.
+
+ Also see: [Maven NBM development FAQs](http://wiki.netbeans.org/NetBeansDeveloperFAQ#Mavenized_Builds)
+
+## HOWTO: Upload NetBeans release binaries to a Maven repository
+
+There is a `populate` goal that converts the NetBeans module information into Maven metadata
+and is capable of uploading the module jar file, javadoc, sources and nbm files to local
+and remote repositories.
+
+For a binary-only upload (jar files and nbm files only), it's possible to download the bits from official sites. See below for URLs.
+
+For the complete upload, you will need to checkout the sources of the IDE/Platform you
+want to upload. See this FAQ entry on [HowTo checkout sources from Hg](http://wiki.netbeans.org/DevFaqAccessSourcesUsingMercurial)
+
+
+ The goal has multiple input parameters that link the goal to binaries prepared beforehand.
+
+* `netbeansInstallDirectory` designates the base directory where resides the NetBeans installation
+that shall be uploaded. It can be either [downloaded as zip](http://www.netbeans.org/downloads/index.html) or built from sources.
+Run `ant` in your local hg clone to build the distribution at `nbbuild/netbeans` sundirectory.
+
+* `netbeansNbmDirectory` designates the base directory where the nbm files are located.
+Run `ant build-nbms` in your local `hg clone` to build the nbms at `nbbuild/nbms` directory or download it from the
+[http://updates.netbeans.org/netbeans](http://updates.netbeans.org/netbeans) space eg.
+final *6.5* version at [http://updates.netbeans.org/netbeans/*6.5*/final/uc/](http://updates.netbeans.org/netbeans/6.5/final/uc/).
+Use a tool like `wget` to download the complete directory tree to a directory designated by the `netbeansNbmDirectory` parameter.
+
+* `netbeansSourcesDirectory` designates the base directory containing zip files with module jar sources.
+Run `ant build-source-zips` in your local hg clone to build the nbms at `nbbuild/build/source-zips` directory.
+
+* `netbeansJavadocDirectory` designates the base directory containing zip files with javadoc zips for modules with public apis.
+Run `ant build-javadoc` in your local hg clone to build the nbms at `nbbuild/build/javadoc` directory.
+
+* To have external dependencies correctly identified by their real GAV, you will need to download the index from central (or other) repository using the `download` goal.
+
+
+
diff --git a/nb-repository-plugin/pom.xml b/nb-repository-plugin/pom.xml
new file mode 100644
index 0000000..ea75681
--- /dev/null
+++ b/nb-repository-plugin/pom.xml
@@ -0,0 +1,444 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>mojo-parent</artifactId>
+ <version>40</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>nb-repository-plugin</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>NB Repository Plugin</name>
+ <description>Maven plugin for creating Maven Repository out of a NetBeans installation (and other sources) for consumption by the projects using nbm-maven-plugin.
+ </description>
+ <inceptionYear>2005</inceptionYear>
+ <url>https://github.com/mojohaus/nb-repository-plugin</url>
+ <issueManagement>
+ <system>GitHub</system>
+ <url>https://github.com/mojohaus/nb-repository-plugin/issues</url>
+ </issueManagement>
+ <prerequisites>
+ <maven>3.1.1</maven>
+ </prerequisites>
+ <licenses>
+ <license>
+ <name>Apache License 2</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:https://github.com/mojohaus/nb-repository-plugin.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mojohaus/nb-repository-plugin.git</developerConnection>
+ <url>https://github.com/mojohaus/nb-repository-plugin/tree/${project.scm.tag}</url>
+ <tag>master</tag>
+ </scm>
+ <developers>
+ <developer>
+ <id>mkleint</id>
+ <name>Milos Kleint</name>
+ <email>mkleint@gmail.com</email>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>jglick</id>
+ <name>Jesse Glick</name>
+ <email>jglick@codehaus.org</email>
+ <organization>Codehaus</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <id>ebarboni</id>
+ <name>Eric Barboni</name>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
+ <contributors>
+ <contributor>
+ <name>Johan Andrén</name>
+ <email>protected</email>
+ <roles>
+ <role>Patch Contributor</role>
+ <role>Goal Contributor</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Mykola Nikishov</name>
+ <email>mn@mn.com.ua</email>
+ <roles>
+ <role>Patch Contributor</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Frantisek Mantlik</name>
+ <email>frantisek@mantlik.cz</email>
+ <roles>
+ <role>Goal Contributor</role>
+ </roles>
+ </contributor>
+ </contributors>
+
+
+ <!-- TODO need to override parent version value... I suppose this will eventually end up in mojo parent pom, check regularly -->
+
+ <build>
+ <plugins>
+ <plugin>
+ <!-- TODO need to override parent version value... I suppose this will eventually end up in mojo parent pom, check regularly -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.5</version>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java17</artifactId>
+ <version>1.0</version>
+ </signature>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.6</version>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.9</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>plugins</report>
+ <!-- <report>cim</report> -->
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <version>2.12.1</version>
+
+ <configuration>
+ <!-- configure github milestone ? -->
+ <onlyMilestoneIssues>false</onlyMilestoneIssues>
+ <onlyCurrentVersion>false</onlyCurrentVersion>
+ </configuration>
+
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+
+ <configuration>
+ <configLocation>config/maven_checks.xml</configLocation>
+ <headerLocation>config/maven-header.txt</headerLocation>
+ </configuration>
+
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.5</version>
+ <configuration>
+ <requirements>
+ <!--
+ NOTE: Maven 2.x does not interpolate properties of the form project.*|pom.* so the Maven Plugin Plugin
+ gets garbage when manually examining the config of the Maven Compiler Plugin.
+ -->
+ <jdk>${mojo.java.target}</jdk>
+ </requirements>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>3.0.0-M1</version>
+ <configuration>
+ <quiet>true</quiet>
+ <links>
+ <!--<link>http://download-llnw.oracle.com/javaee/1.4/api/</link>-->
+ <!-- unreachable site <link>http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/</link>-->
+ <link>http://commons.apache.org/dbcp/apidocs/</link>
+ <link>http://commons.apache.org/fileupload/apidocs/</link>
+ <link>http://commons.apache.org/logging/apidocs/</link>
+ <link>http://commons.apache.org/pool/apidocs/</link>
+ <link>http://junit.sourceforge.net/javadoc/</link>
+ <link>http://logging.apache.org/log4j/1.2/apidocs/</link>
+ <!-- unreachable site <link>http://jakarta.apache.org/regexp/apidocs/</link> -->
+ <link>http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/</link>
+ <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-artifact/apidocs/</link>
+ <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-model/apidocs/</link>
+ <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-plugin-api/apidocs/</link>
+ <!-- unreachable site <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-project/apidocs/</link>-->
+ <!-- unreachable site <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-reporting/maven-reporting-api/apidocs/</link>-->
+ <link>http://maven.apache.org/ref/${mojo.javadoc.mavenVersion}/maven-settings/apidocs/</link>
+ </links>
+ <tagletArtifacts>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>3.4</version>
+ </tagletArtifact>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-javadoc</artifactId>
+ <version>1.6</version>
+ </tagletArtifact>
+ </tagletArtifacts>
+ </configuration>
+
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>3.8</version>
+ <configuration>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-linkcheck-plugin</artifactId>
+ <version>1.2</version>
+ <configuration>
+ <excludedLinks>
+ <excludedLink>../../images/codehaus-small.png</excludedLink>
+ <excludedLink>../../images/mojo_logo.png</excludedLink>
+ <excludedLink>plugin-info.html</excludedLink>
+ </excludedLinks>
+ <!--<excludedPages>
+ <excludedPage>dependencies.html</excludedPage>
+ </excludedPages>-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.7</version>
+ <configuration>
+ <instrumentation>
+ <excludes>
+ <exclude>**/HelpMojo.class</exclude>
+ </excludes>
+ </instrumentation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>2.0.0</version>
+ <configuration>
+ <debug>false</debug>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <goals>
+ <!-- default build in netbeans IDE -->
+ <goal>clean</goal>
+ <goal>install</goal>
+ </goals>
+ <filterProperties>
+ <netbeans.version>RELEASE82</netbeans.version>
+ </filterProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+ </profile>
+ </profiles>
+ <!--profiles>
+ <profile>
+ <id>tools.jar</id>
+ <activation>
+ <file>
+ <exists>${java.home}/../lib/tools.jar</exists>
+ </file>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.5.0</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles-->
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ <version>5.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>3.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>${maven.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.2</version>
+ <scope>compile</scope>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.indexer</groupId>
+ <artifactId>indexer-core</artifactId>
+ <version>6.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http</artifactId>
+ <version>${wagon.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nb-shared</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ <version>${wagon.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <mojo.java.target>1.6</mojo.java.target>
+ <wagon.version>3.0.0</wagon.version>
+ <maven.version>3.1.1</maven.version>
+ </properties>
+</project>
diff --git a/nb-repository-plugin/src/it/folder/pom.xml b/nb-repository-plugin/src/it/folder/pom.xml
new file mode 100644
index 0000000..570f86d
--- /dev/null
+++ b/nb-repository-plugin/src/it/folder/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nb-repository-plugin-it-root</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>nb-repository-plugin-it-single-module</artifactId>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nb-repository-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>install</phase>
+ <goals>
+ <goal>download</goal>
+ </goals>
+ <configuration>
+ <nexusIndexDirectory>${project.build.directory}/indextest</nexusIndexDirectory>
+ <repositoryUrl>http://repo1.maven.org/maven2</repositoryUrl>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/nb-repository-plugin/src/it/pom.xml b/nb-repository-plugin/src/it/pom.xml
new file mode 100644
index 0000000..6e264b2
--- /dev/null
+++ b/nb-repository-plugin/src/it/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nb-repository-plugin-it-root</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ <!--<plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@compilerPluginVersion@</version>
+ <configuration>
+ <source>@testJavaVersion@</source>
+ <target>@testJavaVersion@</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>@surefirePluginVersion@</version>
+ </plugin>-->
+ </plugins>
+ </pluginManagement>
+ </build>
+ <properties>
+ <jar.plugin.version>3.0.2</jar.plugin.version>
+ </properties>
+</project>
\ No newline at end of file
diff --git a/nb-repository-plugin/src/it/settings.xml b/nb-repository-plugin/src/it/settings.xml
new file mode 100644
index 0000000..5ee363c
--- /dev/null
+++ b/nb-repository-plugin/src/it/settings.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
diff --git a/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/DownloadIndexMojo.java b/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/DownloadIndexMojo.java
new file mode 100644
index 0000000..158abff
--- /dev/null
+++ b/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/DownloadIndexMojo.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2012 Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.codehaus.mojo.nbm.repository;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.index.NexusIndexer;
+import org.apache.maven.index.context.IndexCreator;
+import org.apache.maven.index.context.IndexingContext;
+import org.apache.maven.index.updater.IndexUpdateRequest;
+import org.apache.maven.index.updater.IndexUpdater;
+import org.apache.maven.index.updater.ResourceFetcher;
+import org.apache.maven.index.updater.WagonHelper;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.providers.http.HttpWagon;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+/**
+ * Goal for retrieving and expanding the lucene index of the given repository. That in turn is used by the <code>populate</code>
+ * goal.
+ * @author mkleint
+ */
+@Mojo(name="download", aggregator=true, requiresProject=false)
+public class DownloadIndexMojo extends AbstractMojo implements Contextualizable {
+
+ /**
+ * url of the repository to download index from. Please note that if you already have
+ * an existing index at <code>nexusIndexDirectory</code>, you should always use the same url for that directory.
+ */
+ @Parameter(required=true, property="repositoryUrl")
+ private String repositoryUrl;
+
+ /**
+ * location on disk where the index should be created. either empty or with existing index from same repository. then only update check will
+ * be performed.
+ */
+ @Parameter(required=true, property="nexusIndexDirectory")
+ private File nexusIndexDirectory;
+
+ @Component
+ IndexUpdater remoteIndexUpdater;
+
+ @Component
+ NexusIndexer indexer;
+
+ PlexusContainer container;
+
+
+ @Component
+ WagonManager wagonManager;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ try
+ {
+ List<IndexCreator> creators = new ArrayList<IndexCreator>();
+ creators.addAll(container.lookupList(IndexCreator.class));
+ String indexurl = repositoryUrl + (!repositoryUrl.endsWith( "/") ? "/" : "") + ".index";
+ IndexingContext indexingContext = indexer.addIndexingContextForced(
+ "central", // context id
+ "central", // repository id
+ null, // repository folder
+ nexusIndexDirectory,
+ repositoryUrl,// repositoryUrl
+ indexurl,
+ creators);
+
+ String protocol = URI.create(repositoryUrl).getScheme();
+ ProxyInfo wagonProxy = wagonManager.getProxy( protocol );
+ TransferListener tr = new TransferListener() {
+
+ @Override
+ public void transferInitiated( TransferEvent transferEvent )
+ {
+ getLog().info( "Initiated connection to " + repositoryUrl);
+ }
+
+ @Override
+ public void transferStarted( TransferEvent transferEvent )
+ {
+ getLog().info( "Started transfer of " + repositoryUrl + "/.index/" + transferEvent.getResource().toString());
+ }
+
+ @Override
+ public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
+ {
+ }
+
+ @Override
+ public void transferCompleted( TransferEvent transferEvent )
+ {
+ getLog().info( "Finished transfer of " + repositoryUrl + "/.index/" + transferEvent.getResource().toString());
+ }
+
+ @Override
+ public void transferError( TransferEvent transferEvent )
+ {
+ getLog().error( "Failed transfer of " + repositoryUrl + "/.index/" + transferEvent.getResource().toString(), transferEvent.getException());
+ }
+
+ @Override
+ public void debug( String message )
+ {
+ }
+ };
+ // MINDEXER-42: cannot use WagonHelper.getWagonResourceFetcher
+ Wagon wagon = container.lookup(Wagon.class, protocol);
+ if (wagon instanceof HttpWagon) { //#216401
+ HttpWagon httpwagon = (HttpWagon) wagon;
+ //#215343
+ Properties p = new Properties();
+ p.setProperty("User-Agent", "mojo/nb-repository-plugin");
+ httpwagon.setHttpHeaders(p);
+ }
+
+ ResourceFetcher fetcher = new WagonHelper.WagonFetcher(wagon, tr, null, wagonProxy);
+ IndexUpdateRequest iur = new IndexUpdateRequest(indexingContext, fetcher);
+
+ remoteIndexUpdater.fetchAndUpdateIndex(iur);
+ indexer.removeIndexingContext(indexingContext, false);
+ }
+ catch ( Exception ex )
+ {
+ throw new MojoExecutionException( "Cannot download index", ex);
+ }
+ }
+
+ @Override
+ public void contextualize( Context context ) throws ContextException
+ {
+ this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ }
+
+
+}
diff --git a/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojo.java b/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojo.java
new file mode 100644
index 0000000..d59670e
--- /dev/null
+++ b/nb-repository-plugin/src/main/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojo.java
@@ -0,0 +1,1266 @@
+/* ==========================================================================
+ * Copyright 2003-2006 Mevenide Team
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =========================================================================
+ */
+package org.codehaus.mojo.nbm.repository;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+import java.security.DigestOutputStream;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.artifact.AttachedArtifact;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Input;
+import org.apache.tools.ant.taskdefs.PathConvert;
+import org.apache.tools.ant.types.FileSet;
+import org.codehaus.mojo.nbm.utils.AbstractNetbeansMojo;
+import org.codehaus.mojo.nbm.utils.ExamineManifest;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * A goal for identifying NetBeans modules from the installation and populating the local
+ * repository with them. Optionally you can also deploy to a remote repository.
+ * <p>
+ * If you are looking for an existing remote repository for NetBeans artifacts, check out
+ * <a href="http://bits.netbeans.org/nexus/content/groups/netbeans/">http://bits.netbeans.org/nexus/content/groups/netbeans/</a>,
+ * it contains API artifacts for multiple releases.
+ * <a href="http://bits.netbeans.org/netbeans/trunk/maven-snapshot/">http://bits.netbeans.org/netbeans/trunk/maven-snapshot/</a>
+ * may also be used for <code>SNAPSHOT</code> artifacts if you wish to test development builds.
+ * </p><p>
+ * See this <a href="http://mojo.codehaus.org/nbm-maven/nbm-maven-plugin/repository.html">HOWTO</a> on how to generate the NetBeans binaries required
+ * by this goal.
+ * </p>
+ *
+ * @author <a href="mailto:mkleint@codehaus.org">Milos Kleint</a>
+ */
+@Mojo(name="populate", aggregator=true, requiresProject=false)
+public class PopulateRepositoryMojo
+ extends AbstractNetbeansMojo
+{
+ private static final String GROUP_API = ".api";
+ private static final String GROUP_IMPL = ".modules";
+ private static final String GROUP_EXTERNAL = ".external";
+ private static final String GROUP_CLUSTER = ".cluster";
+
+
+ /**
+ * a prefix for groupId of generated content,
+ * eg. for org.netbeans value will generate org.netbeans.cluster groupId for clusters and org.netbeans.modules for module artifacts.
+ * @since 1.2
+ */
+ @Parameter(property="groupIdPrefix", defaultValue = "org.netbeans")
+ private String groupIdPrefix;
+
+ /**
+ * an url where to deploy the NetBeans artifacts. Optional, if not specified, the artifacts will be only installed
+ * in local repository, if you need to give credentials to access remote repo, the id of the server is hardwired to "netbeans".
+ */
+ @Parameter(property="deployUrl")
+ private String deployUrl;
+
+ /**
+ * By default the generated metadata is installed in local repository.
+ * Setting this parameter to false will avoid installing the bits. Only meaningful together with
+ * a defined "deployUrl" parameter.
+ * @since 3.0
+ */
+ @Parameter(defaultValue="false", property="skipInstall")
+ private boolean skipLocalInstall;
+
+
+ /**
+ * Location of NetBeans installation
+ */
+ @Parameter(property="netbeansInstallDirectory", required=true)
+ protected File netbeansInstallDirectory;
+
+ /**
+ * If you want to install/deploy also NetBeans api javadocs, download the javadoc zip file from netbeans.org
+ * expand it to a directory, it should contain multiple zip files. Define this parameter as absolute path to the zip files folder.
+ *
+ */
+ @Parameter(property="netbeansJavadocDirectory")
+ protected File netbeansJavadocDirectory;
+
+ /**
+ * Assumes a folder with <code-name-base>.zip files containing sources for modules.
+ */
+ @Parameter(property="netbeansSourcesDirectory")
+ protected File netbeansSourcesDirectory;
+
+ /**
+ * If defined, will match the nbm files found in the designated folder with the modules
+ * and upload the nbm file next to the module jar in local and remote repositories.
+ *
+ * Assumes a folder with <code-name-base>.nbm files containing nbm files for modules.
+ * @since 3.0
+ */
+ @Parameter(property="netbeansNbmDirectory", required=true)
+ protected File netbeansNbmDirectory;
+
+ /**
+ * When specified, will force all modules to have the designated version.
+ * Good when depending on releases. Then you would for example specify RELEASE50 in this parameter and
+ * all modules get this version in the repository. If not defined, the maven version is
+ * derived from the OpenIDE-Module-Specification-Version manifest attribute.
+ * <p>
+ * Highly Recommended!
+ * </p>
+ */
+ @Parameter(property="forcedVersion")
+ protected String forcedVersion;
+
+ /**
+ * When specified it points to a directory containing a Maven Indexer
+ * (Nexus) Lucene index. This index will be used to find external libraries that
+ * are referenced by NetBeans modules and populate the POM metadata with correct
+ * dependencies. Any dependencies not found this way, will be generated with a unique
+ * id under the org.netbeans.external groupId.
+ * <p/>
+ * Use the {@code download} goal to retrieve the index.
+ * @since 3.0
+ */
+ @Parameter(property="nexusIndexDirectory")
+ private File nexusIndexDirectory;
+
+ /**
+ * Whether to create cluster POMs in the {@code org.netbeans.cluster} group.
+ * Only meaningful when {@code forcedVersion} is defined.
+ * @since 3.7
+ */
+ @Parameter(defaultValue="true", property="defineCluster")
+ private boolean defineCluster;
+
+ /**
+ * Optional remote repository to use for inspecting remote dependencies.
+ * This may be used to populate just part of an installation,
+ * when base modules are already available in Maven format.
+ * Currently only supported when {@code forcedVersion} is defined.
+ * @since 3.7
+ */
+ @Parameter(property="dependencyRepositoryUrl")
+ private String dependencyRepositoryUrl;
+
+ /**
+ * Repository ID to use when inspecting remote dependencies.
+ * Only meaningful when {@code dependencyRepositoryUrl} is defined.
+ * @since 3.7
+ */
+ @Parameter(defaultValue="temp", property="dependencyRepositoryId")
+ private String dependencyRepositoryId;
+
+ // <editor-fold defaultstate="collapsed" desc="Component parameters">
+ /**
+ * Local maven repository.
+ */
+ @Parameter(required=true, readonly=true, defaultValue="${localRepository}")
+ protected ArtifactRepository localRepository;
+
+ /**
+ * Maven ArtifactFactory.
+ */
+ @Component
+ private ArtifactFactory artifactFactory;
+
+ /**
+ * Maven ArtifactInstaller.
+ */
+ @Component
+ private ArtifactInstaller artifactInstaller;
+
+ /**
+ * Maven ArtifactDeployer.
+ *
+ */
+ @Component
+ private ArtifactDeployer artifactDeployer;
+
+ /**
+ * Maven ArtifactHandlerManager
+ *
+ */
+ @Component
+ private ArtifactHandlerManager artifactHandlerManager;
+
+ /**
+ * Maven ArtifactRepositoryFactory.
+ *
+ */
+ @Component
+ private ArtifactRepositoryFactory repositoryFactory;
+
+ @Component
+ private ArtifactResolver artifactResolver;
+
+ @Component
+ private ArtifactRepositoryLayout artifactRepositoryLayout;
+// </editor-fold>
+
+ @Override
+ public void execute()
+ throws MojoExecutionException
+ {
+ getLog().info( "Populate repository with NetBeans modules" );
+ Project antProject = antProject();
+ ArtifactRepository deploymentRepository = null;
+ if ( deployUrl != null )
+ {
+ ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
+ deploymentRepository = repositoryFactory.createDeploymentArtifactRepository(
+ "netbeans", deployUrl, layout, true );
+ }
+ else if ( skipLocalInstall )
+ {
+ throw new MojoExecutionException(
+ "When skipping install to local repository, one shall define the deployUrl parameter" );
+ }
+
+ IndexSearcher searcher = null;
+ if ( nexusIndexDirectory != null && nexusIndexDirectory.exists() )
+ {
+ try
+ {
+ Directory nexusDir = FSDirectory.open( nexusIndexDirectory.toPath() );
+ IndexReader nexusReader = DirectoryReader.open( nexusDir );
+ searcher = new IndexSearcher( nexusReader );
+ getLog().info( "Opened index with " + nexusReader.numDocs() + " documents" );
+ }
+ catch ( IOException ex )
+ {
+ getLog().error( "Could not open " + nexusIndexDirectory, ex );
+ }
+ }
+
+ if ( netbeansInstallDirectory == null )
+ {
+ Input input = (Input) antProject.createTask( "input" );
+ input.setMessage( "Please enter NetBeans installation directory:" );
+ input.setAddproperty( "installDir" );
+ try
+ {
+ input.execute();
+ }
+ catch ( BuildException e )
+ {
+ getLog().error( "Cannot run ant:input" );
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ String prop = antProject.getProperty( "installDir" );
+ netbeansInstallDirectory = new File( prop );
+ }
+
+ File rootDir = netbeansInstallDirectory;
+ if ( !rootDir.exists() )
+ {
+ getLog().error( "NetBeans installation doesn't exist." );
+ throw new MojoExecutionException( "NetBeans installation doesn't exist." );
+ }
+ getLog().info( "Copying NetBeans artifacts from " + netbeansInstallDirectory );
+
+ PathConvert convert = (PathConvert) antProject.createTask( "pathconvert" );
+ convert.setPathSep( "," );
+ convert.setProperty( "netbeansincludes" );
+ FileSet set = new FileSet();
+ set.setDir( rootDir );
+ set.createInclude().setName( "**/modules/*.jar" );
+ set.createInclude().setName( "*/core/*.jar" );
+ set.createInclude().setName( "platform*/lib/*.jar" );
+
+ convert.createPath().addFileset( set );
+ try
+ {
+ convert.execute();
+ }
+ catch ( BuildException e )
+ {
+ getLog().error( "Cannot run ant:pathconvert" );
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+
+ String prop = antProject.getProperty( "netbeansincludes" );
+ StringTokenizer tok = new StringTokenizer( prop, "," );
+ HashMap<ModuleWrapper, Artifact> moduleDefinitions = new HashMap<ModuleWrapper, Artifact>();
+ HashMap<String, Collection<ModuleWrapper>> clusters = new HashMap<String, Collection<ModuleWrapper>>();
+ while ( tok.hasMoreTokens() )
+ {
+ String token = tok.nextToken();
+ File module = new File( token );
+ String clust = module.getAbsolutePath().substring( rootDir.getAbsolutePath().length() + 1 );
+ clust = clust.substring( 0, clust.indexOf( File.separator ) );
+ ExamineManifest examinator = new ExamineManifest( getLog() );
+ examinator.setPopulateDependencies( true );
+ examinator.setJarFile( module );
+ examinator.checkFile();
+ if ( examinator.isNetBeansModule() || examinator.isOsgiBundle() )
+ {
+ //TODO get artifact id from the module's manifest?
+ String artifact = module.getName().substring( 0, module.getName().indexOf( ".jar" ) );
+ if ( "boot".equals( artifact ) )
+ {
+ artifact = "org-netbeans-bootstrap";
+ }
+ if ( "core".equals( artifact ) )
+ {
+ artifact = "org-netbeans-core-startup";
+ }
+ if ( "core-base".equals( artifact ) )
+ {
+ artifact = "org-netbeans-core-startup-base";
+ }
+ String version = forcedVersion == null ? examinator.getSpecVersion() : forcedVersion;
+ String group = groupIdPrefix + (examinator.isOsgiBundle() ? GROUP_EXTERNAL : examinator.hasPublicPackages() ? GROUP_API : GROUP_IMPL);
+ Artifact art = createArtifact( artifact, version, group );
+ if ( examinator.isOsgiBundle() )
+ {
+ Dependency dep = findExternal( searcher, module );
+ if ( dep != null )
+ {
+ // XXX use those coords instead of publishing this
+ // (for now all bundles are from Orbit, which does not publish to Central, or specially built)
+ }
+ }
+ ModuleWrapper wr = new ModuleWrapper( artifact, version, group, examinator, module );
+ wr.setCluster( clust );
+ moduleDefinitions.put( wr, art );
+ Collection<ModuleWrapper> col = clusters.get( clust );
+ if ( col == null )
+ {
+ col = new ArrayList<ModuleWrapper>();
+ clusters.put( clust, col );
+ }
+ col.add( wr );
+ }
+ }
+ List<ModuleWrapper> wrapperList = new ArrayList<ModuleWrapper>( moduleDefinitions.keySet() );
+ int count = wrapperList.size() + 1;
+ int index = 0;
+ File javadocRoot = null;
+ if ( netbeansJavadocDirectory != null )
+ {
+ javadocRoot = netbeansJavadocDirectory ;
+ if ( !javadocRoot.exists() )
+ {
+ javadocRoot = null;
+ throw new MojoExecutionException(
+ "The netbeansJavadocDirectory parameter doesn't point to an existing folder" );
+ }
+ }
+ File sourceRoot = null;
+ if ( netbeansSourcesDirectory != null )
+ {
+ sourceRoot = netbeansSourcesDirectory;
+ if ( !sourceRoot.exists() )
+ {
+ sourceRoot = null;
+ throw new MojoExecutionException(
+ "The netbeansSourceDirectory parameter doesn't point to an existing folder" );
+ }
+ }
+
+ File nbmRoot = null;
+ if ( netbeansNbmDirectory != null )
+ {
+ nbmRoot = netbeansNbmDirectory;
+ if ( !nbmRoot.exists() )
+ {
+ nbmRoot = null;
+ throw new MojoExecutionException(
+ "The nbmDirectory parameter doesn't point to an existing folder" );
+ }
+ }
+
+ List<ExternalsWrapper> externals = new ArrayList<ExternalsWrapper>();
+ try
+ {
+ for ( Map.Entry<ModuleWrapper, Artifact> elem : moduleDefinitions.entrySet() )
+ {
+ ModuleWrapper man = elem.getKey();
+ Artifact art = elem.getValue();
+ index = index + 1;
+ getLog().info( "Processing " + index + "/" + count );
+ File pom = createMavenProject( man, wrapperList, externals, searcher );
+ ArtifactMetadata metadata = new ProjectArtifactMetadata( art, pom );
+ art.addMetadata( metadata );
+ File javadoc = null;
+ Artifact javadocArt = null;
+ if ( javadocRoot != null )
+ {
+ File zip = new File( javadocRoot, art.getArtifactId() + ".zip" );
+ if ( zip.exists() )
+ {
+ javadoc = zip;
+ javadocArt = createAttachedArtifact( art, javadoc, "jar", "javadoc" );
+ }
+ }
+ File source = null;
+ Artifact sourceArt = null;
+ if ( sourceRoot != null )
+ {
+ File zip = new File( sourceRoot, art.getArtifactId() + ".zip" );
+ if ( zip.exists() )
+ {
+ source = zip;
+ sourceArt = createAttachedArtifact( art, source, "jar", "sources" );
+ }
+ }
+ File nbm = null;
+ Artifact nbmArt = null;
+ if ( nbmRoot != null )
+ {
+ File zip = new File( nbmRoot, art.getArtifactId() + ".nbm" );
+
+ if ( !zip.exists() )
+ {
+ zip = new File( nbmRoot,
+ man.getCluster() + File.separator + art.getArtifactId() + ".nbm" );
+ }
+ if ( zip.exists() )
+ {
+ nbm = zip;
+ nbmArt = createAttachedArtifact( art, nbm, "nbm-file", null );
+ if ( nbmArt.getArtifactHandler().getExtension().equals( "nbm-file" ) )
+ {
+ // Maven 2.x compatibility.
+ nbmArt = createAttachedArtifact( art, nbm, "nbm", null );
+ }
+ assert nbmArt.getArtifactHandler().getExtension().equals( "nbm" );
+ }
+ }
+ File moduleJar = man.getFile();
+ File moduleJarMinusCP = null;
+ if ( ! man.getModuleManifest().getClasspath().isEmpty() )
+ {
+ try
+ {
+ moduleJarMinusCP = File.createTempFile( man.getArtifact(), ".jar" );
+ moduleJarMinusCP.deleteOnExit();
+ InputStream is = new FileInputStream( moduleJar );
+ try
+ {
+ OutputStream os = new FileOutputStream( moduleJarMinusCP );
+ try
+ {
+ JarInputStream jis = new JarInputStream( is );
+ Manifest mani = new Manifest( jis.getManifest() );
+ mani.getMainAttributes().remove( Attributes.Name.CLASS_PATH );
+ if ( !man.deps.isEmpty() )
+ { // MNBMODULE-132
+ StringBuilder b = new StringBuilder();
+ for ( Dependency dep : man.deps )
+ {
+ if ( b.length() > 0 )
+ {
+ b.append( ' ' );
+ }
+ b.append( dep.getGroupId() ).append( ':' ).append( dep.getArtifactId() ).append( ':' ).append( dep.getVersion() );
+ if (dep.getClassifier() != null) {
+ b.append(":").append(dep.getClassifier());
+ }
+ }
+ mani.getMainAttributes().putValue( "Maven-Class-Path", b.toString() );
+ }
+ else
+ {
+ getLog().warn( "did not find any external artifacts for " + man.getModule() );
+ }
+ JarOutputStream jos = new JarOutputStream( os, mani );
+ JarEntry entry;
+ while ( ( entry = jis.getNextJarEntry() ) != null )
+ {
+ if ( entry.getName().matches( "META-INF/.+[.]SF" ) )
+ {
+ throw new IOException( "cannot handle signed JARs" );
+ }
+ jos.putNextEntry( entry );
+ byte[] buf = new byte[(int) entry.getSize()];
+ int read = jis.read( buf, 0, buf.length );
+ if ( read != buf.length )
+ {
+ throw new IOException( "read wrong amount" );
+ }
+ jos.write( buf );
+ }
+ jos.close();
+ }
+ finally
+ {
+ os.close();
+ }
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+ catch ( IOException x )
+ {
+ getLog().warn( "Could not process " + moduleJar + ": " + x, x );
+ moduleJarMinusCP.delete();
+ moduleJarMinusCP = null;
+ }
+ }
+ try
+ {
+ if ( !skipLocalInstall )
+ {
+ install( moduleJarMinusCP != null ? moduleJarMinusCP : moduleJar, art );
+ if ( javadoc != null )
+ {
+ install( javadoc, javadocArt );
+ }
+ if ( source != null )
+ {
+ install( source, sourceArt );
+ }
+ if ( nbm != null )
+ {
+ install( nbm, nbmArt );
+ }
+ }
+ try
+ {
+ if ( deploymentRepository != null )
+ {
+ artifactDeployer.deploy( moduleJarMinusCP != null ? moduleJarMinusCP : moduleJar, art,
+ deploymentRepository, localRepository );
+ if ( javadoc != null )
+ {
+ artifactDeployer.deploy( javadoc, javadocArt, deploymentRepository, localRepository );
+ }
+ if ( source != null )
+ {
+ artifactDeployer.deploy( source, sourceArt, deploymentRepository, localRepository );
+ }
+ if ( nbm != null )
+ {
+ artifactDeployer.deploy( nbm, nbmArt, deploymentRepository, localRepository );
+ }
+ }
+ }
+ catch ( ArtifactDeploymentException ex )
+ {
+ throw new MojoExecutionException( "Error Deploying artifact", ex );
+ }
+ }
+ finally
+ {
+ if ( moduleJarMinusCP != null )
+ {
+ moduleJarMinusCP.delete();
+ }
+ }
+ }
+ }
+ finally
+ {
+ /*if ( searcher != null )
+ {
+ try
+ {
+ searcher.close();
+ }
+ catch ( IOException ex )
+ {
+ getLog().error( ex );
+ }
+ }*/
+ }
+
+ //process collected non-recognized external jars..
+ if ( externals.size() > 0 )
+ {
+ index = 0;
+ count = externals.size();
+ for ( ExternalsWrapper ex : externals )
+ {
+ Artifact art = createArtifact( ex.getArtifact(), ex.getVersion(), ex.getGroupid() );
+ index = index + 1;
+ getLog().info( "Processing external " + index + "/" + count );
+ File pom = createExternalProject( ex );
+ ArtifactMetadata metadata = new ProjectArtifactMetadata( art, pom );
+ art.addMetadata( metadata );
+ if ( !skipLocalInstall )
+ {
+ install( ex.getFile(), art );
+ }
+ try
+ {
+ if ( deploymentRepository != null )
+ {
+ artifactDeployer.deploy( ex.getFile(), art,
+ deploymentRepository, localRepository );
+ }
+ }
+ catch ( ArtifactDeploymentException exc )
+ {
+ throw new MojoExecutionException( "Error Deploying artifact", exc );
+ }
+ }
+ }
+
+ if ( ! defineCluster )
+ {
+ getLog().info( "Not creating cluster POMs." );
+ }
+ else if ( forcedVersion == null )
+ {
+ getLog().warn( "Version not specified, cannot create cluster POMs." );
+ }
+ else
+ {
+ for ( Map.Entry<String, Collection<ModuleWrapper>> elem : clusters.entrySet() )
+ {
+ String cluster = stripClusterName( elem.getKey() );
+ Collection<ModuleWrapper> modules = elem.getValue();
+ getLog().info( "Processing cluster " + cluster );
+ Artifact art = createClusterArtifact( cluster, forcedVersion );
+ File pom = createClusterProject( art, modules );
+ ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( art, pom );
+ art.addMetadata( metadata );
+ if ( !skipLocalInstall )
+ {
+ install( pom, art );
+ }
+ try
+ {
+ if ( deploymentRepository != null )
+ {
+ artifactDeployer.deploy( pom, art, deploymentRepository, localRepository );
+ }
+ }
+ catch ( ArtifactDeploymentException ex )
+ {
+ throw new MojoExecutionException( "Error Deploying artifact", ex );
+ }
+ }
+
+ }
+ }
+
+ void install( File file, Artifact art )
+ throws MojoExecutionException
+ {
+ assert localRepository != null;
+ try
+ {
+ artifactInstaller.install( file, art, localRepository );
+ }
+ catch ( ArtifactInstallationException e )
+ {
+ // TODO: install exception that does not give a trace
+ throw new MojoExecutionException( "Error installing artifact", e );
+ }
+ }
+
+ //performs the same tasks as the MavenProjectHelper
+ Artifact createAttachedArtifact( Artifact primary, File file, String type, String classifier )
+ {
+ assert type != null;
+
+ ArtifactHandler handler;
+
+ handler = artifactHandlerManager.getArtifactHandler( type );
+
+ if ( handler == null )
+ {
+ getLog().warn( "No artifact handler for " + type );
+ handler = artifactHandlerManager.getArtifactHandler( "jar" );
+ }
+
+ Artifact artifact = new AttachedArtifact( primary, type, classifier, handler );
+
+ artifact.setFile( file );
+ artifact.setResolved( true );
+ return artifact;
+ }
+
+ private File createMavenProject( ModuleWrapper wrapper, List<ModuleWrapper> wrapperList,
+ List<ExternalsWrapper> externalsList, IndexSearcher searcher )
+ throws MojoExecutionException
+ {
+ Model mavenModel = new Model();
+
+ mavenModel.setGroupId( wrapper.getGroup() );
+ mavenModel.setArtifactId( wrapper.getArtifact() );
+ mavenModel.setVersion( wrapper.getVersion() );
+ mavenModel.setPackaging( "jar" );
+ mavenModel.setModelVersion( "4.0.0" );
+ ExamineManifest man = wrapper.getModuleManifest();
+ List<Dependency> deps = new ArrayList<Dependency>();
+ if ( !man.getDependencyTokens().isEmpty() )
+ {
+ for ( String elem : man.getDependencyTokens() )
+ {
+ // create pseudo wrapper
+ ModuleWrapper wr = new ModuleWrapper( elem );
+ int index = wrapperList.indexOf( wr );
+ if ( index > -1 )
+ {
+ wr = wrapperList.get( index );
+ Dependency dep = new Dependency();
+ dep.setArtifactId( wr.getArtifact() );
+ dep.setGroupId( wr.getGroup() );
+ dep.setVersion( wr.getVersion() );
+ dep.setType( "jar" );
+ //we don't want the API modules to depend on non-api ones..
+ // otherwise the transitive dependency mechanism pollutes your classpath..
+ if ( wrapper.getModuleManifest().hasPublicPackages() && !wr.getModuleManifest().hasPublicPackages() )
+ {
+ dep.setScope( "runtime" );
+ }
+ deps.add( dep );
+ }
+ else if ( dependencyRepositoryUrl != null )
+ {
+ Dependency dep = new Dependency();
+ dep.setType( "jar" );
+ String artifactId = elem.replace( '.', '-' );
+ dep.setArtifactId( artifactId );
+ if ( forcedVersion == null )
+ {
+ throw new MojoExecutionException( "Cannot use dependencyRepositoryUrl without forcedVersion" );
+ }
+ dep.setVersion( forcedVersion );
+ ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
+ List<ArtifactRepository> repos = Collections.singletonList(
+ repositoryFactory.createArtifactRepository( dependencyRepositoryId, dependencyRepositoryUrl, artifactRepositoryLayout, policy, policy) );
+ try
+ {
+ artifactResolver.resolve( artifactFactory.createBuildArtifact( groupIdPrefix + GROUP_API, artifactId, forcedVersion, "pom" ), repos, localRepository );
+ dep.setGroupId( groupIdPrefix + GROUP_API );
+ }
+ catch ( AbstractArtifactResolutionException x )
+ {
+ try
+ {
+ artifactResolver.resolve( artifactFactory.createBuildArtifact( groupIdPrefix + GROUP_IMPL, artifactId, forcedVersion, "pom" ), repos, localRepository );
+ dep.setGroupId( groupIdPrefix + GROUP_IMPL );
+ if ( wrapper.getModuleManifest().hasPublicPackages() )
+ {
+ dep.setScope( "runtime" );
+ }
+ }
+ catch ( AbstractArtifactResolutionException x2 )
+ {
+ try
+ {
+ artifactResolver.resolve( artifactFactory.createBuildArtifact( groupIdPrefix + GROUP_EXTERNAL, artifactId, forcedVersion, "pom" ), repos, localRepository );
+ dep.setGroupId( groupIdPrefix + GROUP_EXTERNAL );
+ if ( wrapper.getModuleManifest().hasPublicPackages() )
+ {
+ dep.setScope( "runtime" );
+ }
+ }
+ catch ( AbstractArtifactResolutionException x3 )
+ {
+ getLog().warn( x3.getOriginalMessage() );
+ throw new MojoExecutionException( "No module found for dependency '" + elem + "'", x );
+ }
+
+
+ }
+
+ }
+ deps.add( dep );
+ }
+ else
+ {
+ getLog().warn( "No module found for dependency '" + elem + "'" );
+ }
+ }
+ }
+ //need some generic way to handle Classpath: items.
+ //how to figure the right version?
+ String cp = wrapper.getModuleManifest().getClasspath();
+ if ( !cp.isEmpty() )
+ {
+ StringTokenizer tok = new StringTokenizer( cp );
+ while ( tok.hasMoreTokens() )
+ {
+ String path = tok.nextToken();
+ File f = new File( wrapper.getFile().getParentFile(), path );
+ if ( f.exists() )
+ {
+ Dependency dep = findExternal( searcher, f );
+ if ( dep != null )
+ {
+ deps.add( dep );
+ // XXX MNBMODULE-170: repack NBM with *.external
+ }
+ else
+ {
+ ExternalsWrapper ex = new ExternalsWrapper();
+ ex.setFile( f );
+ String artId = f.getName();
+ if ( artId.endsWith( ".jar" ) )
+ {
+ artId = artId.substring( 0, artId.length() - ".jar".length() );
+ }
+ ex.setVersion( wrapper.getVersion() );
+ ex.setArtifact( artId );
+ ex.setGroupid( groupIdPrefix + GROUP_EXTERNAL );
+ externalsList.add( ex );
+ dep = new Dependency();
+ dep.setArtifactId( artId );
+ dep.setGroupId( groupIdPrefix + GROUP_EXTERNAL );
+ dep.setVersion( wrapper.getVersion() );
+ dep.setType( "jar" );
+ deps.add( dep );
+ }
+ }
+ }
+ }
+
+ wrapper.deps = deps;
+ mavenModel.setDependencies( deps );
+ FileWriter writer = null;
+ File fil = null;
+ try
+ {
+ MavenXpp3Writer xpp = new MavenXpp3Writer();
+ fil = File.createTempFile( "maven", ".pom" );
+ fil.deleteOnExit();
+ writer = new FileWriter( fil );
+ xpp.write( writer, mavenModel );
+ }
+ catch ( IOException ex )
+ {
+ ex.printStackTrace();
+
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException io )
+ {
+ io.printStackTrace();
+ }
+ }
+ }
+ return fil;
+ }
+
+ private Dependency findExternal( IndexSearcher searcher, File f )
+ {
+ if ( searcher == null )
+ {
+ return null;
+ }
+ try
+ {
+ MessageDigest shaDig = MessageDigest.getInstance( "SHA1" );
+ InputStream is = new FileInputStream( f );
+ try {
+ OutputStream os = new DigestOutputStream( new NullOutputStream(), shaDig );
+ IOUtil.copy( is, os );
+ os.close();
+ }
+ finally
+ {
+ is.close();
+ }
+ String sha = encode( shaDig.digest() );
+ TermQuery q = new TermQuery( new Term( "1", sha ) );
+ TopScoreDocCollector collector = TopScoreDocCollector.create( 5 );
+ searcher.search(q, collector);
+ ScoreDoc[] hits = collector.topDocs().scoreDocs;
+ if ( hits.length >= 1 )
+ {
+ int docId = hits[0].doc;
+ Document doc = searcher.doc(docId);
+ IndexableField idField = doc.getField( "u" );
+ if ( idField != null )
+ {
+ String id = idField.stringValue();
+ String[] splits = StringUtils.split( id, "|" );
+ Dependency dep = new Dependency();
+ dep.setArtifactId( splits[1] );
+ dep.setGroupId( splits[0] );
+ dep.setVersion( splits[2] );
+ dep.setType( "jar" );
+ if ( splits.length > 3 && !"NA".equals( splits[3] ) )
+ {
+ dep.setClassifier( splits[3] );
+ }
+ getLog().info( "found match " + splits[0] + ":" + splits[1] + ":" + splits[2] + " for " + f.getName() );
+ return dep;
+ }
+ else
+ {
+ getLog().error( "no idField for " + q );
+ }
+ }
+ else
+ {
+ getLog().info( "no repository match for " + f.getName() );
+ }
+ }
+ catch ( Exception x )
+ {
+ getLog().error( x );
+ }
+ return null;
+ }
+
+ File createExternalProject( ExternalsWrapper wrapper )
+ {
+ Model mavenModel = new Model();
+
+ mavenModel.setGroupId( wrapper.getGroupid() );
+ mavenModel.setArtifactId( wrapper.getArtifact() );
+ mavenModel.setVersion( wrapper.getVersion() );
+ mavenModel.setPackaging( "jar" );
+ mavenModel.setModelVersion( "4.0.0" );
+ mavenModel.setName(
+ "Maven definition for " + wrapper.getFile().getName() + " - external part of NetBeans module." );
+ mavenModel.setDescription(
+ "POM and identification for artifact that was not possible to uniquely identify as a maven dependency." );
+ FileWriter writer = null;
+ File fil = null;
+ try
+ {
+ MavenXpp3Writer xpp = new MavenXpp3Writer();
+ fil = File.createTempFile( "maven", ".pom" );
+ fil.deleteOnExit();
+ writer = new FileWriter( fil );
+ xpp.write( writer, mavenModel );
+ }
+ catch ( IOException ex )
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException io )
+ {
+ io.printStackTrace();
+ }
+ }
+ }
+ return fil;
+
+ }
+
+ private File createClusterProject( Artifact cluster, Collection<ModuleWrapper> mods )
+ {
+ Model mavenModel = new Model();
+
+ mavenModel.setGroupId( cluster.getGroupId() );
+ mavenModel.setArtifactId( cluster.getArtifactId() );
+ mavenModel.setVersion( cluster.getVersion() );
+// mavenModel.setPackaging("nbm-application");
+ mavenModel.setPackaging( "pom" );
+ mavenModel.setModelVersion( "4.0.0" );
+ List<Dependency> deps = new ArrayList<Dependency>();
+ for ( ModuleWrapper wr : mods )
+ {
+ Dependency dep = new Dependency();
+ dep.setArtifactId( wr.getArtifact() );
+ dep.setGroupId( wr.getGroup() );
+ dep.setVersion( wr.getVersion() );
+ if ( wr.getModuleManifest().isNetBeansModule() )
+ {
+ dep.setType( "nbm-file" );
+ }
+ deps.add( dep );
+ }
+ mavenModel.setDependencies( deps );
+//
+//
+// Build build = new Build();
+// Plugin plg = new Plugin();
+// plg.setGroupId("org.codehaus.mojo");
+// plg.setArtifactId("nbm-maven-plugin");
+// plg.setVersion("2.7-SNAPSHOT");
+// plg.setExtensions(true);
+// build.addPlugin(plg);
+// mavenModel.setBuild(build);
+
+ FileWriter writer = null;
+ File fil = null;
+ try
+ {
+ MavenXpp3Writer xpp = new MavenXpp3Writer();
+ fil = File.createTempFile( "maven", ".pom" );
+ fil.deleteOnExit();
+ writer = new FileWriter( fil );
+ xpp.write( writer, mavenModel );
+ }
+ catch ( IOException ex )
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ IOUtil.close( writer );
+ }
+ return fil;
+ }
+
+ Artifact createArtifact( String artifact, String version, String group )
+ {
+ return artifactFactory.createBuildArtifact( group, artifact, version, "jar" );
+ }
+
+ private Artifact createClusterArtifact( String artifact, String version )
+ {
+ return artifactFactory.createBuildArtifact( groupIdPrefix + GROUP_CLUSTER, artifact, version, "pom" );
+ }
+
+ private static Pattern PATTERN_CLUSTER = Pattern.compile( "([a-zA-Z]+)[0-9\\.]*" );
+ static String stripClusterName( String key )
+ {
+ Matcher m = PATTERN_CLUSTER.matcher( key );
+ if ( m.matches() )
+ {
+ return m.group( 1 );
+ }
+ return key;
+ }
+
+ private static class ExternalsWrapper
+ {
+
+ private File file;
+
+ private String artifact;
+
+ private String groupid;
+
+ public String getArtifact()
+ {
+ return artifact;
+ }
+
+ public void setArtifact( String artifact )
+ {
+ this.artifact = artifact;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ public String getGroupid()
+ {
+ return groupid;
+ }
+
+ public void setGroupid( String groupid )
+ {
+ this.groupid = groupid;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+ private String version;
+
+ }
+
+ private static class ModuleWrapper
+ {
+
+ ExamineManifest man;
+
+ private String artifact;
+
+ private String version;
+
+ private String group;
+
+ private File file;
+
+ private String cluster;
+
+ String module;
+
+ List<Dependency> deps;
+
+ public ModuleWrapper( String module )
+ {
+ this.module = module;
+ }
+
+ public ModuleWrapper( String art, String ver, String grp, ExamineManifest manifest, File fil )
+ {
+ man = manifest;
+ artifact = art;
+ version = ver;
+ group = grp;
+ file = fil;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getModule().hashCode();
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ return obj instanceof ModuleWrapper && getModule().equals( ( (ModuleWrapper) obj ).getModule() );
+ }
+
+ public String getModule()
+ {
+ return module != null ? module : getModuleManifest().getModule();
+ }
+
+ public ExamineManifest getModuleManifest()
+ {
+ return man;
+ }
+
+ private String getArtifact()
+ {
+ return artifact;
+ }
+
+ private String getVersion()
+ {
+ return version;
+ }
+
+ private String getGroup()
+ {
+ return group;
+ }
+
+ private File getFile()
+ {
+ return file;
+ }
+
+ void setCluster( String clust )
+ {
+ cluster = clust;
+ }
+
+ String getCluster()
+ {
+ return cluster;
+ }
+ }
+
+ private static class NullOutputStream
+ extends OutputStream
+ {
+
+ @Override
+ public void write( int b )
+ throws IOException
+ {
+ }
+ }
+
+ /**
+ * Encodes a 128 bit or 160-bit byte array into a String.
+ *
+ * @param binaryData Array containing the digest
+ * @return Encoded hex string, or null if encoding failed
+ */
+ static String encode( byte[] binaryData )
+ {
+ int bitLength = binaryData.length * 8;
+ if ( bitLength != 128 && bitLength != 160 )
+ {
+ throw new IllegalArgumentException(
+ "Unrecognised length for binary data: " + bitLength + " bits" );
+ }
+ return String.format( "%0" + bitLength / 4 + "x", new BigInteger( 1, binaryData ) );
+ }
+}
diff --git a/nb-repository-plugin/src/site/apt/index.apt b/nb-repository-plugin/src/site/apt/index.apt
new file mode 100644
index 0000000..99701c1
--- /dev/null
+++ b/nb-repository-plugin/src/site/apt/index.apt
@@ -0,0 +1,19 @@
+ ------
+ Maven 2 NB Repository Plugin
+ ------
+ Milos Kleint
+ <mkleint@codehaus.org>
+ ------
+ Oct 19 2012
+
+NetBeans Repository plugin
+
+ The plugin is capable of populating the local or remote maven repository with module jars and NBM files from a given NetBeans installation. Useful for
+module development, modules with public APIs are separated from those without a public API.
+See the {{{./populate-mojo.html}<<<populate>>>}} goal and the {{{./repository.html}HOWTO document}} for details.
+
+ To get access to a repository with NetBeans.org module artifacts and metadata, add {{{http://bits.netbeans.org/maven2/}http://bits.netbeans.org/maven2/}} repository to your project POM
+or the repository manager you are using. The repository hosts binaries of NetBeans 6.5 and later.
+
+ Also see: {{{http://wiki.netbeans.org/NetBeansDeveloperFAQ#Mavenized_Builds}Maven NBM development FAQs}}
+
diff --git a/nb-repository-plugin/src/site/apt/repository.apt b/nb-repository-plugin/src/site/apt/repository.apt
new file mode 100644
index 0000000..f7c0bd4
--- /dev/null
+++ b/nb-repository-plugin/src/site/apt/repository.apt
@@ -0,0 +1,41 @@
+ ------
+ Maven 2 NB Repository Plugin
+ ------
+ Milos Kleint
+ <mkleint@codehaus.org>
+ ------
+ Oct 19, 2012
+
+HOWTO: Upload NetBeans release binaries to a Maven repository
+
+
+ There is a goal that converts the NetBeans module information into Maven metadata
+and is capable of uploading the module jar file, javadoc, sources and nbm files to local
+and remote repositories. See {{{./populate-mojo.html}<<<populate>>> goal}} description.
+
+ For a binary-only upload (jar files and nbm files only), it's possible to download the bits from official sites. See below for URLs.
+For the complete upload, you will need to checkout the sources of the IDE/Platform you
+want to upload. See this FAQ entry on {{{http://wiki.netbeans.org/DevFaqAccessSourcesUsingMercurial}HowTo checkout sources from Hg}}
+
+ To have external dependencies correctly identified by their real GAV, you will need to download the index from central (or other) repository.
+See {{{./download-mojo.html}<<<download>>> goal}}
+
+ The goal has multiple input parameters that link the goal to binaries prepared beforehand.
+
+ * <<netbeansInstallDirectory>> designates the base directory where resides the NetBeans installation
+that shall be uploaded. It can be either {{{http://www.netbeans.org/downloads/index.html}downloaded as zip}} or built from sources.
+Run <<<ant>>> in your local hg clone to build the distribution at <<<nbbuild/netbeans>>> sundirectory.
+
+ * <<netbeansNbmDirectory>> designates the base directory where the nbm files are located.
+Run <<<ant build-nbms>>> in your local <<<hg clone>>> to build the nbms at <<<nbbuild/nbms>>> directory or download it from the
+{{{http://updates.netbeans.org/netbeans}http://updates.netbeans.org/netbeans}} space eg.
+final <<6.5>> version at {{{http://updates.netbeans.org/netbeans/6.5/final/uc/}http://updates.netbeans.org/netbeans/<<6.5>>/final/uc/}}.
+Use a tool like <<<wget>>> to download the complete directory tree to a directory designated by the <<netbeansNbmDirectory>> parameter.
+
+ * <<netbeansSourcesDirectory>> designates the base directory containing zip files with module jar sources.
+Run <<<ant build-source-zips>>> in your local hg clone to build the nbms at <<<nbbuild/build/source-zips>>> directory.
+
+ * <<netbeansJavadocDirectory>> designates the base directory containing zip files with javadoc zips for modules with public apis.
+Run <<<ant build-javadoc>>> in your local hg clone to build the nbms at <<<nbbuild/build/javadoc>>> directory.
+
+
diff --git a/nb-repository-plugin/src/site/site.xml b/nb-repository-plugin/src/site/site.xml
new file mode 100644
index 0000000..c632a25
--- /dev/null
+++ b/nb-repository-plugin/src/site/site.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+-->
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+ <body>
+ <menu name="Overview">
+ <item name="Usage" href="index.html"/>
+ <item name="Plugin Goals" href="plugin-info.html"/>
+ <!-- <item name="Javadoc" href="apidocs/index.html"/> -->
+ <!--item name="FAQ" href="faq.html"/-->
+ </menu>
+ <!--<menu name="Upgrade">
+ <item name="2.4 -> 2.5 upgrade" href="2425upgrade.html"/>
+ <item name="2.6 -> 3.0 upgrade" href="2630upgrade.html"/>
+ </menu>-->
+ <menu name="HOWTOs ">
+ <item name="Populate repository" href="repository.html"/>
+ </menu>
+ </body>
+</project>
+
diff --git a/nb-repository-plugin/src/test/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojoTest.java b/nb-repository-plugin/src/test/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojoTest.java
new file mode 100644
index 0000000..c22a603
--- /dev/null
+++ b/nb-repository-plugin/src/test/java/org/codehaus/mojo/nbm/repository/PopulateRepositoryMojoTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2010 mkleint.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+
+package org.codehaus.mojo.nbm.repository;
+
+import java.io.File;
+import junit.framework.TestCase;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+public class PopulateRepositoryMojoTest extends TestCase /** AbstractMojoTestCase the only way out of dependency hell.**/{
+
+ public void testStripClusterName()
+ {
+ assertEquals( "platform", PopulateRepositoryMojo.stripClusterName( "platform9" ) );
+ assertEquals( "platform", PopulateRepositoryMojo.stripClusterName( "platform11" ) );
+ assertEquals( "nb", PopulateRepositoryMojo.stripClusterName( "nb6.9" ) );
+ assertEquals( "extra", PopulateRepositoryMojo.stripClusterName( "extra" ) );
+ }
+
+ public void testInstall() throws Exception
+ {
+//TODO how is this done on maven3?
+// PopulateRepositoryMojo mojo = ( PopulateRepositoryMojo ) lookupMojo( "populate", new File( getBasedir(), "src/test/resources/PopulateMojoTest.xml" ) );
+// File repo = new File( System.getProperty( "java.io.tmpdir" ), "PopulateRepositoryMojoTest" );
+// FileUtils.deleteDirectory( repo );
+// mojo.localRepository = new DefaultArtifactRepository( "test", repo.toURI().toString(), new DefaultRepositoryLayout() );
+// Artifact art1 = mojo.createArtifact( "testarg", "1.0", "testgrp" );
+// File f = File.createTempFile( "PopulateRepositoryMojoTest", ".nbm" );
+// f.deleteOnExit();
+// Artifact art2 = mojo.createAttachedArtifact( art1, f, "nbm-file", null );
+// assertEquals( "nbm", art2.getArtifactHandler().getExtension() );
+// //TODO does not work because of missing session
+//// mojo.install( f, art2 );
+//// assertTrue( new File( repo, "testgrp/testarg/1.0/testarg-1.0.nbm" ).isFile() );
+//// assertFalse( new File( repo, "testgrp/testarg/1.0/testarg-1.0.jar" ).isFile() );
+ }
+
+ public void testEncode() throws Exception
+ {
+ assertEquals( "057558504e1d03e57ce6fd80ad983b3c2e803b40", PopulateRepositoryMojo.encode( new byte[] {
+ (byte) 0x05, (byte) 0x75, (byte) 0x58, (byte) 0x50, (byte) 0x4e, (byte) 0x1d, (byte) 0x03, (byte) 0xe5, (byte) 0x7c, (byte) 0xe6,
+ (byte) 0xfd, (byte) 0x80, (byte) 0xad, (byte) 0x98, (byte) 0x3b, (byte) 0x3c, (byte) 0x2e, (byte) 0x80, (byte) 0x3b, (byte) 0x40,
+ } ) );
+ assertEquals( "ca70822c47a67fc3a11670270567c2d01566dae1", PopulateRepositoryMojo.encode( new byte[] {
+ (byte) 0xca, (byte) 0x70, (byte) 0x82, (byte) 0x2c, (byte) 0x47, (byte) 0xa6, (byte) 0x7f, (byte) 0xc3, (byte) 0xa1, (byte) 0x16,
+ (byte) 0x70, (byte) 0x27, (byte) 0x05, (byte) 0x67, (byte) 0xc2, (byte) 0xd0, (byte) 0x15, (byte) 0x66, (byte) 0xda, (byte) 0xe1,
+ } ) );
+ }
+
+}
diff --git a/nb-repository-plugin/src/test/resources/PopulateMojoTest.xml b/nb-repository-plugin/src/test/resources/PopulateMojoTest.xml
new file mode 100644
index 0000000..1820ea3
--- /dev/null
+++ b/nb-repository-plugin/src/test/resources/PopulateMojoTest.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nb-repository-plugin</artifactId>
+ <configuration/>
+ </plugin>
+ </plugins>
+ </build>
+</project>