Object (String modelName, Project project) { final ScalaPlugin scalaPlugin = project.getPlugins().findPlugin(ScalaPlugin.class); ScalaModel scalaModel = null; if (scalaPlugin != null) { Task scalaTask = project.getTasks().getByName(COMPILE_SCALA_TASK); scalaModel = createModel(scalaTask); } else { Iterator<ScalaCompile> it = project.getTasks().withType(ScalaCompile.class).iterator(); if (it.hasNext()) { scalaModel = createModel(it.next()); } } return scalaModel; }