Merge pull request #49 from ebarboni/preparation
Merge of all related Netbeans plugin and archetype keeping history
diff --git a/.gitignore b/.gitignore
index a6f89c2..6e27347 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-/target/
\ No newline at end of file
+/target/
+/nbactions.xml
diff --git a/archetype/nbm-archetype/pom.xml b/archetype/nbm-archetype/pom.xml
new file mode 100644
index 0000000..06478dd
--- /dev/null
+++ b/archetype/nbm-archetype/pom.xml
@@ -0,0 +1,37 @@
+<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>38</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.codehaus.mojo.archetypes</groupId>
+ <artifactId>nbm-archetype</artifactId>
+ <version>1.16-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+ <name>NetBeans Module Archetype</name>
+ <description>Archetype for development of NetBeans modules in Maven.</description>
+ <scm>
+ <connection>scm:git:https://github.com/mojohaus/nbm-archetype.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mojohaus/nbm-archetype.git</developerConnection>
+ <url>https://github.com/mojohaus/nbm-archetype/tree/${project.scm.tag}</url>
+ <tag>master</tag>
+ </scm>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0</version>
+ </extension>
+ </extensions>
+ </build>
+</project>
diff --git a/archetype/nbm-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/nbm-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..ed04059
--- /dev/null
+++ b/archetype/nbm-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ partial="false" name="NetBeans module project archetype">
+ <fileSets>
+ <fileSet filtered="true" packaged="true">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true">
+ <directory>src/main/nbm</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true">
+ <directory>src/main/java</directory>
+ </fileSet>
+ </fileSets>
+ <requiredProperties>
+ <requiredProperty key="netbeansVersion">
+ <defaultValue>RELEASE81</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+</archetype-descriptor>
diff --git a/archetype/nbm-archetype/src/main/resources/archetype-resources/pom.xml b/archetype/nbm-archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..0eee5e6
--- /dev/null
+++ b/archetype/nbm-archetype/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,71 @@
+<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>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>nbm</packaging>
+
+ <name>${artifactId}</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <repositories>
+ <!--
+ Repository hosting NetBeans modules, especially APIs.
+ Versions are based on IDE releases, e.g.: RELEASE691
+ To create your own repository, use: nbm:populate-repository
+ -->
+ <repository>
+ <id>netbeans</id>
+ <name>NetBeans</name>
+ <url>http://bits.netbeans.org/nexus/content/groups/netbeans/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-netbeans-api-annotations-common</artifactId>
+ <version>${netbeansVersion}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ <version>4.1</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ <plugin>
+ <!-- NetBeans 6.9+ requires JDK 6, starting NetBeans 7.4 source 1.7 is required -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <!-- to have the jar plugin pickup the nbm generated manifest -->
+ <useDefaultManifestFile>true</useDefaultManifestFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/archetype/nbm-archetype/src/main/resources/archetype-resources/src/main/nbm/manifest.mf b/archetype/nbm-archetype/src/main/resources/archetype-resources/src/main/nbm/manifest.mf
new file mode 100644
index 0000000..02dc07c
--- /dev/null
+++ b/archetype/nbm-archetype/src/main/resources/archetype-resources/src/main/nbm/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+#set( $slashed = $package.replaceAll("([.])", "/") )
+OpenIDE-Module-Localizing-Bundle: $slashed/Bundle.properties
diff --git a/src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties b/archetype/nbm-archetype/src/main/resources/archetype-resources/src/main/resources/Bundle.properties
similarity index 100%
copy from src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties
copy to archetype/nbm-archetype/src/main/resources/archetype-resources/src/main/resources/Bundle.properties
diff --git a/archetype/nbm-suite-root/pom.xml b/archetype/nbm-suite-root/pom.xml
new file mode 100644
index 0000000..ad3b743
--- /dev/null
+++ b/archetype/nbm-suite-root/pom.xml
@@ -0,0 +1,18 @@
+<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.archetypes</groupId>
+ <artifactId>mojo-archetypes</artifactId>
+ <version>6</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>nbm-suite-root</artifactId>
+ <version>1.11-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+ <name>NetBeans Module Suite Archetype</name>
+ <description>Root project archetype for creating multi module projects developing NetBeans IDE modules. Approximately similar in functionality to module suites in NetBeans Ant projects.</description>
+ <scm>
+ <connection>scm:svn:http://svn.codehaus.org/mojo/trunk/mojo/mojo-archetypes/nbm-suite-root</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/mojo/trunk/mojo/mojo-archetypes/nbm-suite-root</developerConnection>
+ <url>http://fisheye.codehaus.org/browse/mojo/trunk/mojo/mojo-archetypes/nbm-suite-root</url>
+ </scm>
+</project>
diff --git a/archetype/nbm-suite-root/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/nbm-suite-root/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..f5be1ae
--- /dev/null
+++ b/archetype/nbm-suite-root/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ partial="false" name="NetBeans module suite archetype">
+ <fileSets>
+ <fileSet filtered="true" packaged="false">
+ <directory></directory>
+ <includes>
+ <include>nbactions.xml</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <requiredProperties>
+ <requiredProperty key="netbeansVersion">
+ <defaultValue>RELEASE74</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+</archetype-descriptor>
diff --git a/archetype/nbm-suite-root/src/main/resources/archetype-resources/nbactions.xml b/archetype/nbm-suite-root/src/main/resources/archetype-resources/nbactions.xml
new file mode 100644
index 0000000..498859b
--- /dev/null
+++ b/archetype/nbm-suite-root/src/main/resources/archetype-resources/nbactions.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set( $D = '$' )
+<actions>
+ <action>
+ <actionName>run</actionName>
+ <goals>
+ <goal>package</goal>
+ <goal>nbm:cluster</goal>
+ <goal>nbm:run-ide</goal>
+ </goals>
+ </action>
+ <action>
+ <actionName>debug</actionName>
+ <goals>
+ <goal>package</goal>
+ <goal>nbm:cluster</goal>
+ <goal>nbm:run-ide</goal>
+ </goals>
+ <properties>
+ <jpda.listen>true</jpda.listen>
+ <netbeans.run.params.debug>-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=n,server=n,address=${D}{jpda.address}</netbeans.run.params.debug>
+ </properties>
+ </action>
+</actions>
diff --git a/archetype/nbm-suite-root/src/main/resources/archetype-resources/pom.xml b/archetype/nbm-suite-root/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..8589192
--- /dev/null
+++ b/archetype/nbm-suite-root/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set( $D = '$' )
+<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>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+ <packaging>pom</packaging>
+
+ <name>${artifactId}</name>
+
+ <repositories>
+ <!--
+ Repository hosting NetBeans modules, especially APIs.
+ Versions are based on IDE releases, e.g.: RELEASE691
+ To create your own repository, use: nbm:populate-repository
+ -->
+ <repository>
+ <id>netbeans</id>
+ <name>NetBeans</name>
+ <url>http://bits.netbeans.org/nexus/content/groups/netbeans/</url>
+ </repository>
+ </repositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ <version>3.13</version>
+ <configuration>
+ <cluster>${artifactId.toLowerCase().replaceAll("[^a-z0-9_]+", "_")}</cluster>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- NetBeans 6.9+ requires JDK 6, starting NetBeans 7.4 source 1.7 is required-->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>updatesite</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>site</id>
+ <phase>package</phase>
+ <goals>
+ <goal>autoupdate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <properties>
+ <netbeans.version>${netbeansVersion}</netbeans.version>
+ </properties>
+</project>
diff --git a/archetype/netbeans-platform-app-archetype/pom.xml b/archetype/netbeans-platform-app-archetype/pom.xml
new file mode 100644
index 0000000..972ca5c
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/pom.xml
@@ -0,0 +1,37 @@
+<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>38</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.codehaus.mojo.archetypes</groupId>
+ <artifactId>netbeans-platform-app-archetype</artifactId>
+ <version>1.21-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+ <name>NetBeans Platform Application Archetype</name>
+ <description>Archetype for sample application based on NetBeans Platform. Creates parent POM with branding and empty NBM project.</description>
+ <scm>
+ <connection>scm:git:https://github.com/mojohaus/netbeans-platform-app-archetype.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mojohaus/netbeans-platform-app-archetype.git</developerConnection>
+ <url>https://github.com/mojohaus/netbeans-platform-app-archetype/tree/${project.scm.tag}</url>
+ <tag>master</tag>
+ </scm>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0</version>
+ </extension>
+ </extensions>
+ </build>
+</project>
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype/netbeans-platform-app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..8140bd7
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+ partial="false" name="NetBeans Platform Application Archetype">
+ <fileSets>
+ <fileSet filtered="true">
+ <directory>branding</directory>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true">
+ <directory>branding/src/main/nbm-branding</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true">
+ <directory>branding/src/main/resources</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true">
+ <directory>branding/src/main/nbm</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true">
+ <directory>application</directory>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" packaged="true">
+ <directory>application/src/test/java</directory>
+ <includes>
+ <include>**/*.*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <requiredProperties>
+ <requiredProperty key="netbeansVersion">
+ <defaultValue>RELEASE81</defaultValue>
+ </requiredProperty>
+ </requiredProperties>
+</archetype-descriptor>
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/pom.xml b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/pom.xml
new file mode 100644
index 0000000..21ee414
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set( $D = '$' )
+<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>${groupId}</groupId>
+ <artifactId>${artifactId}-parent</artifactId>
+ <version>${version}</version>
+ </parent>
+
+ <artifactId>${artifactId}-app</artifactId>
+ <packaging>nbm-application</packaging>
+
+ <name>${artifactId}-app</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <all.clusters>${D}{project.build.directory}/${D}{brandingToken}</all.clusters>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.netbeans.cluster</groupId>
+ <artifactId>platform</artifactId>
+ <version>${D}{netbeans.version}</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>${D}{project.groupId}</groupId>
+ <artifactId>${artifactId}-branding</artifactId>
+ <version>${D}{project.version}</version>
+ </dependency>
+ <!-- NbModuleSuite functional in RELEASE70 or later: -->
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-netbeans-modules-nbjunit</artifactId>
+ <version>${D}{netbeans.version}</version>
+ <scope>test</scope> <!-- beyond platform cluster, this often needs to be dropped down to compile/runtime, some other modules in IDE clusters depend on it -->
+ </dependency>
+#if (${netbeansVersion} == "RELEASE71")
+ <!-- Cf.: https://netbeans.org/bugzilla/show_bug.cgi?id=207956 -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+#end
+ <!-- To use Jelly Tools in your functional tests, add or replace with:
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-netbeans-modules-jellytools-platform</artifactId>
+ <version>${D}{netbeans.version}</version>
+ <scope>test</scope>
+ </dependency>
+ -->
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ </plugin>
+ <!-- Permits NbModuleSuite to be run in integration-test phase: -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12.2</version>
+ <configuration>
+#if (${netbeansVersion} == "RELEASE70" || ${netbeansVersion} == "RELEASE701")
+ <!-- For RELEASE70 or RELEASE701 only (adding in any other clusters imported by your app); RELEASE71+ uses all.clusters directly, plus branding.token: -->
+ <systemPropertyVariables>
+ <cluster.path.final>${D}{all.clusters}/${D}{brandingToken}:${D}{all.clusters}/platform</cluster.path.final>
+ </systemPropertyVariables>
+#else
+ <systemPropertyVariables>
+ <all.clusters>${D}{all.clusters}</all.clusters>
+ <branding.token>${D}{brandingToken}</branding.token>
+ </systemPropertyVariables>
+#end
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>deployment</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>extra</id>
+ <goals>
+ <goal>autoupdate</goal>
+ <goal>webstart-app</goal>
+ <goal>build-installers</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/src/test/java/ApplicationTest.java b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/src/test/java/ApplicationTest.java
new file mode 100644
index 0000000..1b73255
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/application/src/test/java/ApplicationTest.java
@@ -0,0 +1,32 @@
+package ${package};
+
+import java.util.logging.Level;
+import junit.framework.Test;
+import org.netbeans.junit.NbModuleSuite;
+import org.netbeans.junit.NbTestCase;
+
+public class ApplicationTest extends NbTestCase {
+
+ public static Test suite() {
+ return NbModuleSuite.createConfiguration(ApplicationTest.class).
+ gui(false).
+ failOnMessage(Level.WARNING). // works at least in RELEASE71
+ failOnException(Level.INFO).
+ enableClasspathModules(false).
+ clusters(".*").
+ suite(); // RELEASE71+, else use NbModuleSuite.create(NbModuleSuite.createConfiguration(...))
+ }
+
+ public ApplicationTest(String n) {
+ super(n);
+ }
+
+ public void testApplication() {
+ // pass if there are merely no warnings/exceptions
+ /* Example of using Jelly Tools (additional test dependencies required) with gui(true):
+ new ActionNoBlock("Help|About", null).performMenu();
+ new NbDialogOperator("About").closeByButton();
+ */
+ }
+
+}
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/pom.xml b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/pom.xml
new file mode 100644
index 0000000..36ba370
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set( $D = '$' )
+<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>${groupId}</groupId>
+ <artifactId>${artifactId}-parent</artifactId>
+ <version>${version}</version>
+ </parent>
+
+ <artifactId>${artifactId}-branding</artifactId>
+ <packaging>nbm</packaging>
+
+ <name>${artifactId}-branding</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-netbeans-api-annotations-common</artifactId>
+ <version>${D}{netbeans.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <!-- to have the jar plugin pickup the nbm generated manifest -->
+ <useDefaultManifestFile>true</useDefaultManifestFile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
new file mode 100644
index 0000000..0c991e6
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
@@ -0,0 +1,2 @@
+currentVersion=${artifactId} {0}
+LBL_splash_window_title=Starting ${artifactId}
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
new file mode 100644
index 0000000..b68602c
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
@@ -0,0 +1,2 @@
+CTL_MainWindow_Title=${artifactId} {0}
+CTL_MainWindow_Title_No_Project=${artifactId} {0}
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties
new file mode 100644
index 0000000..157512a
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties
@@ -0,0 +1 @@
+LBL_ProductInformation=${artifactId}
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm/manifest.mf b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm/manifest.mf
new file mode 100644
index 0000000..e5d042b
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/nbm/manifest.mf
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+#set( $slashed = $package.replaceAll("([.])", "/") )
+OpenIDE-Module-Localizing-Bundle: $slashed/branding/Bundle.properties
+AutoUpdate-Essential-Module: true
diff --git a/src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/resources/branding/Bundle.properties
similarity index 100%
copy from src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties
copy to archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/branding/src/main/resources/branding/Bundle.properties
diff --git a/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/pom.xml b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..3d0e03a
--- /dev/null
+++ b/archetype/netbeans-platform-app-archetype/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#set( $D = '$' )
+<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>${groupId}</groupId>
+ <artifactId>${artifactId}-parent</artifactId>
+ <version>${version}</version>
+ <packaging>pom</packaging>
+
+ <name>${artifactId}-parent</name>
+
+ <repositories>
+ <!--
+ Repository hosting NetBeans modules, especially APIs.
+ Versions are based on IDE releases, e.g.: RELEASE691
+ To create your own repository, use: nbm:populate-repository
+ -->
+ <repository>
+ <id>netbeans</id>
+ <name>NetBeans</name>
+ <url>http://bits.netbeans.org/nexus/content/groups/netbeans/</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>nbm-maven-plugin</artifactId>
+ <version>4.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <brandingToken>${D}{brandingToken}</brandingToken>
+ <cluster>${D}{brandingToken}</cluster>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!-- NetBeans 6.9+ requires JDK 6, starting NetBeans 7.4 source 1.7 is required -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <modules>
+ <module>branding</module>
+ <module>application</module>
+ </modules>
+
+ <properties>
+ <netbeans.version>${netbeansVersion}</netbeans.version>
+## XXX better to pass toLowerCase(java.util.Locale.ENGLISH), to fix Turkish problem, but Velocity rejects that syntax
+## XXX some other patterns are also rejected by NbBundle; it wants /[a-z][a-z0-9]*(_[a-z][a-z0-9]*)*/
+ <brandingToken>${artifactId.toLowerCase().replaceAll("[^a-z0-9]+", "")}</brandingToken>
+ </properties>
+</project>
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/src/it/settings.xml b/nb-repository-plugin/src/it/settings.xml
similarity index 100%
copy from src/it/settings.xml
copy to nb-repository-plugin/src/it/settings.xml
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>
diff --git a/nbm-maven-harness/pom.xml b/nbm-maven-harness/pom.xml
new file mode 100644
index 0000000..ef0dada
--- /dev/null
+++ b/nbm-maven-harness/pom.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0"?>
+<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>mojo-parent</artifactId>
+ <version>37</version>
+ </parent>
+ <artifactId>nbm-maven-harness</artifactId>
+ <version>8.3-SNAPSHOT</version>
+ <name>NBM Harness for Maven</name>
+ <licenses>
+ <license>
+ <name>CDDL + GPL 2 with Classpath Exception</name>
+ <url>http://netbeans.org/cddl-gplv2.html</url>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:https://github.com/mojohaus/nbm-maven-harness.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mojohaus/nbm-maven-harness.git</developerConnection>
+ <url>https://github.com/mojohaus/nbm-maven-harness/tree/${project.scm.tag}</url>
+ <tag>master</tag>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <id>unpack-harness</id>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.netbeans.modules:org-netbeans-modules-apisupport-harness:${netbeans.version}:nbm</artifact>
+ <transitive>false</transitive>
+ <remoteRepositories>${netbeans.repo}</remoteRepositories>
+ <destination>${project.build.directory}/harness.nbm</destination>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>generate-resources</phase>
+ <id>unpack-installer</id>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.netbeans.modules:org-netbeans-libs-nbi-ant:${netbeans.version}:nbm</artifact>
+ <transitive>false</transitive>
+ <remoteRepositories>${netbeans.repo}</remoteRepositories>
+ <destination>${project.build.directory}/nbi-ant.nbm</destination>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>generate-resources</phase>
+ <id>unpack-installer-engine</id>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.netbeans.modules:org-netbeans-libs-nbi-engine:${netbeans.version}:nbm</artifact>
+ <transitive>false</transitive>
+ <remoteRepositories>${netbeans.repo}</remoteRepositories>
+ <destination>${project.build.directory}/nbi-engine.nbm</destination>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.6</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <unzip src="${project.build.directory}/harness.nbm" dest="${project.build.directory}/classes">
+ <patternset>
+ <include name="netbeans/etc/app.conf" />
+ <include name="netbeans/etc/applicationIcon.icns*" />
+ <include name="netbeans/launchers/app*" />
+ </patternset>
+ <mapper type="glob" from="netbeans/*" to="harness/*" />
+ </unzip>
+ <unzip src="${project.build.directory}/harness.nbm" dest="${project.build.directory}">
+ <patternset>
+ <include name="netbeans/tasks.jar.pack.gz" />
+ <include name="netbeans/jnlp/jnlp-launcher.jar.pack.gz" />
+ </patternset>
+ <flattenmapper />
+ </unzip>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/tasks.jar.pack.gz" />
+ <arg file="${project.build.directory}/tasks.jar" />
+ </exec>
+ <mkdir dir="${project.build.directory}/classes/harness/jnlp" />
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/jnlp-launcher.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/jnlp/jnlp-launcher.jar" />
+ </exec>
+ <unzip src="${project.build.directory}/tasks.jar" dest="${project.build.directory}/classes" />
+ <unzip src="${project.build.directory}/nbi-ant.nbm" dest="${project.build.directory}/classes">
+ <patternset>
+ <include name="netbeans/modules/" />
+ <include name="netbeans/nbi/" />
+ </patternset>
+ <mapper type="glob" from="netbeans/*" to="harness/*" />
+ </unzip>
+ <unzip src="${project.build.directory}/nbi-engine.nbm" dest="${project.build.directory}/classes">
+ <patternset>
+ <include name="netbeans/modules/" />
+ </patternset>
+ <mapper type="glob" from="netbeans/*" to="harness/*" />
+ </unzip>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/classes/harness/modules/org-netbeans-libs-nbi-ant.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/modules/org-netbeans-libs-nbi-ant.jar" />
+ </exec>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/classes/harness/modules/org-netbeans-libs-nbi-engine.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/modules/org-netbeans-libs-nbi-engine.jar" />
+ </exec>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-engine.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-engine.jar" />
+ </exec>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-registries-management.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-registries-management.jar" />
+ </exec>
+ <exec executable="unpack200" failonerror="true">
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-ant-tasks.jar.pack.gz" />
+ <arg file="${project.build.directory}/classes/harness/modules/ext/nbi-ant-tasks.jar" />
+ </exec>
+ <delete>
+ <fileset dir="${project.build.directory}/classes/harness/modules" includes="**/*.pack.gz" />
+ </delete>
+ <!-- patch product.xml - unable to delete temp files after build finishes -->
+ <replace file="${project.build.directory}/classes/harness/nbi/.common/product.xml">
+ <replacetoken expandProperties="false"><![CDATA[<delete dir="${current.temp.dir}>"]]></replacetoken>
+ <replacevalue expandProperties="false"><![CDATA[<delete dir="${current.temp.dir}" deleteonexit="true">]]></replacevalue>
+ </replace>
+ <!-- patch replace exec with ant task in common.xml -->
+ <replaceregexp file="${project.build.directory}/classes/harness/nbi/.common/common.xml" match="exec executable=.{3}ant.executable(.+?)/exec" replace="@EXEC@" flags="s" />
+ <replace file="${project.build.directory}/classes/harness/nbi/.common/common.xml" failOnNoReplacements="true">
+ <replacetoken expandProperties="false">@EXEC@</replacetoken>
+ <replacevalue expandProperties="false"><![CDATA[ant inheritrefs="false"
+ dir="${cvs.dir}/${nbproject.path}">
+ <target name="clean" />
+ <property name="ignore.native" value="true" />
+ <property name="no.dependencies" value="true" />
+ <property name="dont.build.custom.tasks" value="true" />
+ <property name="custom.tasks.cls" value="${custom.tasks.cls}" />
+ </ant]]></replacevalue>
+ </replace>
+ <replaceregexp file="${project.build.directory}/classes/harness/nbi/.common/common.xml" match="exec executable=.{3}ant.executable(.+?)/exec" replace="@EXEC@" flags="s" />
+ <replace file="${project.build.directory}/classes/harness/nbi/.common/common.xml" failOnNoReplacements="true">
+ <replacetoken expandProperties="false">@EXEC@</replacetoken>
+ <replacevalue expandProperties="false"><![CDATA[condition property="nb.jdk.home.value"
+ value="${@java.home@}/.."
+ else="${@java.home@}">
+ <not>
+ <equals arg1="Apple Inc." arg2="${java.vendor}" />
+ </not>
+ </condition>
+ <condition property="custom.parameter.name" value="reference.NBI_Engine.jar">
+ <contains string="${nb.custom.parameter}" substring="reference.NBI_Engine.jar" />
+ </condition>
+ <condition property="custom.parameter.value" value="${core.engine.dist.file}">
+ <contains string="${nb.custom.parameter}" substring="reference.NBI_Engine.jar" />
+ </condition>
+ <condition property="custom.parameter.name" value="javac.classpath">
+ <contains string="${nb.custom.parameter}" substring="javac.classpath" />
+ </condition>
+ <condition property="custom.parameter.value" value="${engine.dist.file}">
+ <contains string="${nb.custom.parameter}" substring="javac.classpath" />
+ </condition>
+ <echoproperties />
+ <ant inheritRefs="false" dir="${cvs.dir}/${nbproject.path}" >
+ <target name="clean" />
+ <target name="compile" />
+ <property name="platforms.JDK_1.5.home" value="${nb.jdk.home.value}" />
+ <property name="ignore.native" value="true" />
+ <property name="no.dependencies" value="true" />
+ <property name="dont.build.custom.tasks" value="true" />
+ <property name="custom.tasks.cls" value="${custom.tasks.cls}" />
+ <property name="${custom.parameter.name}" value="${custom.parameter.value}" />
+ </ant]]></replacevalue>
+ </replace>
+ <replace file="${project.build.directory}/classes/harness/nbi/.common/common.xml" failOnNoReplacements="true" token="@java.home@" value="java.home" />
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- No real effect on the build, but prevents NB IDE from thinking src/main/java should be considered in preference to the JAR: -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <netbeans.repo>netbeans::default::http://bits.netbeans.org/nexus/content/groups/netbeans/</netbeans.repo>
+ <netbeans.version>RELEASE82</netbeans.version>
+ </properties>
+</project>
diff --git a/nbm-maven-harness/src/main/java/Dummy.java b/nbm-maven-harness/src/main/java/Dummy.java
new file mode 100644
index 0000000..6e291bf
--- /dev/null
+++ b/nbm-maven-harness/src/main/java/Dummy.java
@@ -0,0 +1,7 @@
+/**
+ * dummy class to keep central maven repository happy.
+ * @author mkleint
+ */
+public class Dummy {
+
+}
diff --git a/nbm-maven-harness/src/main/java/dummy.txt b/nbm-maven-harness/src/main/java/dummy.txt
new file mode 100644
index 0000000..d4fd10c
--- /dev/null
+++ b/nbm-maven-harness/src/main/java/dummy.txt
@@ -0,0 +1,2 @@
+This jar doesn't have sources or javadoc.
+It contains a multitude of resources from the netbeans IDE, used by the nbm-maven-plugin.
diff --git a/README.md b/nbm-maven-plugin/README.md
similarity index 100%
rename from README.md
rename to nbm-maven-plugin/README.md
diff --git a/pom.xml b/nbm-maven-plugin/pom.xml
similarity index 100%
rename from pom.xml
rename to nbm-maven-plugin/pom.xml
diff --git a/src/it/full/application/pom.xml b/nbm-maven-plugin/src/it/full/application/pom.xml
similarity index 100%
rename from src/it/full/application/pom.xml
rename to nbm-maven-plugin/src/it/full/application/pom.xml
diff --git a/src/it/full/application/src/test/java/nbmmavenpluginit/ittest/ApplicationTest.java b/nbm-maven-plugin/src/it/full/application/src/test/java/nbmmavenpluginit/ittest/ApplicationTest.java
similarity index 100%
rename from src/it/full/application/src/test/java/nbmmavenpluginit/ittest/ApplicationTest.java
rename to nbm-maven-plugin/src/it/full/application/src/test/java/nbmmavenpluginit/ittest/ApplicationTest.java
diff --git a/src/it/full/branding/pom.xml b/nbm-maven-plugin/src/it/full/branding/pom.xml
similarity index 100%
rename from src/it/full/branding/pom.xml
rename to nbm-maven-plugin/src/it/full/branding/pom.xml
diff --git a/src/it/full/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
similarity index 100%
rename from src/it/full/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
rename to nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
diff --git a/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
similarity index 100%
rename from src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
rename to nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
diff --git a/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties b/nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties
similarity index 100%
rename from src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties
rename to nbm-maven-plugin/src/it/full/branding/src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties
diff --git a/src/it/full/branding/src/main/nbm/manifest.mf b/nbm-maven-plugin/src/it/full/branding/src/main/nbm/manifest.mf
similarity index 100%
rename from src/it/full/branding/src/main/nbm/manifest.mf
rename to nbm-maven-plugin/src/it/full/branding/src/main/nbm/manifest.mf
diff --git a/src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties b/nbm-maven-plugin/src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties
similarity index 100%
rename from src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties
rename to nbm-maven-plugin/src/it/full/branding/src/main/resources/nbmmavenpluginit/ittest/branding/Bundle.properties
diff --git a/src/it/full/ittest-sample/pom.xml b/nbm-maven-plugin/src/it/full/ittest-sample/pom.xml
similarity index 100%
rename from src/it/full/ittest-sample/pom.xml
rename to nbm-maven-plugin/src/it/full/ittest-sample/pom.xml
diff --git a/src/it/full/ittest-sample/src/main/nbm/manifest.mf b/nbm-maven-plugin/src/it/full/ittest-sample/src/main/nbm/manifest.mf
similarity index 100%
rename from src/it/full/ittest-sample/src/main/nbm/manifest.mf
rename to nbm-maven-plugin/src/it/full/ittest-sample/src/main/nbm/manifest.mf
diff --git a/src/it/full/ittest-sample/src/main/resources/nbmmavenpluginit/ittest/Bundle.properties b/nbm-maven-plugin/src/it/full/ittest-sample/src/main/resources/nbmmavenpluginit/ittest/Bundle.properties
similarity index 100%
rename from src/it/full/ittest-sample/src/main/resources/nbmmavenpluginit/ittest/Bundle.properties
rename to nbm-maven-plugin/src/it/full/ittest-sample/src/main/resources/nbmmavenpluginit/ittest/Bundle.properties
diff --git a/src/it/full/pom.xml b/nbm-maven-plugin/src/it/full/pom.xml
similarity index 100%
rename from src/it/full/pom.xml
rename to nbm-maven-plugin/src/it/full/pom.xml
diff --git a/src/it/pom.xml b/nbm-maven-plugin/src/it/pom.xml
similarity index 100%
rename from src/it/pom.xml
rename to nbm-maven-plugin/src/it/pom.xml
diff --git a/src/it/settings.xml b/nbm-maven-plugin/src/it/settings.xml
similarity index 100%
rename from src/it/settings.xml
rename to nbm-maven-plugin/src/it/settings.xml
diff --git a/src/it/single/pom.xml b/nbm-maven-plugin/src/it/single/pom.xml
similarity index 100%
rename from src/it/single/pom.xml
rename to nbm-maven-plugin/src/it/single/pom.xml
diff --git a/src/main/java/org/codehaus/mojo/nbm/AbstractNbmMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/AbstractNbmMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/AbstractNbmMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/AbstractNbmMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/AdaptNbVersion.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/AdaptNbVersion.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/AdaptNbVersion.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/AdaptNbVersion.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/BrandingMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/BrandingMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/BrandingMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/BrandingMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/BuildInstallersMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/BuildInstallersMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/BuildInstallersMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/BuildInstallersMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CollectLibrariesNodeVisitor.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CollectLibrariesNodeVisitor.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CollectLibrariesNodeVisitor.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CollectLibrariesNodeVisitor.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CollectModuleLibrariesNodeVisitor.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CollectModuleLibrariesNodeVisitor.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CollectModuleLibrariesNodeVisitor.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CollectModuleLibrariesNodeVisitor.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateClusterAppMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateClusterAppMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateClusterAppMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateClusterAppMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateClusterMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateClusterMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateClusterMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateClusterMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateNbmMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateNbmMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateNbmMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateNbmMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructure.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructure.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructure.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructure.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateStandaloneMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateStandaloneMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateStandaloneMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateStandaloneMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateUpdateSiteMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateUpdateSiteMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateUpdateSiteMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateUpdateSiteMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/CreateWebstartAppMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateWebstartAppMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/CreateWebstartAppMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/CreateWebstartAppMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/RunNetBeansMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/RunNetBeansMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/RunNetBeansMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/RunNetBeansMojo.java
diff --git a/src/main/java/org/codehaus/mojo/nbm/RunPlatformAppMojo.java b/nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/RunPlatformAppMojo.java
similarity index 100%
rename from src/main/java/org/codehaus/mojo/nbm/RunPlatformAppMojo.java
rename to nbm-maven-plugin/src/main/java/org/codehaus/mojo/nbm/RunPlatformAppMojo.java
diff --git a/src/main/mdo/descriptor.mdo b/nbm-maven-plugin/src/main/mdo/descriptor.mdo
similarity index 100%
rename from src/main/mdo/descriptor.mdo
rename to nbm-maven-plugin/src/main/mdo/descriptor.mdo
diff --git a/src/main/resources/META-INF/plexus/components.xml b/nbm-maven-plugin/src/main/resources/META-INF/plexus/components.xml
similarity index 100%
rename from src/main/resources/META-INF/plexus/components.xml
rename to nbm-maven-plugin/src/main/resources/META-INF/plexus/components.xml
diff --git a/src/main/resources/branding.jnlp b/nbm-maven-plugin/src/main/resources/branding.jnlp
similarity index 100%
rename from src/main/resources/branding.jnlp
rename to nbm-maven-plugin/src/main/resources/branding.jnlp
diff --git a/src/main/resources/master.jnlp b/nbm-maven-plugin/src/main/resources/master.jnlp
similarity index 100%
rename from src/main/resources/master.jnlp
rename to nbm-maven-plugin/src/main/resources/master.jnlp
diff --git a/src/site/apt/buildinstexample.apt b/nbm-maven-plugin/src/site/apt/buildinstexample.apt
similarity index 100%
rename from src/site/apt/buildinstexample.apt
rename to nbm-maven-plugin/src/site/apt/buildinstexample.apt
diff --git a/src/site/apt/descriptor.apt b/nbm-maven-plugin/src/site/apt/descriptor.apt
similarity index 100%
rename from src/site/apt/descriptor.apt
rename to nbm-maven-plugin/src/site/apt/descriptor.apt
diff --git a/src/site/apt/index.apt.vm b/nbm-maven-plugin/src/site/apt/index.apt.vm
similarity index 100%
rename from src/site/apt/index.apt.vm
rename to nbm-maven-plugin/src/site/apt/index.apt.vm
diff --git a/src/site/apt/upgrade.apt b/nbm-maven-plugin/src/site/apt/upgrade.apt
similarity index 100%
rename from src/site/apt/upgrade.apt
rename to nbm-maven-plugin/src/site/apt/upgrade.apt
diff --git a/src/site/resources/masterjnlp.txt b/nbm-maven-plugin/src/site/resources/masterjnlp.txt
similarity index 100%
rename from src/site/resources/masterjnlp.txt
rename to nbm-maven-plugin/src/site/resources/masterjnlp.txt
diff --git a/src/site/site.xml b/nbm-maven-plugin/src/site/site.xml
similarity index 100%
rename from src/site/site.xml
rename to nbm-maven-plugin/src/site/site.xml
diff --git a/src/test/java/org/codehaus/mojo/nbm/AbstractNbmMojoTest.java b/nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/AbstractNbmMojoTest.java
similarity index 100%
rename from src/test/java/org/codehaus/mojo/nbm/AbstractNbmMojoTest.java
rename to nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/AbstractNbmMojoTest.java
diff --git a/src/test/java/org/codehaus/mojo/nbm/BrandingMojoTest.java b/nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/BrandingMojoTest.java
similarity index 100%
rename from src/test/java/org/codehaus/mojo/nbm/BrandingMojoTest.java
rename to nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/BrandingMojoTest.java
diff --git a/src/test/java/org/codehaus/mojo/nbm/CreateClusterAppMojoTest.java b/nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/CreateClusterAppMojoTest.java
similarity index 100%
rename from src/test/java/org/codehaus/mojo/nbm/CreateClusterAppMojoTest.java
rename to nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/CreateClusterAppMojoTest.java
diff --git a/src/test/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructureTest.java b/nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructureTest.java
similarity index 100%
rename from src/test/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructureTest.java
rename to nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/CreateNetBeansFileStructureTest.java
diff --git a/src/test/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojoTest.java b/nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojoTest.java
similarity index 100%
rename from src/test/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojoTest.java
rename to nbm-maven-plugin/src/test/java/org/codehaus/mojo/nbm/NetBeansManifestUpdateMojoTest.java
diff --git a/src/test/resources/osgimanifests/a.b.c.MF b/nbm-maven-plugin/src/test/resources/osgimanifests/a.b.c.MF
similarity index 100%
rename from src/test/resources/osgimanifests/a.b.c.MF
rename to nbm-maven-plugin/src/test/resources/osgimanifests/a.b.c.MF
diff --git a/src/test/resources/osgimanifests/b.c.d.MF b/nbm-maven-plugin/src/test/resources/osgimanifests/b.c.d.MF
similarity index 100%
rename from src/test/resources/osgimanifests/b.c.d.MF
rename to nbm-maven-plugin/src/test/resources/osgimanifests/b.c.d.MF
diff --git a/nbm-shared/pom.xml b/nbm-shared/pom.xml
new file mode 100644
index 0000000..680b83e
--- /dev/null
+++ b/nbm-shared/pom.xml
@@ -0,0 +1,280 @@
+<?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-shared</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>NBM Plugins Utilities</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/nbm-shared</url>
+ <issueManagement>
+ <system>GitHub</system>
+ <url>https://github.com/mojohaus/nbm-shared/issues</url>
+ </issueManagement>
+ <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/nbm-shared.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mojohaus/nbm-shared.git</developerConnection>
+ <url>https://github.com/mojohaus/nbm-shared/tree/${project.scm.tag}</url>
+ <tag>master</tag>
+ </scm>
+ <developers>
+ <developer>
+ <id>mkleint</id>
+ <name>Milos Kleint</name>
+ <email>mkleint@codehaus.org</email>
+ <organization>Codehaus</organization>
+ <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>
+ </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>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</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>java16</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>plugin-management</report>
+ <report>plugins</report>
+ <report>project-team</report>
+ <report>scm</report>
+ <report>summary</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>
+ <!-- <onlyCurrentVersion>true</onlyCurrentVersion>-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.9.1</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-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>-->
+ <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>
+ <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/${maven.version}/maven-artifact/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-artifact-manager/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-model/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-plugin-api/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-project/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-reporting/maven-reporting-api/apidocs/</link>
+ <link>http://maven.apache.org/ref/${maven.version}/maven-settings/apidocs/</link>
+ </links>
+ <tagletArtifacts>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.8</version>
+ </tagletArtifact>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-javadoc</artifactId>
+ <version>1.5.5</version>
+ </tagletArtifact>
+ </tagletArtifacts>
+ </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-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>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.12</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <!--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-plugin-api</artifactId>
+ <version>3.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.9.2</version>
+ <scope>compile</scope>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ <properties>
+ <mojo.java.target>1.6</mojo.java.target>
+ <maven.version>3.0.4</maven.version>
+ </properties>
+</project>
diff --git a/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/AbstractNetbeansMojo.java b/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/AbstractNetbeansMojo.java
new file mode 100644
index 0000000..c005bb9
--- /dev/null
+++ b/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/AbstractNetbeansMojo.java
@@ -0,0 +1,132 @@
+/* ==========================================================================
+ * Copyright 2003-2004 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.utils;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Taskdef;
+
+public abstract class AbstractNetbeansMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Creates a project initialized with the same logger.
+ * @return project
+ */
+ protected final Project antProject()
+ {
+ Project antProject = new Project();
+ antProject.init();
+ antProject.addBuildListener( new BuildListener()
+ {
+ @Override
+ public void buildStarted( BuildEvent be )
+ {
+ getLog().debug( "Ant build started" );
+ }
+ @Override
+ public void buildFinished( BuildEvent be )
+ {
+ if ( be.getException() != null )
+ {
+ getLog().error( be.getMessage(), be.getException() );
+ }
+ else
+ {
+ getLog().debug( "Ant build finished" );
+ }
+ }
+ @Override
+ public void targetStarted( BuildEvent be )
+ {
+ getLog().info( be.getTarget().getName() + ":" );
+ }
+ @Override
+ public void targetFinished( BuildEvent be )
+ {
+ getLog().debug( be.getTarget().getName() + " finished" );
+ }
+ @Override
+ public void taskStarted( BuildEvent be )
+ {
+ getLog().debug( be.getTask().getTaskName() + " started" );
+ }
+ @Override
+ public void taskFinished( BuildEvent be )
+ {
+ getLog().debug( be.getTask().getTaskName() + " finished" );
+ }
+ @Override
+ public void messageLogged( BuildEvent be )
+ {
+ switch ( be.getPriority() )
+ {
+ case Project.MSG_ERR:
+ getLog().error( be.getMessage() );
+ break;
+ case Project.MSG_WARN:
+ getLog().warn( be.getMessage() );
+ break;
+ case Project.MSG_INFO:
+ getLog().info( be.getMessage() );
+ break;
+ default:
+ getLog().debug( be.getMessage() );
+ }
+ }
+ } );
+ return antProject;
+ }
+
+ protected final Project registerNbmAntTasks()
+ {
+ Project antProject = antProject();
+
+ Taskdef taskdef = (Taskdef) antProject.createTask( "taskdef" );
+ taskdef.setClassname( "org.netbeans.nbbuild.MakeListOfNBM" );
+ taskdef.setName( "genlist" );
+ taskdef.execute();
+
+ taskdef = (Taskdef) antProject.createTask( "taskdef" );
+ taskdef.setClassname( "org.netbeans.nbbuild.MakeNBM" );
+ taskdef.setName( "makenbm" );
+ taskdef.execute();
+
+ taskdef = (Taskdef) antProject.createTask( "taskdef" );
+ taskdef.setClassname( "org.netbeans.nbbuild.MakeUpdateDesc" );
+ taskdef.setName( "updatedist" );
+ taskdef.execute();
+
+ taskdef = (Taskdef) antProject.createTask( "taskdef" );
+ taskdef.setClassname( "org.netbeans.nbbuild.CreateModuleXML" );
+ taskdef.setName( "createmodulexml" );
+ taskdef.execute();
+
+ taskdef = (Taskdef) antProject.createTask( "taskdef" );
+ taskdef.setClassname( "org.netbeans.nbbuild.JHIndexer" );
+ taskdef.setName( "jhindexer" );
+ taskdef.execute();
+
+ return antProject;
+ }
+
+
+
+}
diff --git a/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/ExamineManifest.java b/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/ExamineManifest.java
new file mode 100644
index 0000000..730114d
--- /dev/null
+++ b/nbm-shared/src/main/java/org/codehaus/mojo/nbm/utils/ExamineManifest.java
@@ -0,0 +1,503 @@
+/* ==========================================================================
+ * Copyright 2003-2004 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.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Tag examines the manifest of a jar file and retrieves NetBeans specific information.
+ * @author <a href="mailto:mkleint@codehaus.org">Milos Kleint</a>
+ *
+ */
+public class ExamineManifest
+{
+
+ private final Log logger;
+ private File jarFile;
+ private File manifestFile;
+ private boolean netBeansModule;
+ private boolean osgiBundle;
+
+ private boolean localized;
+ private String specVersion;
+ private String implVersion;
+ private String module;
+ private String locBundle;
+ private String classpath;
+ private boolean publicPackages;
+ private boolean populateDependencies = false;
+ private List<String> dependencyTokens = Collections.<String>emptyList();
+ private Set<String> osgiImports = Collections.<String>emptySet();
+ private Set<String> osgiExports = Collections.<String>emptySet();
+
+ private boolean friendPackages = false;
+ private List<String> friends = Collections.<String>emptyList();
+ private List<String> packages = Collections.<String>emptyList();
+
+ private List<String> requires = Collections.<String>emptyList();
+
+ private List<String> provides = Collections.<String>emptyList();
+ //that's the default behaviour without the special manifest entry
+ private boolean bundleAutoload = true;
+
+ public ExamineManifest( Log logger )
+ {
+ this.logger = logger;
+ }
+
+ public void checkFile()
+ throws MojoExecutionException
+ {
+
+ resetExamination();
+
+ Manifest mf = null;
+ if ( jarFile != null )
+ {
+ JarFile jar = null;
+ try
+ {
+ jar = new JarFile( jarFile );
+ mf = jar.getManifest();
+ }
+ catch ( Exception exc )
+ {
+ throw new MojoExecutionException( "Could not open " + jarFile + ": " + exc.getMessage(), exc );
+ }
+ finally
+ {
+ if ( jar != null )
+ {
+ try
+ {
+ jar.close();
+ }
+ catch ( IOException io )
+ {
+ throw new MojoExecutionException( io.getMessage(), io );
+ }
+ }
+ }
+ }
+ else if ( manifestFile != null )
+ {
+ InputStream stream = null;
+ try
+ {
+ stream = new FileInputStream( manifestFile );
+ mf = new Manifest( stream );
+ }
+ catch ( Exception exc )
+ {
+ throw new MojoExecutionException( exc.getMessage(), exc );
+ }
+ finally
+ {
+ if ( stream != null )
+ {
+ try
+ {
+ stream.close();
+ }
+ catch ( IOException io )
+ {
+ throw new MojoExecutionException( io.getMessage(), io );
+ }
+ }
+ }
+ }
+ if ( mf != null )
+ {
+ processManifest( mf );
+ }
+ else
+ {
+ //MNBMODULE-22
+ File source = manifestFile;
+ if ( source == null )
+ {
+ source = jarFile;
+ }
+ if ( source == null )
+ {
+ logger.debug( "No manifest to examine" );
+ }
+ else
+ {
+ logger.debug( "Cannot find manifest entries in " + source.getAbsolutePath() );
+ }
+ }
+ }
+
+ private void resetExamination()
+ {
+ setNetBeansModule( false );
+ this.localized = false;
+ this.specVersion = null;
+ this.implVersion = null;
+ this.module = null;
+ this.locBundle = null;
+ this.publicPackages = false;
+ classpath = "";
+ }
+
+ private void processManifest( Manifest mf )
+ {
+ Attributes attrs = mf.getMainAttributes();
+ this.module = attrs.getValue( "OpenIDE-Module" );
+ setNetBeansModule( getModule() != null );
+ if ( isNetBeansModule() )
+ {
+ this.locBundle = attrs.getValue( "OpenIDE-Module-Localizing-Bundle" );
+ this.localized = locBundle != null;
+ this.specVersion = attrs.getValue( "OpenIDE-Module-Specification-Version" );
+ this.implVersion = attrs.getValue( "OpenIDE-Module-Implementation-Version" );
+ String cp = attrs.getValue( Attributes.Name.CLASS_PATH );
+ classpath = cp == null ? "" : cp;
+ String value = attrs.getValue( "OpenIDE-Module-Public-Packages" );
+ String frList = attrs.getValue( "OpenIDE-Module-Friends" );
+ if ( value == null || value.trim().equals( "-" ) )
+ {
+ this.publicPackages = false;
+ }
+ else
+ {
+ if ( frList != null )
+ {
+ this.publicPackages = false;
+ String[] friendList = StringUtils.stripAll( StringUtils.split( frList, "," ) );
+ friendPackages = true;
+ friends = Arrays.asList( friendList );
+ }
+ else
+ {
+ this.publicPackages = true;
+ }
+ String[] packageList = StringUtils.stripAll( StringUtils.split( value, "," ) );
+ packages = Arrays.asList( packageList );
+ }
+ if ( populateDependencies )
+ {
+ String deps = attrs.getValue( "OpenIDE-Module-Module-Dependencies" );
+ if ( deps != null )
+ {
+ StringTokenizer tokens = new StringTokenizer( deps, "," );
+ List<String> depList = new ArrayList<String>();
+ while ( tokens.hasMoreTokens() )
+ {
+ String tok = tokens.nextToken();
+ //we are just interested in specification and loose dependencies.
+ int spec = tok.indexOf( '>' );
+ int impl = tok.indexOf( '=');
+ if ( spec > 0 )
+ {
+ tok = tok.substring( 0, spec );
+ }
+ else if ( impl > 0 )
+ {
+ tok = tok.substring( 0, impl );
+ }
+ int slash = tok.indexOf( '/' );
+ if ( slash > 0 )
+ {
+ tok = tok.substring( 0, slash );
+ }
+ depList.add( tok.trim().intern() );
+ }
+ this.dependencyTokens = depList;
+ }
+ String req = attrs.getValue( "OpenIDE-Module-Requires" );
+ String prov = attrs.getValue( "OpenIDE-Module-Provides" );
+ String needs = attrs.getValue( "OpenIDE-Module-Needs" );
+ if (prov != null) {
+ provides = Arrays.asList( StringUtils.stripAll( StringUtils.split( prov, "," ) ));
+ }
+ if (req != null || needs != null) {
+ requires = new ArrayList<String>();
+ if (req != null) {
+ requires.addAll(Arrays.asList( StringUtils.stripAll( StringUtils.split( req, "," ) )));
+ }
+ if (needs != null) {
+ requires.addAll(Arrays.asList( StringUtils.stripAll( StringUtils.split( needs, "," ) )));
+ }
+ }
+ }
+
+ }
+ else
+ {
+
+ //check osgi headers first, let nb stuff override it, making nb default
+ String bndName = attrs.getValue( "Bundle-SymbolicName" );
+ if ( bndName != null )
+ {
+ this.osgiBundle = true;
+ this.module =
+ bndName./* MNBMODULE-125 */replaceFirst( " *;.+", "" )./* MNBMODULE-96 */replace( '-', '_' );
+ this.specVersion = attrs.getValue( "Bundle-Version" );
+ String exp = attrs.getValue( "Export-Package" );
+ String autoload = attrs.getValue( "Nbm-Maven-Plugin-Autoload");
+ if (autoload != null) {
+ bundleAutoload = Boolean.parseBoolean( autoload );
+ }
+ this.publicPackages = exp != null;
+ if ( populateDependencies )
+ {
+ //well, this doesn't appear to cover the major way of declation dependencies in osgi - Import-Package
+ String deps = attrs.getValue( "Require-Bundle" );
+ if ( deps != null )
+ {
+ List<String> depList = new ArrayList<String>();
+ // http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
+ for ( String piece : deps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
+ {
+ depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
+ }
+ this.dependencyTokens = depList;
+ }
+ String imps = attrs.getValue( "Import-Package" );
+ if ( imps != null )
+ {
+ Set<String> depList = new HashSet<String>();
+ // http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
+ for ( String piece : imps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
+ {
+ depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
+ }
+ this.osgiImports = depList;
+ }
+ String exps = attrs.getValue( "Export-Package" );
+ if ( exps != null )
+ {
+ Set<String> depList = new HashSet<String>();
+ // http://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
+ for ( String piece : exps.split( ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)" ) )
+ {
+ depList.add( piece.replaceFirst( ";.+", "" ).trim().intern() );
+ }
+ this.osgiExports = depList;
+ }
+
+ }
+ }
+ else
+ {
+
+ // for non-netbeans, non-osgi jars.
+ this.specVersion = attrs.getValue( "Specification-Version" );
+ this.implVersion = attrs.getValue( "Implementation-Version" );
+ this.module = attrs.getValue( "Package" );
+ this.publicPackages = false;
+ classpath = "";
+ /* if ( module != null )
+ {
+ // now we have the package to make it a module definition, add the version there..
+ module = module + "/1";
+ }
+ */
+ if ( getModule() == null )
+ {
+ // do we want to do that?
+ this.module = attrs.getValue( "Extension-Name" );
+ }
+ }
+ }
+
+ }
+
+ /**
+ * The jar file to examine. It is exclusive with manifestFile.
+ * @param jarFileLoc jar file
+ */
+ public void setJarFile( File jarFileLoc )
+ {
+ jarFile = jarFileLoc;
+ }
+
+ /**
+ * Manifest file to be examined. It is exclusive with jarFile.
+ * @param manifestFileLoc manifedt file
+ */
+ public void setManifestFile( File manifestFileLoc )
+ {
+ manifestFile = manifestFileLoc;
+ }
+
+ /**
+ * Either call {@link #setJarFile} or {@link #setManifestFile} as appropriate.
+ * @param artifactFileLoc a JAR or folder
+ */
+ public void setArtifactFile( File artifactFileLoc )
+ {
+ if ( artifactFileLoc.isFile() )
+ {
+ setJarFile( artifactFileLoc );
+ }
+ else if ( artifactFileLoc.isDirectory() )
+ {
+ File mani = new File( artifactFileLoc, "META-INF/MANIFEST.MF" );
+ if ( mani.isFile() )
+ {
+ setManifestFile( mani );
+ } // else e.g. jarprj/target/classes has no manifest, so nothing to examine
+ }
+ else
+ {
+ throw new IllegalArgumentException( artifactFileLoc.getAbsolutePath() );
+ }
+ }
+
+ public String getClasspath()
+ {
+ return classpath;
+ }
+
+ public boolean isNetBeansModule()
+ {
+ return netBeansModule;
+ }
+
+ public void setNetBeansModule( boolean netBeansModule )
+ {
+ this.netBeansModule = netBeansModule;
+ }
+
+ public boolean isLocalized()
+ {
+ return localized;
+ }
+
+ public String getSpecVersion()
+ {
+ return specVersion;
+ }
+
+ public String getImplVersion()
+ {
+ return implVersion;
+ }
+
+ /**
+ * Code name base of the module only.
+ * Does not include any release version.
+ * @return module code name base
+ */
+ public String getModule()
+ {
+ return module != null ? module.replaceFirst( "/\\d+$", "" ) : module;
+ }
+
+ /**
+ * Full name of module: code name base, then optionally slash and major release version.
+ * @return module full name
+ */
+ public String getModuleWithRelease()
+ {
+ return module;
+ }
+
+ /**
+ * returns true if there are defined public packages and there is no friend
+ * declaration.
+ * @return true if has public package
+ */
+ public boolean hasPublicPackages()
+ {
+ return publicPackages;
+ }
+
+ public void setPopulateDependencies( boolean populateDependencies )
+ {
+ this.populateDependencies = populateDependencies;
+ }
+
+ public List<String> getDependencyTokens()
+ {
+ return dependencyTokens;
+ }
+
+ /**
+ * returns true if both public packages and friend list are declared.
+ * @return true if has friend package
+ */
+ public boolean hasFriendPackages()
+ {
+ return friendPackages;
+ }
+
+ public List<String> getFriends()
+ {
+ return friends;
+ }
+
+ /**
+ * list of package statements from OpenIDE-Module-Public-Packages.
+ * All items end with .*
+ * @return list of package
+ */
+ public List<String> getPackages()
+ {
+ return packages;
+ }
+
+ public boolean isOsgiBundle()
+ {
+ return osgiBundle;
+ }
+
+ public Set<String> getOsgiImports()
+ {
+ return osgiImports;
+ }
+
+ public Set<String> getOsgiExports()
+ {
+ return osgiExports;
+ }
+
+ public List<String> getNetBeansRequiresTokens()
+ {
+ return requires;
+ }
+
+ public List<String> getNetBeansProvidesTokens()
+ {
+ return provides;
+ }
+
+ public boolean isBundleAutoload()
+ {
+ return bundleAutoload;
+ }
+
+}
diff --git a/nbm-shared/src/test/java/org/codehaus/mojo/nbm/utils/ExamineManifestTest.java b/nbm-shared/src/test/java/org/codehaus/mojo/nbm/utils/ExamineManifestTest.java
new file mode 100644
index 0000000..f23827d
--- /dev/null
+++ b/nbm-shared/src/test/java/org/codehaus/mojo/nbm/utils/ExamineManifestTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2010 jglick.
+ *
+ * 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.utils;
+
+import java.io.File;
+import java.io.PrintWriter;
+import junit.framework.TestCase;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+
+public class ExamineManifestTest extends TestCase
+{
+
+ public ExamineManifestTest( String testName )
+ {
+ super(testName);
+ }
+
+ public void testDependencyParsing()
+ throws Exception
+ {
+ ExamineManifest em = new ExamineManifest( new SystemStreamLog() );
+ File mf = File.createTempFile( "ExamineManifestTes", ".mf" );
+ mf.deleteOnExit();
+ PrintWriter w = new PrintWriter( mf );
+ w.println( "OpenIDE-Module: org.netbeans.modules.nbjunit/1" );
+ w.println( "OpenIDE-Module-Module-Dependencies: org.netbeans.insane/1, org.netbeans.libs.junit4 > 1.0" );
+ w.flush();
+ w.close();
+ em.setManifestFile( mf );
+ em.setPopulateDependencies( true );
+ em.checkFile();
+ assertEquals( "[org.netbeans.insane, org.netbeans.libs.junit4]", em.getDependencyTokens().toString() );
+ assertEquals( "org.netbeans.modules.nbjunit", em.getModule() );
+ assertEquals( "org.netbeans.modules.nbjunit/1", em.getModuleWithRelease() );
+ em = new ExamineManifest( new SystemStreamLog() );
+ mf.delete();
+ w = new PrintWriter( mf );
+ w.println( "Manifest-Version: 1.0" );
+ w.flush();
+ w.close();
+ em.setManifestFile( mf );
+ em.setPopulateDependencies( true );
+ em.checkFile();
+ assertEquals( null, em.getModule() );
+ assertEquals( null, em.getModuleWithRelease() );
+ }
+
+ public void testBundles()
+ throws Exception
+ {
+ ExamineManifest em = new ExamineManifest( new SystemStreamLog() );
+ File mf = File.createTempFile( "ExamineManifestTest", ".mf" );
+ mf.deleteOnExit();
+ PrintWriter w = new PrintWriter( mf );
+ w.println( "Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true" );
+ w.println( "Bundle-Version: 3.1.0" );
+ w.println( "Export-Package: org.eclipse.jdt.core," );
+ w.println( " org.eclipse.jdt.internal.formatter.old;x-internal:=true" );
+ w.println( "Require-Bundle: org.eclipse.equinox.registry;bundle-version=\"[3.4.0,4." );
+ w.println( " 0.0)\",org.eclipse.equinox.common;bundle-version=\"[3.2.0,4.0.0)\"" );
+ w.flush();
+ w.close();
+ em.setManifestFile( mf );
+ em.setPopulateDependencies( true );
+ em.checkFile();
+ assertEquals( "org.eclipse.jdt.core", em.getModule() );
+ assertEquals( "3.1.0", em.getSpecVersion() );
+ assertTrue( em.hasPublicPackages() );
+ assertEquals( "[org.eclipse.equinox.registry, org.eclipse.equinox.common]", em.getDependencyTokens().toString() );
+ }
+
+}