I'm using the docbkx-tools for creating the DocBook by using Maven. At the moment I can produce the book in various formats. I also achieve to deploy my Maven site to the web server by using the Wagon through the WebDav already.
I would like to publish them together, the generated DocBook and my Maven site, by using the command like mvn clean install site:deploy. Could you please help to shed some light?
You simple need to copy the generated pdf/rtf/html whatever to the correct location and it will be deployed with the maven-site or you can generate directly into the target location for the site like this:
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
<version>2.0.14</version>
<dependencies>
<dependency>
<groupId>docbook</groupId>
<artifactId>docbook-xml</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate-pdf</goal>
</goals>
<phase>pre-site</phase>
<configuration>
<sourceDirectory>${basedir}/src/docbkx</sourceDirectory>
<xincludeSupported>true</xincludeSupported>
<includes>maui.xml</includes>
<foCustomization>src/docbkx/fopdf.xsl</foCustomization>
<targetDirectory>${project.build.directory}/site/</targetDirectory>
</configuration>
</execution>
</executions>
</plugin>
You shouldn't use site:deploy you should use mvn site and mvn site-deploy instead to get run the site life-cycle.
You can control the docbook output directory with this property : <targetDirectory> (default is ${basedir}/target/docbkx/<something dependending on the output format>.
On the other hand the maven-site-plugin will get all files under <inputDirectory> the create to site (globally, it make a zip with everything in the directory). Default is project.reporting.outputDirectory
So if you change the docbook plugin <targetDirectory> to something in maven-site-plugin <inputDirectory> : the docbook output will be included in the generated site zip.
Additionally, to be sure that your docbook plugin will be run before the site get deployed, you need to bind the docbook plugin the some phase in the site lifecycle before the site-deploy. So one of those phase is OK : pre-site site post-site
Here is more details about binding a plugin to a phase
Related
I am trying to deploy an Eclipse product to Nexus repository. I am somewhat successful, but still get some errors that I am not sure how to handle.
I am using maven-deploy-plugin in the feature (F) that builds product:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>snapshots</repositoryId>
<packaging>zip</packaging>
<generatePom>true</generatePom>
<url>http://repo:8081/nexus/content/repositories/snapshots</url>
<groupId>my.group</groupId>
<artifactId>my.artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<file>
target/products/product.zip
</file>
</configuration>
</execution>
</executions>
</plugin>
I execute 'mvn clean install' to build the product and then 'mvn deploy' on F. If I do that then I get error
Exception while publishing product /home/akravets/dev/workspaces/trunk/my.repository.feature/myProduct.product: publishing result: [Included element my.product.feature.feature.group 8.0.1.R20180301-1431 is missing. Cannot determine filter for requirement to this element.] -> [Help 1]
I've read discussions about this issue, but nothing seems relevant to my issue because I don't have any defined deploy phases besides the one in maven-deploy-plugin.
If I change phase of maven-deploy-plugin to 'install' I get almost satisfactory results. The zip file and generated pom get deployed to repository, but the build fails with error
product.qualifier-p2artifacts.xml. Return code is: 400, ReasonPhrase: Bad Request.
Why does this file even gets considered to be deployed to repository when it's not in file element of maven-deploy-plugin and it's not in the directory structure where zip file is: target/ vs target/product/product.zip? Is this because maven-deploy-plugin is executed during the install phase and it picks up all generated resources as candidates for deployment?
I simply recommend you to use Maven-Tycho to deploy Eclipse RCP product.Tycho determines the dependencies of a plug-in via the MANIFEST.MF file of the plug-in and fetches the required plugins-bundles through the online repositories.
You can check this git repository as an example; rcp - tycho
What I am trying to do, is to obfuscate a certain packages in a multi module application, before it gets installed to my local repository, so that the final package will be an EAR file which contains obfuscated jars.
I tried to obfuscate the jars during EAR building process without success. Now i want to build the EAR with obfuscated jars instead ob obfuscating then during the build.
So I've got the following plugin configuration:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.11</version>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>${version.proguard}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
...
</configuration>
</plugin>
So there are two problems for me:
Progruard always runs after the install phase, so that the EAR build always gets the not obfuscated jars
I always have to add proguard:proguard to the maven command, which of course fails in a multi module project where some modules don't have to be obfuscated
So my questions:
How can I obfuscate the package before it gets installed?
How can I make plugins like this one run on default without adding <phase>:<goal> to the maven call?
Thnx.
It seems that for the proguard plugin to work, JAR files are needed. Perhaps you can achieve this by attaching the proguard plugin's proguard goal to the package phase (and not process-classes phase) of the default Maven build life cycle as proposed here by Alexey Shmalko. It's not clear to me if you are using the maven-shade-plugin, but if you are, then place the proguard plugin configuration your in pom.xml after that of maven-shade-plugin (this is because both these plugin attach to the same phase: package).
My expectation is that since package phase is achieved before install phase, it should give you the effect you are looking for.
Using WSO2 Developer Studio (version 3.7.0), I have created a WSO2 ESB proxy service with a sequence in a "ESB Config Project", this proxy service using a wsdl file located in a "Registry Resources Project". I also created a "Composite Application Project" to generate my .car file (including proxy service, sequence and resources), and deployed this file in my WSO2 ESB installation with success.
Now I am trying to generate (then deploy) the .car file using maven command.
I first tried this solution : https://docs.wso2.com/display/DVS370/Deploying+a+CAR+File+with+the+Maven+Plug-In.
When executing command "mvn clean install" on my ESB Config Project, I get this error :
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory ([ESB Config Project Path]\target\capp).
Please verify you invoked Maven from the correct directory. -> [Help 1]
Indeed, the install goal is configured to be executed in "target/capp" directory :
<directory>target/capp</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<extensions>true</extensions>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>clean</argument>
<argument>install</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
...
Then I tried to create a "Maven Multi Module Project", as suggested here : maven build for WSo2 artifacts, but I did not found any solution to make it work :
following the steps from this documentation (https://docs.wso2.com/display/DVS310/Using+Maven+with+Developer+Studio?src=search), I created a "Maven Multi Module Project", and selected my Config, Resources and Composite projects as children. Then I launched the "mvn clean install" command, but still getting the error on ESB Config Project (no POM in target/capp folder).
Actually, I just did not found any information about these errors, and do not understand why the WSO2 documented solution did not work for me.
Does anyone have a suggestion about that ? How does WSO2 Developer Studio generate the .car file ?
Thanks
I found another answer for this problem. The exec-maven-plugin version seems to be buggy. The WSO2 Developer Studio 3.7.0 add a buggy version (1.2) when creating the project. You just have to change the artifact from:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
to:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
See this as a complementary information:
exec-maven-plugin says cannot run specified program, even though it is on the PATH
I finally succeded in generating a .car file and creating a maven multi module project.
I was trying to create all my maven projects with WSO2 Developer Studio 3.7.0, although the sample said to use version 3.2.0. As the WSO2's maven plugins versions change, it now works fine for me, executing maven install with plugin v2.0.4.
And a maven multi module project is finally just a maven project with modules, so it is OK.
Is there a way of automatically publishing as live website javadocs after uploading it to Nexus Maven repository? I have some packages, which are under constant development and I'd like to have the docs for them available for browsing by other team members straight after uploading updated code to our remote repository.
Is there any ready solution for doing that or would I have to write say a shell script (executed by Maven after successfull deployment of the code to the remote repo), which would copy the docs to a remote location on a web server?
I know that Nexus Professional allows to view javadocs out of the box, but even for 10 users it is a bit pricey, so I'd appreciate a different solution :-)
I'm using Eclipse#Windows + Maven 2.
Thanks!
If your project is open-source and is released to Maven Central then your javadoc will be available at javadoc.io automatically.
The url is of the form: http://www.javadoc.io/doc/[groupId]/[artifactId]. For example, I have my javadoc for my project at www.javadoc.io/doc/me.ramswaroop.jbot/jbot
Nexus Open Source as well as Nexus Professional support the site repository format, which allows you to host Maven produced sites. If you set up publishing a Maven site that includes Javadoc as part of your build you can have them accessible there.
The other thing you can do is just publish javadoc and source artifacts as part of you build and then Eclipse will be able to automatically download them from Nexus and you therefore wont even need a website with the javadoc on it for you developers.
Of course other people might want the site though.
Documentation on all that is available in the Nexus book as usual.
A bit late for reply, but someone else might need it in future. I didn't try the solution you proposed instead using one utilizing Maven Wagon plugin. Basically I first upload the jar with javadoc to webserver using sftp protocol and then unzip it using ssh command.
So parts of my parent POM, which configure the plugin look as follows:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<executions>
<execution>
<id>upload-javadoc</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<serverId>my_id</serverId>
<fromDir>${local.dir}</fromDir>
<includes>${javaDoc.file}</includes>
<excludes>pom.xml</excludes>
<url>${remote.url}</url>
<toDir>${remote.dir}</toDir>
</configuration>
</execution>
<execution>
<id>execute-test-commands</id>
<phase>deploy</phase>
<goals>
<goal>sshexec</goal>
</goals>
<configuration>
<serverId>my_id</serverId>
<url>${remote.url}</url>
<commands>
<command>mkdir -p ${www.dir}</command>
<command>unzip -o ${remote.dir}/${javaDoc.file} -d ${www.dir} > latest_unzip_log.txt</command>
</commands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
And then just call the plugin in child pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
So that's my solution, but I guess Manfred's is much simpler.
Ps.
Having the Javadoc available only in Ecplise (which I do anyways) was not the goal as the purpose was for the Javadoc to be available for other project members through a website.
Another option to host javadocs is https://docshoster.org/. It can automatically pickup from maven. There is an api to upload directly as well.
I have small maven project. I'm trying to add generating site by maven-site-plugin, but it doesn't work. When I'm building this project i get following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project server-wms-product: SiteToolException: The site descriptor cannot be resolved from the repository: ArtifactResolutionException: Unable to locate site descriptor: Could not transfer artifact [PARENT-PROJECT]:xml:site_en:1.0.141.1 from/to eclipse (http://maven.eclipse.org/nexus/content/repositories/testing/): Connection to http://maven.eclipse.org refused
My project is extension for other project, so in my pom.xml is set parent project which isn't mine and I can't add site configuration there.
So is there any chance to skip checking parent project's site in site generation?
My pom.xml looks like this:
<project>
<parent>
<artifactId>base-server-product</artifactId>
<groupId>XXXXXXXXXXXx</groupId>
<version>1.0</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<reportPlugins>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
And of course i have site.xml file in src/site.
Configure attaching the site descriptor to the artifacts in the parent pom.
<project>
<artifactId>base-server-product</artifactId>
<groupId>XXXXXXXXXXXx</groupId>
<version>1.0</version>
...
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<executions>
<execution>
<id>attach-descriptor</id>
<goals>
<goal>attach-descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
Core functionality has been separated from site generation in maven 3. You can find the reasons here. If you want to refer to the parent module's site from the submodule, you have to attach the site.xml to the deployed artifacts.
I have the exact same problem, and after much googling, came across this article which solved my problem:
http://amanica.blogspot.com/2010/08/archiva-gives-maven-site-plugin-invalid.html?m=1
Basically you want to add a basic site_en.xml to /src/site/ folder in your parent pom.xml.
For a reason I can't fathom, with me, it was enough to run maven in offline mode once.
I came across this question when working on an open source project I don't own where I wanted to submit an update to a site being generated in this manner. I wanted to test and view the change locally, but kept hitting this error.
User #Frischling alluded to this above (credit to them). It turns out what I wanted was not to edit any existing information or update any pom.xml files, but just build entirely in offline mode.
I was trying to run this command and it was failing with the error the original poster mentioned:
mvn site
To do this build offline instead, execute the following commands:
# Download the dependencies for the target
mvn dependency:go-offline site
# Build the target offline
mvn --offline site
Then the output got correctly generated to the target/site directory like I expected.
It's not ideal if you own the project or part of the project, but for a case like mine where I owned none of it, it was the perfect option.
The previous answers didn't work for me.
But Mark's one, here, solved the issue I had: https://stackoverflow.com/a/57429991/5056068
Etienne