Skip to content

Commit

Permalink
Pass all Hydra specific settings. Fix #1 Fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
maris123 committed Oct 18, 2017
1 parent 25765bf commit b63683f
Show file tree
Hide file tree
Showing 12 changed files with 329 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.jps.incremental.scala
package data

import java.io.{File, IOException}
import java.nio.file.Paths
import java.util
import java.util.Collections

Expand All @@ -12,6 +13,7 @@ import org.jetbrains.jps.incremental.{CompileContext, ModuleBuildTarget}
import org.jetbrains.jps.model.java.JpsJavaExtensionService
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions
import org.jetbrains.jps.{ModuleChunk, ProjectPaths}
import com.intellij.openapi.diagnostic.{Logger => JpsLogger}

import scala.collection.JavaConverters._

Expand All @@ -34,6 +36,7 @@ case class CompilationData(sources: Seq[File],
}

object CompilationData {
private val Log: JpsLogger = JpsLogger.getInstance(CompilationData.getClass.getName)
private val compilationStamp = System.nanoTime()

def from(sources: Seq[File], allSources: Seq[File], context: CompileContext, chunk: ModuleChunk): Either[String, CompilationData] = {
Expand Down Expand Up @@ -81,9 +84,13 @@ object CompilationData {
val scalaVersion = CompilerData.compilerVersion(module)
val hydraOptions =
if (hydraSettings.isHydraEnabled && scalaVersion.nonEmpty && hydraGlobalSettings.containsArtifactsFor(scalaVersion.get, hydraSettings.getHydraVersion))
Seq("-sourcepath", outputGroups.map(_._1).mkString(File.pathSeparator), "-cpus", "2")
Seq("-sourcepath", outputGroups.map(_._1).mkString(File.pathSeparator), "-cpus", hydraSettings.getNumberOfCores,
"-YsourcePartitioner:" + hydraSettings.getSourcePartitioner, "-YhydraStore", hydraSettings.getHydraStorePath,
"-YpartitionFile", Paths.get(hydraSettings.getHydraStorePath, module.getName).toString, "-YrootDirectory", hydraSettings.getProjectRoot,
"-YtimingsFile", Paths.get(hydraSettings.getHydraStorePath, "timings.csv").toString, "-YhydraTag", module.getName)
else
Seq.empty
Log.debug("Hydra options: " + hydraOptions.mkString(" "))

val isCompile =
!JavaBuilderUtil.isCompileJavaIncrementally(context) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import scala.collection.JavaConverters._
case class CompilerData(compilerJars: Option[CompilerJars], javaHome: Option[File], incrementalType: IncrementalityType)

object CompilerData {
private val Log: JpsLogger = JpsLogger.getInstance(CompilationData.getClass.getName)
private val Log: JpsLogger = JpsLogger.getInstance(CompilerData.getClass.getName)

def from(context: CompileContext, chunk: ModuleChunk): Either[String, CompilerData] = {
val project = context.getProjectDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
*/
public interface HydraSettings extends JpsElement {
boolean isHydraEnabled();
String getNumberOfCores();
String getHydraVersion();
String getSourcePartitioner();
String getHydraStorePath();
String getProjectRoot();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,46 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.ex.JpsElementBase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.nio.file.Paths;

/**
* @author Maris Alexandru
*/
public class HydraSettingsImpl extends JpsElementBase<HydraSettingsImpl> implements HydraSettings{
public static final HydraSettings DEFAULT = new HydraSettingsImpl(new State());

private final State myState;
private final State state;

public HydraSettingsImpl(State state) {
this.myState = state;
this.state = state;
}

@Override
public boolean isHydraEnabled() { return myState.isHydraEnabled; }
public boolean isHydraEnabled() { return state.isHydraEnabled; }

@Override
public String getHydraVersion() {
return myState.hydraVersion;
return state.hydraVersion;
}

@Override
public String getNumberOfCores() {
return state.noOfCores;
}

@Override
public String getHydraStorePath() { return Paths.get(state.hydraStorePath).toString(); }

@Override
public String getSourcePartitioner() { return state.sourcePartitioner; }

@Override
public String getProjectRoot() { return Paths.get(state.projectRoot).toString(); }

@NotNull
@Override
public HydraSettingsImpl createCopy() {
return new HydraSettingsImpl(XmlSerializerUtil.createCopy(myState));
return new HydraSettingsImpl(XmlSerializerUtil.createCopy(state));
}

@Override
Expand All @@ -42,5 +54,9 @@ public void applyChanges(@NotNull HydraSettingsImpl hydraSettings) {
public static class State {
public boolean isHydraEnabled = false;
public String hydraVersion = "";
public String noOfCores = Integer.toString((int) Math.ceil(Runtime.getRuntime().availableProcessors()/2D));
public String hydraStorePath = "";
public String sourcePartitioner = "";
public String projectRoot = "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,28 @@ class HydraCompilerConfigurable (project: Project, settings: HydraCompilerSettin
override def isModified: Boolean = form.isHydraEnabled != settings.isHydraEnabled ||
form.getUsername != HydraCredentialsManager.getLogin ||
form.getPassword != HydraCredentialsManager.getPlainPassword ||
form.selectedVersion != settings.hydraVersion
form.selectedVersion != settings.hydraVersion ||
form.selectedNoOfCores != settings.noOfCores ||
form.selectedSourcePartitioner != settings.sourcePartitioner ||
form.getHydraStoreDirectory != settings.hydraStorePath

override def reset() {
form.setUsername(HydraCredentialsManager.getLogin)
form.setPassword(HydraCredentialsManager.getPlainPassword)
form.setIsHydraEnabled(settings.isHydraEnabled)
form.setSelectedNoOfCores(settings.noOfCores)
form.setSelectedVersion(settings.hydraVersion)
form.setSelectedSourcePartitioner(settings.sourcePartitioner)
form.setHydraStoreDirectory(settings.hydraStorePath)
}

override def apply() {
BuildManager.getInstance().clearState(project)
settings.isHydraEnabled = form.isHydraEnabled
settings.hydraVersion = form.selectedVersion
settings.isHydraEnabled = form.isHydraEnabled
settings.noOfCores = form.selectedNoOfCores
settings.sourcePartitioner = form.selectedSourcePartitioner
settings.hydraStorePath = form.getHydraStoreDirectory
HydraCredentialsManager.setCredentials(form.getUsername, form.getPassword)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="670" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="c72e2" layout-manager="GridLayoutManager" row-count="5" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c72e2" layout-manager="GridLayoutManager" row-count="8" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="3" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -18,65 +18,47 @@
<children>
<component id="79bc1" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Username"/>
</properties>
</component>
<hspacer id="cc5d3">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="f6769">
<constraints>
<grid row="4" column="0" row-span="1" col-span="5" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="37ee5" class="javax.swing.JTextField" binding="userTextField">
<constraints>
<grid row="0" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="323f0" class="javax.swing.JPasswordField" binding="passwordTextField">
<constraints>
<grid row="1" column="2" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="70600" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Password"/>
</properties>
</component>
<component id="e99f8" class="javax.swing.JCheckBox" binding="enableHydraCheckBox">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable Hydra"/>
</properties>
</component>
<component id="88842" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Hydra Version"/>
</properties>
</component>
<component id="96fc0" class="javax.swing.JButton" binding="downloadButton">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
Expand All @@ -85,7 +67,76 @@
</component>
<component id="b1b14" class="org.jetbrains.sbt.project.template.SComboBox" binding="hydraVersionComboBox">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model/>
</properties>
</component>
<hspacer id="cc5d3">
<constraints>
<grid row="0" column="6" row-span="1" col-span="2" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="864d9">
<constraints>
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="323f0" class="javax.swing.JPasswordField" binding="passwordTextField">
<constraints>
<grid row="1" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="cfbaa" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Number of cores"/>
</properties>
</component>
<vspacer id="f6769">
<constraints>
<grid row="7" column="0" row-span="1" col-span="6" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="9b874" class="org.jetbrains.sbt.project.template.SComboBox" binding="noOfCoresComboBox">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model/>
</properties>
</component>
<component id="f0588" class="org.jetbrains.sbt.project.template.SComboBox" binding="sourcePartitionerComboBox">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="3965f" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Source Partitioner"/>
</properties>
</component>
<component id="b0ae1" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Hydra Store"/>
</properties>
</component>
<component id="816d2" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="hydraStoreDirectoryField">
<constraints>
<grid row="6" column="2" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
Expand Down
Loading

0 comments on commit b63683f

Please sign in to comment.