• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • How to install bnd
      • Guided Tour
      • Guided Tour Workspace & Projects
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Introduction
      • Concepts
      • Best practices
    • Build and Development
      • Project Setup
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • -runenv PROPERTIES
    Project

    Specify a JDB port on invocation when launched outside a debugger so the debugger can attach later.

    public Map<String,String> getRunEnv() {
    	String runenv = project.getProperty(Constants.RUNENV);
    	if ( runenv != null) {
    		return OSGiHeader.parseProperties(runenv);
    	}		
    	return Collections.emptyMap();
    }
    
    public int launch() throws Exception {
    	prepare();
    	java = new Command();
    	
    	
    	//
    	// Handle the environment
    	//
    	
    	Map<String,String> env = getRunEnv();
    	for ( Map.Entry<String,String> e:env.entrySet()) {
    		java.var(e.getKey(), e.getValue());
    	}
    	
    	java.add(project.getProperty("java", "java"));
    	String javaagent = project.getProperty(Constants.JAVAAGENT);
    	if (Processor.isTrue(javaagent)) {
    		for (String agent : agents) {
    			java.add("-javaagent:" + agent);
    		}
    	}
    
    	String jdb = getRunJdb();
    	if (jdb != null) {
    		int port = 1044;
    		try {
    			port = Integer.parseInt(project.getProperty(Constants.RUNJDB));
    		}
    		catch (Exception e) {
    			// ok, value can also be ok, or on, or true
    		}
    		String suspend = port > 0 ? "y" : "n";
    
    		java.add("-Xrunjdwp:server=y,transport=dt_socket,address=" + Math.abs(port) + ",suspend=" + suspend);
    	}
    	
    	java.add("-cp");
    	java.add(Processor.join(getClasspath(), File.pathSeparator));
    	java.addAll(getRunVM());
    	java.add(getMainTypeName());
    	java.addAll(getRunProgramArgs());
    	if (timeout != 0)
    		java.setTimeout(timeout + 1000, TimeUnit.MILLISECONDS);
    
    	File cwd = getCwd();
    	if (cwd != null)
    		java.setCwd(cwd);
    
    	project.trace("cmd line %s", java);
    	try {
    		int result = java.execute(System.in, System.err, System.err);
    		if (result == Integer.MIN_VALUE)
    			return TIMEDOUT;
    		reportResult(result);
    		return result;
    	}
    	finally {
    		cleanup();
    		listeners.clear();
    	}
    }
    
Search
    • Home