Skip to content

Commit 3748182

Browse files
authored
Merge pull request #36 from codacy/crosscompile-scala2.13
bump: Crosscompile to Scala 2.13
2 parents 4e1a554 + 1d71d09 commit 3748182

File tree

13 files changed

+145
-62
lines changed

13 files changed

+145
-62
lines changed

.circleci/config.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ references:
3333
restore_build: &restore_build
3434
restore_cache:
3535
keys:
36-
- sbt-build-1.0.0-{{ .Branch }}-{{ .Revision }}
37-
- sbt-build-1.0.0
36+
- sbt-build-1.0.1-{{ .Branch }}-{{ .Revision }}
37+
- sbt-build-1.0.1
3838

3939
setup_dependencies_key: &setup_dependencies_key
4040
run:
@@ -69,6 +69,7 @@ jobs:
6969
paths:
7070
- ~/.ivy2
7171
- ~/.sbt
72+
- ~/.coursier/cache/v1
7273
key: sbt-ivy2-dependencies-1.0.0-{{ checksum "/tmp/dependencies.cache.tmp" }}
7374

7475
compile:
@@ -102,15 +103,15 @@ jobs:
102103
working_directory: ~/
103104
command: |
104105
mkdir -p ~/coverage-reports/scoverage
105-
cp -f ~/workdir/target/scala-2.11/coverage-report/cobertura.xml ~/coverage-reports/scoverage/results.xml
106+
cp -f ~/workdir/target/scala-2.12/coverage-report/cobertura.xml ~/coverage-reports/scoverage/results.xml
106107
- store_test_results:
107108
path: ~/coverage-reports
108109
- store_artifacts:
109-
path: ~/workdir/target/scala-2.11/coverage-report
110+
path: ~/workdir/target/scala-2.12/coverage-report
110111
- store_artifacts:
111-
path: ~/workdir/target/scala-2.11/scoverage-report
112+
path: ~/workdir/target/scala-2.12/scoverage-report
112113
- store_artifacts:
113-
path: ~/workdir/target/scala-2.11/scoverage-data
114+
path: ~/workdir/target/scala-2.12/scoverage-data
114115

115116
publish:
116117
<<: *default_java_job

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/RUNNING_PID
22
/logs/
33
/project/*-shim.sbt
4-
/project/project/
5-
/project/target/
6-
/target/
7-
/.idea/
4+
target
5+
.idea
6+
.metals
7+
.bloop
88
/libexec/
99
/bin/

.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version = "2.0.1"
12
style=IntelliJ
23
project.excludeFilters = [".*\\.scala.html$", "components/pluginsEngineComponent/src/test/resources/.*", "target/.*"]
34
maxColumn=120

build.sbt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
val scala211 = "2.11.12"
2+
val scala212 = "2.12.8"
3+
val scala213 = "2.13.0"
4+
15
name := "codacy-plugins-api"
2-
version := "1.0.0-SNAPSHOT"
36
organization := "com.codacy"
47

5-
scalaVersion := "2.11.12"
6-
crossScalaVersions := Seq("2.10.6", scalaVersion.value, "2.12.4")
8+
scalaVersion := scala212
9+
crossScalaVersions := Seq(scala211, scala212, scala213)
10+
11+
libraryDependencies ++= Seq(
12+
"org.specs2" %% "specs2-core" % "4.6.0" % Test
13+
)
714

8-
libraryDependencies ++= Seq("org.specs2" %% "specs2-core" % "3.10.0" % Test)
15+
unmanagedSourceDirectories in Compile += {
16+
val sourceDir = (sourceDirectory in Compile).value
17+
CrossVersion.partialVersion(scalaVersion.value) match {
18+
case Some((2, n)) if n >= 13 => sourceDir / "scala-2.13+"
19+
case _ => sourceDir / "scala-2.13-"
20+
}
21+
}
922

1023
// Sonatype repository settings
1124
ThisBuild / credentials += Credentials(

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.3
1+
sbt.version=1.3.0

project/plugins.sbt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sbt._
2-
31
// Sonatype publishing
42
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
53
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")
@@ -8,5 +6,5 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")
86
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4")
97

108
// Coverage
11-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
9+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
1210
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")

scripts/compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
set -e
44

5-
sbt compile
6-
sbt test:compile
5+
sbt +compile
6+
sbt +test:compile

scripts/publish.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ fi
1616

1717
echo "Publishing version ${VERSION}"
1818
if [[ -n "$CI" ]] && [[ "$CURRENT_BRANCH" == "$PUBLISH_BRANCH" || "$CIRCLE_BRANCH" == "$PUBLISH_BRANCH" ]]; then
19-
sbt ++2.10.6 'set version := "'"${VERSION}"'"' 'set pgpPassphrase := Some("'"$SONATYPE_GPG_PASSPHRASE"'".toCharArray)' publishSigned sonatypeRelease
20-
sbt ++2.11.12 'set version := "'"${VERSION}"'"' 'set pgpPassphrase := Some("'"$SONATYPE_GPG_PASSPHRASE"'".toCharArray)' publishSigned sonatypeRelease
21-
sbt ++2.12.4 'set version := "'"${VERSION}"'"' 'set pgpPassphrase := Some("'"$SONATYPE_GPG_PASSPHRASE"'".toCharArray)' publishSigned sonatypeRelease
19+
sbt 'set version := "'"${VERSION}"'"' 'set pgpPassphrase := Some("'"$SONATYPE_GPG_PASSPHRASE"'".toCharArray)' +publishSigned sonatypeRelease
2220
else
2321
sbt 'set version := "'"${VERSION}"'"' +publishLocal
2422
fi

scripts/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ -n "$1" ]; then
66
export CODACY_PROJECT_TOKEN="$1"
77
fi
88

9-
sbt coverage test
9+
sbt coverage +test
1010
sbt coverageReport
1111
sbt coverageAggregate
1212

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.codacy.plugins.api.languages
2+
3+
import Languages._
4+
5+
private[languages] object LanguagesImpl {
6+
def extensionsByLanguageImpl: Map[Language, Set[String]] =
7+
all.view.map { lang =>
8+
(lang, lang.extensions)
9+
}.to(Map)
10+
11+
def filenamesByLanguageImpl: Map[Language, Set[String]] =
12+
all.view.map { lang =>
13+
(lang, lang.files)
14+
}.to(Map)
15+
16+
def languageByExtensionImpl: Map[String, Language] =
17+
all.view.flatMap { lang =>
18+
lang.extensions.map(extension => (extension.toLowerCase(), lang))
19+
}.to(Map)
20+
21+
def languageByFilenameImpl: Map[String, Language] =
22+
all.view.flatMap { lang =>
23+
lang.files.map(file => (file.toLowerCase(), lang))
24+
}.to(Map)
25+
26+
def forPathImpl(
27+
filePath: String,
28+
customExtensions: List[(Language, Seq[String])] = List.empty[(Language, Seq[String])]): Option[Language] = {
29+
lazy val languageByCustomExtension: List[(String, Language)] = {
30+
val customExtensionsMap: Map[Language, Set[String]] = customExtensions.view.map {
31+
case (lang, exts) =>
32+
(lang, exts.view.to(Set) ++ extensionsByLanguage.getOrElse(lang, Set.empty))
33+
}.to(Map)
34+
35+
customExtensionsMap.view.flatMap {
36+
case (lang, extensions) => extensions.map(extension => (extension.toLowerCase, lang))
37+
}.to(List).sortBy {
38+
case (ext, lang) => (lang.toString, ext)
39+
}
40+
}
41+
42+
filePath.split('/').lastOption.flatMap { filename =>
43+
languageByCustomExtension.collectFirst { case (ext, lang) if filename.endsWith(ext) => lang }.orElse {
44+
(for {
45+
extension <- filename.split('.').lastOption
46+
dottedExtension = s".$extension"
47+
} yield languageByExtension.get(dottedExtension.toLowerCase)).flatten
48+
}.orElse(languageByFilename.get(filename.toLowerCase))
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)