Skip to content

Commit

Permalink
Inject MAVEN_OPTS environment variable along with JAVA_OPTS to container
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhenii Voevodin committed Feb 14, 2017
1 parent e4099b8 commit 9370327
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 5 deletions.
4 changes: 4 additions & 0 deletions assembly/assembly-wsmaster-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-machine-ext-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-maven-wsmaster</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-openshift-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ che.workspace.https_proxy=https.proxy
che.workspace.no_proxy=no_proxy
che.workspace.auto_snapshot=workspace.runtime.auto_snapshot
che.workspace.auto_restore=workspace.runtime.auto_restore
che.workspace.java_opts=che.machine.java_opts
che.workspace.java.options=che.machine.java_opts,che.workspace.java_opts
che.workspace.volume=machine.server.extra.volume
che.workspace.ssh_connection_timeout_ms=machine.ssh.connection_timeout_ms
che.workspace.terminal_linux_amd64=machine.server.terminal.path_to_archive.linux_amd64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ che.workspace.pool.cores_multiplier=2


# Java command line options used to start Che agent in workspace runtime
che.workspace.java_opts=-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom
che.workspace.java.options=-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom

# Maven command line options will be exported as value of MAVEN_OPTS
# environment variable in workspace dev-machine.
# If the value is not set then the value provided by 'che.workspace.java.options' property is used
che.workspace.maven.options=NULL

# Folder that will be a volume mount from your host into your workspace.
che.workspace.volume=
Expand Down
9 changes: 8 additions & 1 deletion dockerfiles/init/manifests/che.env
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@
# agents within the workspace when it boots, then the workspace will not be started.
#CHE_MACHINE_WS_AGENT_MAX_START_TIME_MS=300000


# Workspace Agent Java Options
# Java command line options to be added to JVM's that run agents within workspaces.
#CHE_WORKSPACE_JAVA_OPTIONS=-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom

# Workspace Agent Maven Options
# Maven command line options added to JVM's that run agents within workspaces.
# Defaults to the same value of CHE_WORKSPACE_JAVA_OPTIONS.
#CHE_WORKSPACE_MAVEN_OPTIONS=NULL

########################################################################################
##### #####
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/init/modules/che/templates/che.env.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ JAVA_NO_PROXY=-Dhttp.nonProxyHosts='<%= @che_no_proxy.gsub(/^https?\:\/\//, '').
JAVA_OPTS=-Xms512m -server -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark <% if ! @che_http_proxy.empty? or ! @che_https_proxy.empty? -%>$JAVA_HTTP_PROXY_SET<% end -%> <% if ! @che_http_proxy.empty? -%>$JAVA_HTTP_PROXY_HOST $JAVA_HTTP_PROXY_PORT<% end -%> <% if ! @che_https_proxy.empty? -%>$JAVA_HTTPS_PROXY_HOST $JAVA_HTTPS_PROXY_PORT<% end -%><%- if ! @che_no_proxy.empty? -%> $JAVA_NO_PROXY<% end -%><% if @che_http_proxy.include? '@' -%> $JAVA_HTTP_USER_NAME $JAVA_HTTP_USER_PASSWORD<% end -%><% if @che_https_proxy.include? '@' -%> $JAVA_HTTPS_USER_NAME $JAVA_HTTPS_USER_PASSWORD<% end %>

# java opts for ws agent
CHE_WORKSPACE_JAVA__OPTS=-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom <% if ! @http_proxy_for_che_workspaces.empty? or ! @https_proxy_for_che_workspaces.empty? -%>-Dhttp.proxySet=true<% end -%><% if ! @http_proxy_for_che_workspaces.empty? -%><% if ! @http_proxy_for_che_workspaces.empty? and @http_proxy_for_che_workspaces.include? '@' -%> -Dhttp.proxyUser=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttp.proxyPassword=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @https_proxy_for_che_workspaces.empty? -%><% if @https_proxy_for_che_workspaces.include? '@' -%> -Dhttps.proxyUser=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttps.proxyPassword=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @che_no_proxy.empty? -%> -Dhttp.nonProxyHosts='<%= @no_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').gsub(',','|') %>|'<% end -%>
CHE_WORKSPACE_JAVA_OPTIONS=-Xms256m -Xmx2048m -Djava.security.egd=file:/dev/./urandom <% if ! @http_proxy_for_che_workspaces.empty? or ! @https_proxy_for_che_workspaces.empty? -%>-Dhttp.proxySet=true<% end -%><% if ! @http_proxy_for_che_workspaces.empty? -%><% if ! @http_proxy_for_che_workspaces.empty? and @http_proxy_for_che_workspaces.include? '@' -%> -Dhttp.proxyUser=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttp.proxyPassword=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttp.proxyHost=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttp.proxyPort=<%= @http_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @https_proxy_for_che_workspaces.empty? -%><% if @https_proxy_for_che_workspaces.include? '@' -%> -Dhttps.proxyUser=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[0] %> -Dhttps.proxyPassword=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[0].split(':')[1] %> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split('@')[1].split(':')[1].gsub(/\/.*/,'') %><% else -%> -Dhttps.proxyHost=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[0] %> -Dhttps.proxyPort=<%= @https_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').split(':')[1].gsub(/\/.*/,'') %><% end -%><% end -%><% if ! @che_no_proxy.empty? -%> -Dhttp.nonProxyHosts='<%= @no_proxy_for_che_workspaces.gsub(/^https?\:\/\//, '').gsub(/^www./,'').gsub(',','|') %>|'<% end -%>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Singleton
public class JavaOptsEnvVariableProvider implements Provider<String> {
@Inject
@Named("che.workspace.java_opts")
@Named("che.workspace.java.options")
private String javaOpts;

@Override
Expand Down
46 changes: 46 additions & 0 deletions plugins/plugin-maven/che-plugin-maven-wsmaster/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 Codenvy, S.A.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Codenvy, S.A. - initial API and implementation
-->
<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>
<parent>
<artifactId>che-plugin-maven-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.3.0-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-maven-wsmaster</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: Maven :: Workspace Master</name>
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.maven;

import org.eclipse.che.commons.annotation.Nullable;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;

/**
* Provides MAVEN_OPTS environment variable with a value set to either maven options
* from configuration or java options if maven options are not set.
*
* @author Yevhenii Voevodin
*/
public class MavenOptsEnvVariableProvider implements Provider<String> {

@Inject
@Named("che.workspace.java.options")
private String javaOpts;

@Inject
@Named("che.workspace.maven.options")
@Nullable
private String mavenOpts;

@Override
public String get() {
return "MAVEN_OPTS=" + (mavenOpts == null ? javaOpts : mavenOpts);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.maven;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;

import org.eclipse.che.inject.DynaModule;

/**
* Binds maven-plugin related properties.
*
* @author Yevhenii Voevodin
*/
@DynaModule
public class WsMasterModule extends AbstractModule {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), String.class, Names.named("machine.docker.dev_machine.machine_env"))
.addBinding()
.toProvider(MavenOptsEnvVariableProvider.class);
}
}
1 change: 1 addition & 0 deletions plugins/plugin-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<module>che-plugin-maven-shared</module>
<module>che-plugin-maven-ide</module>
<module>che-plugin-maven-server</module>
<module>che-plugin-maven-wsmaster</module>
</modules>
<!-- skip tests on Windows -->
<profiles>
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,11 @@
<artifactId>che-plugin-maven-shared</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-maven-wsmaster</artifactId>
<version>${che.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-nodejs-debugger-ide</artifactId>
Expand Down

0 comments on commit 9370327

Please sign in to comment.