embed generated report into maven site - maven-site-plugin

I am using a Maven plugin which generates a report. It appears as a separate directory in target.
However, this plugin does not implement the Maven Site Report interface, hence cannot be just included in the <reporting> section of pom.xml
Is there someway to have it included in the site and linked to?
TIA
Adrian.

Related

netbeans web.xml file is same as pom.xml file in eclipse?

Am a beginner with netbeans IDE. I want to know that web.xml file in Netbeans hierarchy is same as that of pom.xml file in Eclipse IDE.
Where as in Eclipse, when we create a project it comes with pom.xml file. We can modify when we need to modify or to add dependencies. So, how about in Netbeans? web.xml work as similar to pom.xml
I think you got this all wrong. Please read through some materials.
web.xml - deployment descriptor
Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web.xml, and resides in the app's WAR under the WEB-INF/ directory. web.xml is part of the servlet standard for web applications.
A web application's deployment descriptor describes the classes, resources and configuration of the application and how the web server uses them to serve web requests. When the web server receives a request for the application, it uses the deployment descriptor to map the URL of the request to the code that ought to handle the request.
pom.xml - project object model
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects. Examples for this is the build directory, which is target; the source directory, which is src/main/java; the test source directory, which is src/test/java; and so on.
The POM was renamed from project.xml in Maven 1 to pom.xml in Maven 2. Instead of having a maven.xml file that contains the goals that can be executed, the goals or plugins are now configured in the pom.xml. When executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal.
Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.
Go through the below pages.
https://maven.apache.org/guides/introduction/introduction-to-the-pom.html
https://cloud.google.com/appengine/docs/java/config/webxml

Exporting an Eclipse plugin with a dependency on an external jar

Just recently started using Eclipse and ran into an issue with exporting the plugin I'm working on. I tried to search but so far no luck - but if the answer is already here I'd be grateful if someone can point me to it.
I'm writing a n OSGi/Equinox plugin with Eclipse. The plugin is for a 3rd party system, which allows extensions: basically all jars placed in the application's plugin folder are automatically loaded into the application at startup. I have managed to put together my plugin, it's loading fine and it works.
The issue is that I rely on another plugin which is placed beside mine in the plugins folder. For obvious reasons I do not want to package that plugin into my plugin jar file. I have tried to add the dependency as an external archive, but this breaks the export: when I try to export my plugin project ant complains about missing dependencies and types. (If I actually include the other jar file in my plugin everything works, but obviously this is less then ideal.)
So: how do I set up my plugin project dependency, that it's a) an external dependency and b) doesn't need to be specified with a path or a variable - i.e. how do I tell my exporter to "don't worry, it will be there right beside you"?
Edit: Apparently there's an important detail I didn't mention. The external jar file I depend on is not an OSGi plugin, just a regular jar file with some classes in it. To the 3rd party system it seems all the same (all are under the plugins folder, all are loaded into the application), but for Eclipse the distinction seems important.
If you reference the other plug-in as a dependency in your plug-in's MANIFEST.MF the export should work without errors. The plug-in should be listed in the Require-Bundle list in the MANIFEST.MF.
You can do this in the MANIFEST.MF editor by adding to the 'Required Plug-ins' list on the 'Dependencies' tab of the editor.
Note: When referencing other plug-ins you must always use this method. Do not try adding the plug-in jar to the Java build path or anything like that.
If the jar you want to use is not an Eclipse plug-in you must should include it as part of the plug-in and list the jar in the Bundle-Classpath in the MANIFEST.MF. If you cannot do this you can reference an external jar in the Bundle-Classpath using something like:
Bundle-Classpath: .,external:$LIB_LOCATION$/lib.jar
. is the normal entry in for the plug-in code. external:$LIB_LOCATION$/lib.jar looks for lib.jar in a location defined by the environment variable LIB_LOCATION. This method can be difficult to get right.
In the end the solution to my specific problem was to add the external jar file as an Extra Classpath Entry on the build properties tab (this translated to a "jars.extra.classpath = .jar" entry in the build.properties file). I have also added the jar file to the project itself - after adding the extra class path entry that got changed into an external dependency automatically.
With these two changes I was able to successfully export my plugin, which didn't contain the external jar file, but was able to reference it when loaded into the 3rd party system.

How can I automatically build multiple Eclipse Plug-In Projects as one Jenkins project?

we're using Jenkins as our build server. We have a Project which is built out of Eclipse Plug-Ins, a core project and several other plugins. Building the Core on Jenkins and using Sonar on it is relatively.
Now we want to create a Jenkins build where the whole Project is being automatically built and tested by Sonar. Internet research showed to change the packaging to "pom", which can't be done because the Tycho plugin needs to have packaging set to "eclipse-plugin".
What are we doing wrong and how do you setup a project like this in Jenkins?
If any additional information is needed, please do tell.
You should create an "umbrella" Maven project with pom packaging and make all of your other project modules of this aggregator. In addition however the whole group of projects need to be accessible from your SCM tool as a single entity. If you are using Subversion this is easily achievable by means of svn:externals, with other tools I suspect you'd have to alter your configuration. I suggest you also check out whether there's any Jenkins plugins that might be of help.
For git, you can use the submodules feature to achieve the same as with svn:externals. See for example mylyn, which probably comes close to what you are trying to achieve:
git clone git://git.eclipse.org/gitroot/mylyn/org.eclipse.mylyn.git
Given this example directory layout:
+ParentDir
-pom.xml
+ProjectA
-pom.xml
+ProjectB
+SubDirB
-pom.xml
Contents of pom.xml in ParentDir should include the following:
<packaging>pom</packaging>
<modules>
<module>ProjectA/pom.xml</module>
<module>ProjectB/SubDirB/pom.xml</module>
</modules>
And when you invoke Maven on this top-level POM, it will add ProjectA and ProjectB to the reactor list to be built.
This can be adapted for similar projects, and the <module> tag accepts relative paths, for example ../../SomeProject/pom.xml.

Local Project Dependencies and Maven

I'm converting an ant backed Netbeans project into an Maven project. I've got most of the third party libraries set up in the POM, however now I've run into problems with setting up the local dependencies.
With the previous Netbeans way of doing things, it just added a project reference [with links to the source and jar location, rebuilt the dependency if the depedency's source had been changed and hadn't been compiled]. However I'm not sure how to setup up Maven to emulate this behavior. Is it possible?
Example:
Projects/SharedLibrariesResource [Ant based project]
Projects/WebSite [this is a maven based project]
Projects/Client
In this example the website and client projects don't connect to each other, but they do share the SharedLibrariesResource. Website should compile to produce a War with links to the SharedLibrariesResource
The way I understand the question, the Website maven project depends on the ant SharedLibrariesResource project. When Website is built, it should include the SharedLibrariesResource artifacts. The assumption is SharedLibrariesResources produces a jar artifact.
One way to achieve this is to
install SharedLibrariesResource to your local maven repository each time ant builds it
specify this as a dependency in Website pom.
We can use maven ant tasks to achieve the first.

Eclipse doesn't find source attachements

When opening a class included through a Maven dependency, Eclipse tells me that the containing .jar file has got no source attachment.
But in the directory in which the .jar file resides, there is also as corresponding -sources.jar file.
Do you have any hints regarding the solution of this problem?
Is there a way to tell Eclipse where it should automatically look for the source attachment?
Edit: In the Eclipse .classpath file, the sourcepath value is set for external archives, but not for ours. But both jars and sources file reside in the same repo.
The property -Declipse.useProjectReferences=false is also set.
The problem was that there were already sources.jar-not-available files for certain projects in my local repository.
I've deleted them and now the attachment of source files is working. Obviously Eclipse respectively the Maven Eclipse plugin doesn't look for source attachments as long as these marker files exist.
If it hadn't been for the comment from K. Claszen I'd have never came up with this solution.
Check that you have downloadSources in the maven-eclipse-plugin section of your pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
...
</configuration>
</plugin>
If you are using m2eclipse plugin for integrating Maven projects in Eclipse, you might need to enable downloading sources and javadocs in m2eclipse preferences:
Window > Preferences > Maven > Download Artifact Sources
For me the file was in place in local repo and eclipse (4.5) kept complaining there is no associated source jar (sources.jar-not-available did not existed). I ended up removing the directory from local repo, letting eclipse to download the sources again repolulating the repo, running mvn eclipse:eclipse and refreshing the project.
For me all these steps was necessary to get this working.
For those who are still having trouble downloading sources for your Maven dependencies (like me), you can try this alternate method:
Find the particular Maven dependency you wished to inspect Java source code for. You need to have the Maven artifact name.
Next, navigate to the Maven repository server where you download the Maven dependency from. For example, I have spring-security-core-5.5.1.jar as my Maven dependency. The repository host site is from mvnrepository.com, in which the repository server is from https://repo1.maven.org/maven2/.
Navigate to mvnrepository.com and search for your Maven dependency artifact. In my case, it would be spring-security-core, and I located the artifact information page here.
On this page, in the table row labeled Files, you want to click on View All, on the right of the JAR link with how many kilobytes displayed to the side. (Underlined)
Once you're viewing the list of all JARs provided with the Maven dependency, click and download the one that says, [artifact name]-[artifact version]-sources.jar. In my case, it's spring-security-core-5.5.1-sources.jar.
Once downloaded, on your local machine, use your File Explorer to navigate to the folder containing the artifact JAR which you have trouble downloading the source codes for. In my case, it would be $MAVEN_HOME/repository/org/springframework/security/spring-security-core/5.5.1.
Move the [artifact name]-[artifact version]-sources.jar into this folder.
Go back into Eclipse, and try attaching the sources. You should be able to pick up the ...-sources.jar file upon attaching it.
After attaching it, you will then be able to see the source codes for your Maven dependency.
Right click at project, select Maven, select Download Sources.
I download a maven project from online,use mvn eclipse:eclipse converted to eclipse project then I occurred the problem.
solution is remove all external lib that start with 'M2_REPO',it's work for me.