Archive
Speedup Release for Multiprojects with Maven
In huge multi-module-projects the maven-release-process might have a long running time because there is a lot of site-content to generate and to deployed (Of course this depends on the used report-plugins, i.e. javadoc, findbugs,pmd, dashboard etc.)
I noticed that the upload of the generated javadoc etc. uses a big amount of the deployment time. So how we can speedup this part of the deployment?
We can deploy the generated site in a local directory and after the successful release we can upload the whole directory to the server, i.e. zip the content and unpack on the server, or use a smb-shared-directory … then the site-upload is much faster than with site:deploy and webdav.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<distributionManagement>
<site>
<id>site</id>
<url>${site.distribution.url}/</url>
</site>
<distributionManagement>
<profiles>
<profile>
<id>release</id>
<properties>
<site.distribution.url>file://D:/SITE-RELEASE/</site.distribution.url>
<site.url>http://site-server/releases/</site.url>
</properties>
</profile>
</profiles>
<properties>
<site.url>http://site-server/snapshots/</site.url>
<site.distribution.url>dav:${site.url}</site.distribution.url>
</properties>
</project>
Try it
Show TeamCity Buildstatus in Maven Projectsite
Today i will show you a little hack for TeamCity and Maven. At the end you will be able to show the last (live!) buildstatus of your artifact on the generate project-site.
Lets define a new menu-item “status” in our project-site-descriptor (src/site/site.xml):
... <menu name="Overview" inherit="top"> <item name="Introduction" href="index.html" /> <item name="Status" href="status.html" /> </menu> ...
Hint: you can do this in your parent-project, so all subproject will inherit this menu.
Now we must define the status.xml (src/site/xdoc/status.xml):
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Buildstatus</title>
</properties>
<body>
<section name="Status">
<div id="statuswidget"/>
</section>
<script type="text/javascript">
<![CDATA[
//
// url to the team-city-server
// define HOST, PORT and BUILDID
//
var url = 'http://HOST:PORT/externalStatus.html'
+ '?buildTypeId=BUILDID'
+ unescape( '%26' ) // "hide" amp
+ 'withCss=true';
var container = document.getElementById('statuswidget');
var iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '500px';
iframe.style.border = 'none';
container.appendChild(iframe);
iframe.doc = null;
if(iframe.contentDocument)
iframe.doc = iframe.contentDocument;
else if(iframe.contentWindow)
iframe.doc = iframe.contentWindow.document;
else if(iframe.document)
iframe.doc = iframe.document;
iframe.doc.open();
iframe.doc.close();
iframe.doc.location.href=url;
]]>
</script>
</body>
</document>
Insert HOST and PORT. The BUILDID is the number of the build-configuration:
Hint: The width of the iframe should be 100% but you can customize the height – so if you later click on the status-element you can show teamcity directly in you projectsite … cool
Activate the status-widget for your build-configuration:
Build the site:
mvn clean site-deploy
Now you have a new menu-item, click and you will see the TeamCity status for your artifact.
The implementation details …
The “normal” way to display the build-status (see TeamCity documentation) is shown here:
<script type="text/javascript" src="<path_to_server>/externalStatus.html?js=1&amp;buildTypeId=BUILDID"> </script>
But it’s not possible to insert this code in maven’s xdoc-format (there is no javascript-tag allowed!).
So i found a solution to insert the teamcity-url into a dynamic created iframe. The second trick is to encode the “&” in the url (unescape(‘%26′)).
Try it!



Recent Comments