Skip to content

Commit

Permalink
MWEBSTART-11 - Support generation of JNLP components
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/tiste/MOJOHAUS-TO-GIT/SVN-MOJO-WIP/trunk/mojo/webstart@19254 52ab4f32-60fc-0310-b215-8acea882cd1b
  • Loading branch information
Tony Chemit committed Jan 12, 2014
1 parent 084ff99 commit 6c84adb
Show file tree
Hide file tree
Showing 15 changed files with 485 additions and 56 deletions.
25 changes: 25 additions & 0 deletions webstart-maven-plugin/src/it/MWEBSTART-11/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

To check MWEBSTART-11 works fine. (see https://jira.codehaus.org/browse/MWEBSTART-11).

We will generate here three different jnlp files :
- application
- component
- installer
1 change: 1 addition & 0 deletions webstart-maven-plugin/src/it/MWEBSTART-11/goals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
clean package
111 changes: 111 additions & 0 deletions webstart-maven-plugin/src/it/MWEBSTART-11/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<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>

<groupId>org.codehaus.mojo</groupId>
<artifactId>MWEBSTART-11</artifactId>
<version>1.0</version>
<name>Webstart MWEBSTART-11</name>
<description>Test Case for MWEBSTART-11.</description>

<organization>
<name>CodeHaus</name>
</organization>

<url>https://jira.codehaus.org/browse/MWEBSTART-11</url>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>generate-application</id>
<goals>
<goal>jnlp-single</goal>
</goals>
<phase>package</phase>
<configuration>
<jnlp>
<type>application</type>
<outputFile>test-application.jnlp</outputFile>
<mainClass>org.codehaus.mojo.webstart.Main</mainClass>
</jnlp>
</configuration>
</execution>
<execution>
<id>generate-component</id>
<goals>
<goal>jnlp-single</goal>
</goals>
<phase>package</phase>
<configuration>
<jnlp>
<type>component</type>
<outputFile>test-component.jnlp</outputFile>
<!-- will be removed -->
<mainClass>org.codehaus.mojo.webstart.Main</mainClass>
</jnlp>
</configuration>
</execution>
<execution>
<id>generate-installer</id>
<goals>
<goal>jnlp-single</goal>
</goals>
<phase>package</phase>
<configuration>
<jnlp>
<type>installer</type>
<outputFile>test-installer.jnlp</outputFile>
<!-- will be removed -->
<mainClass>org.codehaus.mojo.webstart.Main</mainClass>
</jnlp>
</configuration>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<makeArchive>false</makeArchive>
<outputJarVersions>true</outputJarVersions>

<!-- SIGNING -->
<!-- defining this will automatically sign the jar and its dependencies -->
<sign>
<keystore>${project.build.directory}/keystore</keystore>
<keypass>m2m2m2</keypass>
<storepass>m2m2m2</storepass>
<alias>alias</alias>
<validity>180</validity>

<dnameCn>www.example.com</dnameCn>
<dnameOu>None</dnameOu>
<dnameO>ExampleOrg</dnameO>
<dnameL>Seattle</dnameL>
<dnameSt>Washington</dnameSt>
<dnameC>US</dnameC>

<verify>true</verify>

<keystoreConfig>
<delete>true</delete>
<gen>true</gen>
</keystoreConfig>
</sign>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<!-- has class with main method -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.codehaus.mojo.webstart;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

public class Main
{

public static void main( String[] args )
{

}
}
101 changes: 101 additions & 0 deletions webstart-maven-plugin/src/it/MWEBSTART-11/validate.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
Required result :
target/it/MWEBSTART-11/target/
├── keystore
└── jnlp
├── commons-cli-commons-1.1.jar
├── MWEBSTART-11-1.0.jar
├── test-application.jnlp
├── test-applet.jnlp
├── test-component.jnlp
└── test-installer.jnlp
*/

def assertExistsDirectory( file )
{
if ( !file.exists() || !file.isDirectory() )
{
println( file.getAbsolutePath() + " file is missing or is not a directory." )
return false
}
return true
}

def assertExistsFile( file )
{
if ( !file.exists() || file.isDirectory() )
{
println( file.getAbsolutePath() + " file is missing or a directory." )
return false
}
return true
}

def assertContains( content, expected )
{
if ( !content.contains(expected) )
{
println( expected + " was not found in \n :" + content )
return false
}
return true
}

String[] expectedJnlpFiles = ["test-application.jnlp", "test-component.jnlp", "test-installer.jnlp"]
String[] expectedJnlpLibFiles = ["commons-cli__V1.1.jar", "MWEBSTART-11__V1.0.jar"]

File target = new File( basedir, "target" )
assert assertExistsDirectory( target )

File jnlpDirectory = new File( target, "jnlp" )
assert assertExistsDirectory( jnlpDirectory )

expectedJnlpFiles.each {
assert assertExistsFile( new File( jnlpDirectory, it ) )
}

File jnlpLib = jnlpDirectory;

expectedJnlpLibFiles.each {
assert assertExistsFile( new File( jnlpLib, it ) )
}

assert jnlpLib.list().length == expectedJnlpLibFiles.length + expectedJnlpFiles.length // jar + jnlp files

File applicationJnlpFile = new File( jnlpDirectory, "test-application.jnlp" )
assert assertContains( applicationJnlpFile.text, "<jar href=\"commons-cli.jar\" version=\"1.1\"/>" )
assert assertContains( applicationJnlpFile.text, "<jar href=\"MWEBSTART-11.jar\" version=\"1.0\" main=\"true\"/>" )
assert assertContains( applicationJnlpFile.text, "<application-desc main-class=\"org.codehaus.mojo.webstart.Main\"/>" )

File componentJnlpFile = new File( jnlpDirectory, "test-component.jnlp" )
assert assertContains( componentJnlpFile .text, "<jar href=\"commons-cli.jar\" version=\"1.1\"/>" )
assert assertContains( componentJnlpFile.text, "<jar href=\"MWEBSTART-11.jar\" version=\"1.0\"/>" )
assert assertContains( componentJnlpFile .text, "<component-desc/>" )

File installerJnlpFile = new File( jnlpDirectory, "test-installer.jnlp" )
assert assertContains( installerJnlpFile .text, "<jar href=\"commons-cli.jar\" version=\"1.1\"/>" )
assert assertContains( installerJnlpFile.text, "<jar href=\"MWEBSTART-11.jar\" version=\"1.0\"/>" )
assert assertContains( installerJnlpFile .text, "<installer-desc/>" )


return true
Original file line number Diff line number Diff line change
Expand Up @@ -739,22 +739,17 @@ protected void pack200Jars( File directory, FileFilter filter )
}
}

protected URL findDefaultJnlpTemplateURL()
protected URL findDefaultTemplateURL(JnlpFileType fileType)
{
return getClass().getClassLoader().getResource( "default-jnlp-template.vm" );
}

protected URL findDefaultJnlpExtensionTemplateURL()
{
return getClass().getClassLoader().getResource( "default-jnlp-extension-template.vm" );
return getClass().getClassLoader().getResource( fileType.getDefaultTemplateName() );
}

/**
* @return something of the form jar:file:..../webstart-maven-plugin-.....jar!/
*/
protected String getWebstartJarURLForVelocity()
{
String url = findDefaultJnlpTemplateURL().toString();
String url = findDefaultTemplateURL(JnlpFileType.application).toString();
return url.substring( 0, url.indexOf( "!" ) + 2 );
}

Expand Down
Loading

0 comments on commit 6c84adb

Please sign in to comment.