Where should a custom Netbeans Platform conf. file be so that maven finds it? - maven

Applications built on top of the NetBeans platform have a <myappdir>/etc/<myapp>.conf file determining, among other things, application JVM parameters. Historically, this file was a part of the NetBeans IDE installation (as far as I could tell), but starting with NB 6.9, custom files are now supported.
I am having trouble packaging a custom configuration file using Maven to build the application.
I imagine the app.conf property should have been set in the project's pom under project/build/pluginManagement/plugins like so:
<plugin>
...
<configuration>
<brandingToken>${brandingToken}</brandingToken>
<cluster>${brandingToken}</cluster>
<appConf>myapp.conf</appConf>
</configuration>
The maven module representing my application contained no prior source, so I created the src/main/nbm folder and placed myapp.conf in src/main/nbm. This isn't picked up by nbm-maven-plugin. and putting the conf file into src/main/resources doesn't make a difference.
So, can anyone explain how a NetBeans Platform application with a custom configuration file can be built using maven?
UPDATE:
With Tim's prod in the right direction, I found the answer documented on Geertjan's blog. The solution is to configure the nbm-maven-plugin like so in the application module pom:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<configuration>
<etcConfFile>src/main/resources/my.conf</etcConfFile>
</configuration>
</plugin>
</plugins>
</build>
BTW, if you need a second name with Geertjan, you're not really a NetBeans platform developer. ;)

Have a look at the documentation of the nbm:cluster-app plugin, specifically the part on the conf file.
As per my understanding that should allow you to replace the default one with a custom one that you create.

Related

How to have version in WAR filename, but not require it in the URL when deployed in Tomcat

I want to version my WAR to make DevOps lives easier, i.e.: foo-3.2.0.war. In pom.xml, I have:
<build>
<finalName>foo</finalName>
but also
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<warName>${project.artifactId}-${project.version}</warName>
that imparts the current version in pom.xml to the WAR filename. So far, so good.
The problem becomes that the version is required in the URL when deployed to Tomcat. I want my application accessed thus: http://hostname:port/foo and not http://hostname:port/foo-3.2.0 (etc.) because I'd have to annoy my consumer with the version change.
Is it possible to work around this problem without just going back to an unversioned WAR file?
You can use ${project.artifactId}##${project.version} as naming scheme.
The part after ## will not be part of the context name (cf. parallel deployment).

NetBeans - show compiler warnings for JSP in non-standard location

Modular components for Liferay portal provided as OSGi modules use non standard Maven layout. All JSP pages are located in /src/main/resources/META-INF/resources instead of typical /src/main/webapps. Moreover, jar packaging is used instead of typical war. When such a project is opened in NetBeans, no errors or warnings are shown in JSP file even it is broken deliberately.
Example project can be found here https://github.com/liferay/liferay-blade-samples/tree/7.1/maven/apps/jsp-portlet
Can I somehow configure NetBeans to process my JSP files as usual?
NetBeans source code revealed there is some support for non-standard locations via the configuration of maven-war-plugin. So this plugin has to be present even not needed for the build:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<warSourceDirectory>/src/main/resources/META-INF/resources</warSourceDirectory>
</configuration>
</plugin>

changing maven site plugin source folder

I need to change the maven site documentation source folder. I've check the plugin documentation and couldn't find this configuration.
Problem scenario:
I have a maven project with several child project, and one of this child is only a angular2 project.
On the angular project, the source folder has the pom.xml and several angular files, and one of the folder used by angular is 'src' (which is there the components, services, etc are stored).
I need to add maven site to this project, and it look the source files into 'src/site/*'. This works, but this 'site' folder is mixed with several ts files, and this looks messy, so I need to change the default folder for maven site plugin.
Is there any way to change it?
If you wish to change the source directory in which Maven looks for, although I would rather recommend to clean your directory, I think what's below should work:
<build>
....
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
<configuration>
<siteDirectory>my/site/dir</siteDirectory>
</configuration>
</plugin>
....
</plugins>
....
</build>

Extract current folder name within maven pom.xml file

I am looking for a way to dynamically extract the current folder name within maven pom.xml file.
For Example:
if the pom.xml file is at /home/jenkins/workspace/bdms-ci/bdms-bcr/pom.xml
then bdms-bcr is the current folder.
See a code snippet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<testClassesDirectory>../../bdms-ci-improve/${project.basedir}/target/test-classes</testClassesDirectory>
<classesDirectory>../../bdms-ci-improve/${project.basedir}/target/classes</classesDirectory>
</configuration>
</plugin>
${project.basedir} will bring the full path which is not good since only the current folder is needed.
I tried to work with MavenProject class from the maven api document:
${project.file.parentFile.name} or ${project.file.name}, but it didn't work.
remember it is maven multi project and everything has to be dynamically.
The whole issue is for jenkins ci build which use parallel-test-executor plugin. I would like to compile once in the main job and then all the other test execute jobs will will only test by looking into the compiled code.
Using maven 3.2.3
#guymi,
Seems like you should be able to simply use ${project.artifactId} or perhaps ${parent.artifactId}.
EDIT
Or does your artifactId name disagree with the directory it's stored in?
If so, that's possible but not good practice and should be avoided.
It is not possible to do it. simple as that.
A workaround solution is by using artifactId with the same name as folder name. then you can do:
../../bdms-ci-improve/${project.artifactId}/target/test-classes</testClassesDirectory>

ClassNotFoundException Netbeans Maven Library wrapper

I was able to follow the tutorial here and convert it to a Maven application.
I got the loading part right, but when I try to use it, it can't find the appropriate swt classes (When ran from windows 64). I did it on a Maven project. Here's the relevant part of the respective pom for the Windows 64 module:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<!-- To have the jar plugin pickup the nbm generated manifest -->
<useDefaultManifestFile>true</useDefaultManifestFile>
<moduleType>normal</moduleType>
swt.windows.64/1</codeNameBase>
<publicPackages>
<publicPackage>org.eclipse.swt</publicPackage>
</publicPackages>
</configuration>
</plugin>
I translates to org.eclipse.swt.*. It seems to be a Maven module issue since it already tries to load from correct module.
Caused: java.lang.ClassNotFoundException: org.eclipse.swt.SWT starting from ModuleCL#25e0dee5[djproject.core] with possible defining loaders [ModuleCL#6783113b[swt.windows.64]] and declared parents [ModuleCL#32821bf7[org.netbeans.api.annotations.common]]
Caused: java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInterface.java:213)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java:71)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:337)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
at synamicd.windows64.support.Windows64BrowserProvider.initialize(Windows64BrowserProvider.java:25)
Any help is more than welcomed!
Edit:
Code is available here.
when I try to build the application at the bitbucket location, it's build order suggests that none of the swt modules are used in the app - http://screencast.com/t/LMxIPy6A6ZUL

Resources