ant scp task

 Eclipse, IT, Java  Kommentare deaktiviert für ant scp task
Feb 142016
 

Ant SCP Task:

<?xml version="1.0" encoding="UTF-8"?>

<project name="MyProject" default="copyToUnix" basedir=".">

	<target name="copyToUnix">
		<scp todir="user@vserver:/var/www/myFolder/" keyfile="/Users/dummy/.ssh/id_rsa">
			<fileset dir="WebContent">
				<include name="*.php" />
			</fileset>
		</scp>
	</target>
	
</project>

You need an additional jar file for ant scp task: http://www.jcraft.com/jsch/index.html

Windchill: Using custom actions in profiles

 IT, Java  Kommentare deaktiviert für Windchill: Using custom actions in profiles
Jan 272015
 

Windchills profile mechanism allows the administrator to show or hide UI components such as attributes and actions. Profiles can be defined on site or organisation level. The Product or Library manager is able to override the profiles from the team page on the product / library by using the Configure Actions for Roles mechanism.

The custom actions (defined in Windchill\codebase\config\actions\customActions.xml) are not directly visible when creating or changing a profile. To make them visible (and selectable) inside the profiles, you have to add them to the config file for profiles (Windchill\codebase\roleaccessprefs.xml)

Example customActions.xml:

<listofactions>
	<objecttype name="object" class="java.lang.Object" resourceBundle="com.pbo.resource.NavigationRB">
		<action name="testPhilipp">
			<command url="netmarkets/jsp/test.jsp" windowType="popup"/>
		</action>
	</objecttype>
</listofactions>

To make the action „testPhilipp“ available in the profiles, you have to add an <uic> element in the roleaccessprefs.xml file:

<product labelId="productLabel">
	 <!-- Adding the action "testPhilipp" to the product level -->
	  <uic name="testPhilipp" order="1010" enabled="true" defaultAll="false" defaultManager="true" 
	          defaultGuest="false" managerEnabled="true" guestEnabled="false"/>

The value of the attribte name in the action-tag must be equal to the name attribute in the uic tag. It is also possible to add a uicomponent attribute when defining your custom action and use its value to reference the action in the roleaccessprefs.xml:

<listofactions>
	<objecttype name="object" class="java.lang.Object" resourceBundle="com.pbo.resource.NavigationRB">
		<action name="testPhilipp" uicomponent="myUicName">
			<command url="netmarkets/jsp/test.jsp" windowType="popup"/>
		</action>
	</objecttype>
</listofactions>

roleaccessprefs.xml:

<product labelId="productLabel">
	 <!-- Adding the action "testPhilipp" to the product level -->
	  <uic name="myUicName" order="1010" enabled="true" defaultAll="false" defaultManager="true" 
	          defaultGuest="false" managerEnabled="true" guestEnabled="false"/>

 

Now you can restart Windchill and you will see your action „testPhilipp“ when changing or creating a profile. To show a more detailed (and maybe localized) name you can use ResourceBundles. Add an entry to the roleAccessResource.rbInfo file.

Javadoc examples: Comments and usage in Eclipse

 IT, Java  Kommentare deaktiviert für Javadoc examples: Comments and usage in Eclipse
Jul 052014
 

Javadoc for java Packages

It is also possible to add a comment / short description of a package. This can be done using a file called package-info.jave inside the package. When using eclipse, you can check the option „Create package-info.java“:

Create package-info.java

Create package-info.java

Change the default comment to something like this. Important: Use only one sentence and don’t forget the point at the end.

Change comment to something like this

Change comment to something like this

This will result in:

Package description

Package description

 

Using Javadoc for classes

To describe classes, you should start with a single sentence at the beginning. This sentence is used on the overview page of a package where all classes are listed (with a short description which is this sentence). Dont forget the point at the end.

The next paragraph contains a more detailed description that will be shown on the detail page of the class. Here you can use some html tags. In this case I used a list. After that you can add some javadoc parameter.

package com.pbo.Game;

/**
 * This Class represents the main class of the F1 Betting Game.
 * <p>
 * This Class handles all the database connection stuff, it creates the GUI
 * and it contains all the rules. See method: displayRules.
 * <br>
 * It also Starts the database connection, create instances of users and rankings and so on.
 * <ul>
 * 		<li>You can also</li>
 * 		<li>use a list</li>
 * 		<li>here in the description of the class</li>
 * </ul>
 * 
 * @author philipp
 * @version 0.1
 */
public class GameStarter {
    // your class here
}

Result of that comment:

Package Overview shows all classes with a short description

Package Overview shows all classes with a short description

 

Overview of one class

Overview of one class

 

Javadoc for methods

To describe methods you should begin with a short description in a single sentence. This sentence will be displayed in the method-overview of the class. After that sentence you should describe your method more detailed. This will be the description of the method. There you can use html-tags like linebreak <br> , lists <ul> , <li>, and more. You can create paragraphs by using the <p> tag. See the example below:

/**
 * This method displays all the rules for the game.
 * <p>
 * Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
 * eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
 * voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
 * clita kasd. <br>
 * Nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
 * sed diam voluptua.
 * <p>
 * Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
 * eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
 * voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
 * clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit.
 * <p>
 * Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
 * eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
 * voluptua dolor sit amet.
 * <ul>
 * <li>Rule 1 ...</li>
 * <li>Rule 2 ...</li>
 * <li>Rule 3 ...</li>
 * </ul>
 * 
 * @param userName
 *            The username of the Player
 * 
 * @param difficulty
 *            The difficulty of the game, from 1 to 10, where 1 is simple
 *            and 10 means strong
 * @return the status code after the game has finished. 1=won, 2=lost
 */
public int displayRules(String userName, int difficulty) {
	// your code goes here
	return 2;
}

Results in:

Javadoc Method Overview

Javadoc Method Overview

and:

Javadoc Method Details

Javadoc Method Details

 

Using javadoc ant task

 IT, Java  Kommentare deaktiviert für Using javadoc ant task
Jul 052014
 

Javadoc is a very powerful and helpful tool of java. You can document your source, as well as insert installation or configuration information. The usage of javadoc in ant is very comfortable, setup once, use every build.
Here is an example of a simple javadoc ant task:

<target name="createJavadoc">
	<!-- this classpath is only necessary when using 3rd party libs or annotation processing -->
	<path id="annotations.classpath">
		<fileset dir=".">
			<include name="lib/**/*.jar" />
		</fileset>
	</path>
	
	<!-- creata javaDoc for package com.pbo.* inside src folder. Store javadoc in folder javaDoc -->
	<javadoc packagenames="com.pbo.*" 
		sourcepath="src" 
		defaultexcludes="yes" 
		destdir="javaDoc" 
		author="true" 
		version="true" 
		use="true" 
		classpathref="annotations.classpath" 
		splitindex="true" 
		nonavbar="true"
		windowtitle="F1 Betting Game : Documentation">
			<doctitle>
				<![CDATA[<h1>F1 Betting Game</h1>]]>
			</doctitle>
		<bottom>
			<![CDATA[Copyright © Philipp Boss.<br/> <b>Please contact Philipp Boss in case of questions</b>]]>
		</bottom>
	</javadoc>
</target>

This task creates the javadoc for the package com.pbo.* inside the src-folder and stores the created doc files inside the javaDoc folder.

The parameter nonavbar hides the navigation bar in the created doc files. For my opinion this generates more „clean“ javadoc pages. The windowtitle is the title of the html-page (what you can see in your browser tab), the doctitle is the one beeing displayed inside the web page. The value of bottom is beeing displayed at the end of the page.

Here you can see the created page:

Javadoc created Webpage

Javadoc created Webpage

Using SVN in Ant

 IT, Java  Kommentare deaktiviert für Using SVN in Ant
Jun 062014
 

In my current ant-script I need to get the SVN revision to insert that info into the deployment-package.

There are three commands available.

svn info is the first one:

D:\Projekte\workspace\myCode >svn info
Pfad: .
URL: https://svn.xxx.xx/abc/def/
Basis des Projektarchivs: https://svn.svn.xxx.xx/abc/def/
UUID des Projektarchivs: hidden
Revision: 12955
Knotentyp: Verzeichnis
Plan: normal
Letzter Autor: pbo
Letzte geänderte Rev: 12859
Letztes Änderungsdatum: 2014-05-21 10:10:14 +0200 (Mi, 21. Mai 2014)

The Revision is the current Revision of the Repository (that means, that if you checkin some changes now, you will get the Revsion 12955+1). The „Letzte geänderte Rev“ (last changed revision) ist the one which was assigned on the last commit/checkin. This is the revision of code that is checked in on the repository. This format is diffiult to handle in ant, that’s the reason why I present another solution:

svnversion

svnversion without any parameter will display the revsion of the repositry:

D:\Projekte\workspace\myCode>svnversion
12955M

„M“ means, that the local code has changed (modified). If you need the latest commited revision, you can append the parameter „-c“:

D:\Projekte\workspace\myCode>svnversion -c
11789:12859M

The firs number is the revision that was assigned during first checkin of this project / path. The second number is the revision of the latest commit. There is also a third solution:

svn log

With the svn command with the log parameter you are able to see the commit-messages. With some parameters you can display only the latest commit, including revsion number, date and author:

D:\Projekte\workspace\myCode>svn log -r COMMITTED -q
------------------------------------------------------------------------
12859| pbo | 2014-05-21 10:10:14 +0200 (Mi, 21. Mai 2014)
------------------------------------------------------------------------

How to use this in ant:

<target name="svnversion">
	<exec executable="svnversion" outputproperty="svnversion" />
	<echo message="SVN Version: ${svnversion}" />
</target>

Results in:

Buildfile: D:\Projekte\workspace\myCode\svn.xml
svnversion:
     [echo] SVN Version: 129555M
BUILD SUCCESSFUL
Total time: 834 milliseconds

 

<target name="svnLog">
	<exec executable="svn" outputproperty="lastCommittedRevision">
		<arg value="log" />
		<arg value="-r" />
		<arg value="COMMITTED" />
		<arg value="-q" />
	</exec>
	<echo message="lastCommittedRevision = " />
	<echo message="${lastCommittedRevision}" />
</target>

Results in:

Buildfile: D:\Projekte\workspace\myCode\svn.xml
svnLog:
     [echo] lastCommittedRevision = 
     [echo] ------------------------------------------------------------------------
     [echo] r12859 | pbo | 2014-05-21 10:10:14 +0200 (Mi, 21. Mai 2014)
     [echo] ------------------------------------------------------------------------
BUILD SUCCESSFUL
Total time: 1 second