Skip to content

Commit 07fff56

Browse files
author
mparvu
committed
* Prepare for release 2.2.6
* Fixed jar building problems * Start Application now returns the remote port * Fixed custom argument to Java Agent
1 parent d89bd18 commit 07fff56

File tree

6 files changed

+59
-98
lines changed

6 files changed

+59
-98
lines changed

pom.xml

Lines changed: 39 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</parent>
99
<groupId>org.robotframework</groupId>
1010
<artifactId>remoteswinglibrary</artifactId>
11-
<version>2.2.5</version>
11+
<version>2.2.6</version>
1212
<packaging>jar</packaging>
1313

1414
<name>robotframework-remoteswinglibrary</name>
@@ -63,6 +63,9 @@
6363
<configuration>
6464
<source>8</source>
6565
<target>8</target>
66+
<compilerArgs>
67+
<arg>-Xlint:unchecked</arg>
68+
</compilerArgs>
6669
</configuration>
6770
</plugin>
6871
<plugin>
@@ -89,73 +92,48 @@
8992
</execution>
9093
</executions>
9194
</plugin>
92-
<plugin>
93-
<groupId>org.sonatype.plugins</groupId>
94-
<artifactId>jarjar-maven-plugin</artifactId>
95-
<version>1.9</version>
96-
<executions>
97-
<execution>
98-
<phase>package</phase>
99-
<goals>
100-
<goal>jarjar</goal>
101-
</goals>
102-
<configuration>
103-
<output>${project.build.directory}/jarjarred</output>
104-
<overwrite>true</overwrite>
105-
<includes>
106-
<include>abbot:abbot</include>
107-
<include>com.thoughtworks.paranamer:paranamer</include>
108-
<include>commons-collections:commons-collections</include>
109-
<include>commons-logging:commons-logging</include>
110-
<include>gnu-regexp:gnu-regexp</include>
111-
<include>javax.servlet:javax.servlet-api</include>
112-
<include>junit:junit</include>
113-
<include>org.apache.commons:commons-collections</include>
114-
<include>org.apache.commons:commons-lang3</include>
115-
<include>org.apache.commons:commons-text</include>
116-
<include>org.apache.logging.log4j:log4j-api</include>
117-
<include>org.apache.logging.log4j:log4j-core</include>
118-
<include>org.apache.logging.log4j:log4j-jcl</include>
119-
<include>org.apache.ws.commons.util:ws-commons-util</include>
120-
<include>org.apache.xmlrpc:xmlrpc-common</include>
121-
<include>org.apache.xmlrpc:xmlrpc-server</include>
122-
<include>org.eclipse.jetty:jetty-http</include>
123-
<include>org.eclipse.jetty:jetty-io</include>
124-
<include>org.eclipse.jetty:jetty-security</include>
125-
<include>org.eclipse.jetty:jetty-server</include>
126-
<include>org.eclipse.jetty:jetty-servlet</include>
127-
<include>org.eclipse.jetty:jetty-util</include>
128-
<include>org.jretrofit:jretrofit</include>
129-
<include>org.netbeans:jemmy</include>
130-
<include>org.robotframework:javalib-core</include>
131-
<include>org.robotframework:jrobotremoteserver</include>
132-
<include>org.robotframework:swinglibrary</include>
133-
<include>xml-apis:xml-apis</include>
134-
</includes>
135-
<rules>
136-
</rules>
137-
</configuration>
138-
</execution>
139-
</executions>
140-
</plugin>
14195
<plugin>
14296
<groupId>org.apache.maven.plugins</groupId>
143-
<artifactId>maven-jar-plugin</artifactId>
144-
<version>2.4</version>
97+
<artifactId>maven-shade-plugin</artifactId>
98+
<version>3.2.4</version>
14599
<executions>
146100
<execution>
147101
<phase>package</phase>
148102
<goals>
149-
<goal>jar</goal>
103+
<goal>shade</goal>
150104
</goals>
151105
<configuration>
152-
<classesDirectory>${project.build.directory}/jarjarred</classesDirectory>
153-
<archive>
154-
<manifestEntries>
155-
<Premain-Class>org.robotframework.remoteswinglibrary.agent.JavaAgent</Premain-Class>
156-
<Main-Class>org.robotframework.remoteswinglibrary.agent.JavaAgent</Main-Class>
157-
</manifestEntries>
158-
</archive>
106+
<filters>
107+
<filter>
108+
<artifact>*:*</artifact>
109+
<excludes>
110+
<exclude>com/**</exclude>
111+
<exclude>Log4j-*</exclude>
112+
<exclude>*.class</exclude>
113+
<exclude>META-INF/**</exclude>
114+
<exclude>about.html</exclude>
115+
</excludes>
116+
</filter>
117+
</filters>
118+
<transformers>
119+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
120+
<manifestEntries>
121+
<Premain-Class>org.robotframework.remoteswinglibrary.agent.JavaAgent</Premain-Class>
122+
<Main-Class>org.robotframework.remoteswinglibrary.agent.JavaAgent</Main-Class>
123+
</manifestEntries>
124+
</transformer>
125+
</transformers>
126+
<relocations>
127+
<relocation>
128+
<pattern>javax.servlet.</pattern>
129+
<shadedPattern>org.robotframework.remoteswinglibrary.javax.servlet.</shadedPattern>
130+
</relocation>
131+
<relocation>
132+
<pattern>org.apache.</pattern>
133+
<shadedPattern>org.robotframework.remoteswinglibrary.apache.</shadedPattern>
134+
</relocation>
135+
</relocations>
136+
<createDependencyReducedPom>false</createDependencyReducedPom>
159137
</configuration>
160138
</execution>
161139
</executions>
@@ -224,6 +202,7 @@
224202
<arguments>
225203
<argument>target/classes/swinglibrary.py</argument>
226204
</arguments>
205+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
227206
</configuration>
228207
</execution>
229208
</executions>

src/main/java/org/robotframework/remoteswinglibrary/agent/FindAppContextWithWindow.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,25 @@ class FindAppContextWithWindow implements Runnable {
3535
boolean closeSecurityDialogs;
3636
RobotConnection robotConnection;
3737
String dirPath;
38+
String custom;
3839

3940
HashMap<Dialog, SecurityDialogAccepter> dialogs = new HashMap<Dialog, SecurityDialogAccepter>();
4041

41-
public FindAppContextWithWindow(String host, int port, int apport, boolean debug, boolean closeSecurityDialogs, String dirPath) {
42+
public FindAppContextWithWindow(String host, int port, int apport, boolean debug, boolean closeSecurityDialogs, String dirPath, String custom) {
4243
this.host = host;
4344
this.port = port;
4445
this.apport = apport;
4546
this.debug = debug;
4647
this.closeSecurityDialogs = closeSecurityDialogs;
4748
this.dirPath = dirPath;
49+
this.custom = custom;
4850
}
4951

5052
public void run() {
5153
try {
5254
robotConnection = new RobotConnection(host, port);
5355
AppContext appContext = getAppContextWithWindow();
54-
sun.awt.SunToolkit.invokeLaterOnAppContext(appContext, new ServerThread(robotConnection, apport, debug));
56+
sun.awt.SunToolkit.invokeLaterOnAppContext(appContext, new ServerThread(robotConnection, apport, debug, custom));
5557
} catch (Exception e) {
5658
if (debug) {
5759
e.printStackTrace();

src/main/java/org/robotframework/remoteswinglibrary/agent/JavaAgent.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation
3232
int port = getRemoteSwingLibraryPort(args[1]);
3333
boolean debug = Arrays.asList(args).contains("DEBUG");
3434
boolean closeSecurityDialogs = Arrays.asList(args).contains("CLOSE_SECURITY_DIALOGS");
35+
String custom = null;
3536
String dirPath = null;
3637
if (Arrays.asList(args).contains("DIR_PATH")){
3738
if (System.getProperty("os.name").contains("Windows"))
@@ -43,8 +44,11 @@ public static void premain(String agentArgument, Instrumentation instrumentation
4344
for (String arg: args)
4445
if (arg.startsWith("APPORT="))
4546
apport = Integer.parseInt(arg.split("=")[1]);
47+
else if (arg.startsWith("CUSTOM=")) {
48+
custom = arg.split("=")[1];
49+
}
4650
try {
47-
Thread findAppContext = new Thread(new FindAppContextWithWindow(host, port, apport, debug, closeSecurityDialogs, dirPath));
51+
Thread findAppContext = new Thread(new FindAppContextWithWindow(host, port, apport, debug, closeSecurityDialogs, dirPath, custom));
4852
findAppContext.setDaemon(true);
4953
findAppContext.start();
5054
// Sleep to ensure that findAppContext daemon thread is kept alive until the

src/main/java/org/robotframework/remoteswinglibrary/agent/ServerThread.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.robotframework.remoteswinglibrary.agent;
1818

1919
import org.robotframework.remoteserver.RemoteServer;
20-
import org.robotframework.remoteswinglibrary.remote.DaemonRemoteServer;
2120
import org.robotframework.swing.SwingLibrary;
2221

2322
import java.io.IOException;
@@ -27,24 +26,26 @@
2726
public class ServerThread implements Runnable {
2827
int apport;
2928
boolean debug;
29+
String custom;
3030
RobotConnection robotConnection;
3131

32-
public ServerThread(RobotConnection robotConnection, int apport, boolean debug) {
32+
public ServerThread(RobotConnection robotConnection, int apport, boolean debug, String custom) {
3333
this.robotConnection = robotConnection;
3434
this.apport = apport;
3535
this.debug = debug;
36+
this.custom = custom;
3637
}
3738

3839
public void run() {
3940
try {
40-
RemoteServer server = new DaemonRemoteServer(apport);
41+
RemoteServer server = new RemoteServer(apport);
4142
SwingLibrary swingLibrary = SwingLibrary.instance == null ? new SwingLibrary() : SwingLibrary.instance;
4243
server.putLibrary("/RPC2", swingLibrary);
4344
server.putLibrary("/services", new ServicesLibrary());
4445
server.setAllowStop(true);
4546
server.start();
4647
Integer actualPort = server.getLocalPort();
47-
notifyPort(actualPort);
48+
notifyPort(actualPort, custom);
4849
} catch (Exception e) {
4950
if (debug) {
5051
e.printStackTrace();
@@ -54,9 +55,9 @@ public void run() {
5455
}
5556
}
5657

57-
private void notifyPort(final Integer portToNotify) throws IOException {
58+
private void notifyPort(final Integer portToNotify, String custom) throws IOException {
5859
robotConnection.connect();
59-
robotConnection.send("PORT:" + portToNotify.toString() + ":" + getName());
60+
robotConnection.send("PORT:" + portToNotify.toString() + ":" + getName() + ":" + custom);
6061
robotConnection.close();
6162
}
6263

src/main/java/org/robotframework/remoteswinglibrary/remote/DaemonRemoteServer.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/python/RemoteSwingLibrary.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _tobool(value):
115115
return str(value).lower() in ("true", "1", "yes")
116116

117117

118-
__version__ = '2.2.5'
118+
__version__ = '2.2.6'
119119

120120

121121
class RemoteSwingLibrary(object):
@@ -412,6 +412,8 @@ def start_application(self, alias, command, timeout=60, name_contains="", close_
412412
``stderr`` is the path where to write stderr to.
413413
414414
``custom`` is a customizable field that can be set when starting the Java agent.
415+
416+
This keyword returns the remote port of the connection.
415417
"""
416418
close_security_dialogs = _tobool(close_security_dialogs)
417419

@@ -456,6 +458,7 @@ def start_application(self, alias, command, timeout=60, name_contains="", close_
456458
raise
457459
finally:
458460
self._remove_policy_file()
461+
return RemoteSwingLibrary.PORT
459462

460463
def _output(self, filename):
461464
return os.path.join(self._output_dir, filename)

0 commit comments

Comments
 (0)