Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3ba22fb
Bump maven-archiver from 3.5.2 to 3.6.0
dependabot[bot] Jun 27, 2022
1ebc830
Bump zinc_2.13 from 1.6.1 to 1.7.0
dependabot[bot] Jul 11, 2022
af12134
Bump zinc_2.13 from 1.7.0 to 1.7.1
dependabot[bot] Jul 12, 2022
252cdbb
Bump spotless-maven-plugin from 2.22.8 to 2.23.0
dependabot[bot] Jul 1, 2022
f0b4fc1
Fix JavaLocator, close #619
slandelle Jul 15, 2022
f8503f3
[maven-release-plugin] prepare release 4.7.0
slandelle Jul 17, 2022
b833541
[maven-release-plugin] prepare for next development iteration
slandelle Jul 17, 2022
efabf92
fix Windows detection
slandelle Jul 17, 2022
59bb9a3
Bump maven-install-plugin from 2.5.2 to 3.0.0
dependabot[bot] Jul 19, 2022
47185c6
Bump maven-deploy-plugin from 2.8.2 to 3.0.0
dependabot[bot] Jul 19, 2022
02ea518
Fix JDK location detection on Linux for Java 8, close #627
slandelle Jul 24, 2022
e935896
format
slandelle Jul 24, 2022
b85d663
[maven-release-plugin] prepare release 4.7.1
slandelle Jul 24, 2022
f4d2b93
[maven-release-plugin] prepare for next development iteration
slandelle Jul 24, 2022
2af9301
Bump maven-project-info-reports-plugin from 3.3.0 to 3.4.0
dependabot[bot] Jul 18, 2022
ed62f4e
Bump maven-install-plugin from 3.0.0 to 3.0.1
dependabot[bot] Jul 25, 2022
75c5d9f
Bump maven-resources-plugin from 3.2.0 to 3.3.0
dependabot[bot] Jul 26, 2022
b5ef905
Bump spotless-maven-plugin from 2.23.0 to 2.24.0
dependabot[bot] Jul 28, 2022
9ea6de1
Bump maven-reporting-api from 3.0 to 3.1.1
dependabot[bot] Aug 1, 2022
a6be8c1
Bump maven-site-plugin from 3.12.0 to 3.12.1
dependabot[bot] Aug 4, 2022
361d88b
Bump spotless-maven-plugin from 2.24.0 to 2.24.1
dependabot[bot] Aug 10, 2022
4d6c5a3
Bump maven-javadoc-plugin from 3.4.0 to 3.4.1
dependabot[bot] Aug 15, 2022
8d9df29
Bump maven-project-info-reports-plugin from 3.4.0 to 3.4.1
dependabot[bot] Aug 15, 2022
94423d0
Bump animal-sniffer-maven-plugin from 1.21 to 1.22
dependabot[bot] Aug 16, 2022
47501b5
Bump spotless-maven-plugin from 2.24.1 to 2.25.0
dependabot[bot] Aug 24, 2022
4681fee
Bump maven-dependency-tree from 3.1.1 to 3.2.0
dependabot[bot] Aug 25, 2022
fb6446a
Bump spotless-maven-plugin from 2.25.0 to 2.26.0
dependabot[bot] Sep 14, 2022
c188f4b
Bump plexus-archiver from 4.4.0 to 4.5.0
dependabot[bot] Sep 15, 2022
2951fb6
Bump maven-jar-plugin from 3.2.2 to 3.3.0
dependabot[bot] Sep 16, 2022
392022a
Bump spotless-maven-plugin from 2.26.0 to 2.27.0
dependabot[bot] Sep 20, 2022
56acb1b
Bump spotless-maven-plugin from 2.27.0 to 2.27.1
dependabot[bot] Sep 28, 2022
ede3d72
Set -release instead of -target since Scala 2.13.9, close #646
slandelle Sep 28, 2022
8c434ad
[maven-release-plugin] prepare release 4.7.2
slandelle Sep 28, 2022
22446e7
[maven-release-plugin] prepare for next development iteration
slandelle Sep 28, 2022
519b82b
Bump zinc_2.13 from 1.7.1 to 1.7.2
dependabot[bot] Oct 3, 2022
36863f0
Bump spotless-maven-plugin from 2.27.1 to 2.27.2
dependabot[bot] Oct 10, 2022
48f20d9
Bump maven-plugin-plugin from 3.6.4 to 3.7.0
dependabot[bot] Nov 8, 2022
9485dd8
Bump maven-plugin-annotations from 3.6.4 to 3.7.0
dependabot[bot] Nov 8, 2022
9b10e64
Bump plexus-utils from 3.4.2 to 3.5.0
dependabot[bot] Oct 24, 2022
06cfed5
Bump plexus-archiver from 4.5.0 to 4.6.0
dependabot[bot] Nov 11, 2022
7d5d9bc
Bump zinc_2.13 from 1.7.2 to 1.8.0
dependabot[bot] Nov 11, 2022
aecb83f
Bump maven-install-plugin from 3.0.1 to 3.1.0
dependabot[bot] Nov 18, 2022
77cb638
Bump plexus-classworlds from 2.6.0 to 2.7.0
dependabot[bot] Nov 18, 2022
4d8bcc0
Bump maven-dependency-tree from 3.2.0 to 3.2.1
dependabot[bot] Nov 21, 2022
407eaf7
chore: minor cleanup
slandelle Nov 22, 2022
b2feb40
chore: don't use LinkedList
slandelle Nov 29, 2022
76c277d
chore: filter out test dependencies
slandelle Nov 29, 2022
ae39f02
chore: minor clean up
slandelle Nov 29, 2022
69a45c0
Run incremental compiler in a forked process when jvmArgs are defined…
slandelle Nov 29, 2022
a22b190
chore: use constants for Scala versions used in tests
slandelle Nov 29, 2022
234da81
[maven-release-plugin] prepare release 4.8.0
slandelle Nov 29, 2022
8100c35
[maven-release-plugin] prepare for next development iteration
slandelle Nov 29, 2022
b64ca9c
Bump maven-dependency-plugin from 3.3.0 to 3.4.0
dependabot[bot] Nov 30, 2022
cbcd10f
Bump maven-invoker-plugin from 3.3.0 to 3.4.0
dependabot[bot] Dec 19, 2022
a329b75
Bump plexus-archiver from 4.6.0 to 4.6.1
dependabot[bot] Jan 2, 2023
cc872f2
Bump maven-dependency-plugin from 3.4.0 to 3.5.0
dependabot[bot] Jan 13, 2023
09ecd03
Bump maven-project-info-reports-plugin from 3.4.1 to 3.4.2
dependabot[bot] Jan 13, 2023
7ce1e01
fix Scalac options when using Scala 3, close #673
slandelle Mar 6, 2023
c6c9868
Bump doxia-sink-api from 1.11.1 to 1.12.0
dependabot[bot] Jan 16, 2023
e16345e
Bump maven-plugin-annotations from 3.7.0 to 3.7.1
dependabot[bot] Jan 16, 2023
2d39d2f
Bump maven-deploy-plugin from 3.0.0 to 3.1.0
dependabot[bot] Feb 9, 2023
61b8873
Bump maven-javadoc-plugin from 3.4.1 to 3.5.0
dependabot[bot] Feb 15, 2023
6bf1a35
Bump maven-plugin-plugin from 3.7.0 to 3.8.1
dependabot[bot] Feb 27, 2023
8a6e77b
Bump maven-plugin-annotations from 3.7.1 to 3.8.1
slandelle Mar 6, 2023
15fe6cb
[maven-release-plugin] prepare release 4.8.1
slandelle Mar 6, 2023
ecf9d17
[maven-release-plugin] prepare for next development iteration
slandelle Mar 6, 2023
ef6df2f
Bump maven-compiler-plugin from 3.10.1 to 3.11.0
dependabot[bot] Mar 6, 2023
3b89c69
Bump plexus-archiver from 4.6.1 to 4.6.2
dependabot[bot] Mar 6, 2023
d51f595
Bump plexus-utils from 3.5.0 to 3.5.1
dependabot[bot] Mar 6, 2023
dde704a
Bump maven-surefire-plugin from 2.22.2 to 3.0.0
dependabot[bot] Mar 14, 2023
531f954
Bump maven-scm-provider-gitexe from 1.13.0 to 2.0.0
dependabot[bot] Mar 17, 2023
ce5d1bd
Bump maven-scm-api from 1.13.0 to 2.0.0
dependabot[bot] Mar 17, 2023
04a77d6
Bump maven-invoker-plugin from 3.4.0 to 3.5.1
dependabot[bot] Mar 31, 2023
01db397
Bump maven-release-plugin from 2.5.3 to 3.0.0
dependabot[bot] Mar 20, 2023
725e1fb
Bump plexus-archiver from 4.6.2 to 4.6.3
dependabot[bot] Mar 21, 2023
685544a
Bump maven-deploy-plugin from 3.1.0 to 3.1.1
dependabot[bot] Mar 24, 2023
3b8e8da
Bump maven-install-plugin from 3.1.0 to 3.1.1
dependabot[bot] Mar 24, 2023
9faa15c
Bump maven-resources-plugin from 3.3.0 to 3.3.1
dependabot[bot] Apr 3, 2023
7c7567b
Upgrade zinc 1.8.1
slandelle May 15, 2023
ee0ad69
Bump maven-project-info-reports-plugin from 3.4.2 to 3.4.3
dependabot[bot] Apr 18, 2023
82f6f00
Bump maven-plugin-annotations from 3.8.1 to 3.8.2
dependabot[bot] Apr 24, 2023
94801f8
Bump maven-plugin-plugin from 3.8.1 to 3.8.2
dependabot[bot] Apr 24, 2023
d0ecd61
Bump maven-gpg-plugin from 3.0.1 to 3.1.0
dependabot[bot] May 8, 2023
2844824
Bump plexus-archiver from 4.6.3 to 4.7.1
dependabot[bot] May 8, 2023
eea9388
Bump maven-surefire-plugin from 3.0.0 to 3.1.0
dependabot[bot] May 15, 2023
8ccab1f
Upgrade Scala and zinc versions
slandelle Jul 7, 2023
7ca4680
Bump maven-plugin-annotations from 3.8.2 to 3.9.0
dependabot[bot] May 16, 2023
246187b
Bump maven-plugin-plugin from 3.8.2 to 3.9.0
dependabot[bot] May 16, 2023
6594e7f
Bump maven-scm-provider-gitexe from 2.0.0 to 2.0.1
dependabot[bot] May 18, 2023
ed5574d
Bump maven-scm-api from 2.0.0 to 2.0.1
dependabot[bot] May 18, 2023
6e875f4
upgrade kind-projector based integration test
slandelle Jul 7, 2023
5045e7c
chore: clean up pom
slandelle Jul 7, 2023
2e4d43b
chore
slandelle Jul 7, 2023
c87ba71
Bump maven-clean-plugin from 3.2.0 to 3.3.1
dependabot[bot] Jul 7, 2023
ce5a820
Bump maven-surefire-plugin from 3.1.0 to 3.1.2
dependabot[bot] Jul 7, 2023
d6bc704
Bump maven-release-plugin from 3.0.0 to 3.0.1
dependabot[bot] Jul 7, 2023
b4dbe28
Bump maven-dependency-plugin from 3.5.0 to 3.6.0
dependabot[bot] Jul 7, 2023
071e962
Bump maven-project-info-reports-plugin from 3.4.3 to 3.4.5
dependabot[bot] Jul 7, 2023
729e31c
Bump org.scala-sbt:zinc_2.13 from 1.9.2 to 1.9.3
dependabot[bot] Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
383 changes: 176 additions & 207 deletions pom.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/it/test_scaladoc_compiler_plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<compilerPlugin>
<groupId>org.typelevel</groupId>
<artifactId>kind-projector_${scala.version.lastrelease}</artifactId>
<version>0.11.0</version>
<version>0.13.2</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ import scala.language.higherKinds

object MyClass {

class TestKinded[F[_], G]

def testWithHigherKinded[F[_] : TestKinded[?[_], Int]] = ???

def testWithHigherKinded[Either[Int, +*]] = ???
}
235 changes: 235 additions & 0 deletions src/main/java/sbt_inc/CompilerBridgeFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*
* This is free and unencumbered software released into the public domain.
* See UNLICENSE.
*/
package sbt_inc;

import static scala.jdk.CollectionConverters.IterableHasAsScala;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.logging.Log;
import sbt.internal.inc.RawCompiler;
import sbt.internal.inc.ScalaInstance;
import sbt.io.AllPassFilter$;
import sbt.io.IO;
import scala.Tuple2;
import scala_maven.MavenArtifactResolver;
import scala_maven.VersionNumber;
import util.FileUtils;
import xsbti.compile.ClasspathOptionsUtil;

public final class CompilerBridgeFactory {

private static final String SBT_GROUP_ID = "org.scala-sbt";
private static final String SBT_GROUP_ID_SCALA3 = "org.scala-lang";
private static final String JAVA_CLASS_VERSION = System.getProperty("java.class.version");

private static final File DEFAULT_SECONDARY_CACHE_DIR =
Paths.get(System.getProperty("user.home"), ".sbt", "1.0", "zinc", "org.scala-sbt").toFile();

private CompilerBridgeFactory() {}

static File getCompiledBridgeJar(
VersionNumber scalaVersion,
ScalaInstance scalaInstance,
File secondaryCacheDir,
MavenArtifactResolver resolver,
Log mavenLogger)
throws Exception {
// eg
// org.scala-sbt-compiler-bridge_2.12-1.2.4-bin_2.12.10__52.0-1.2.4_20181015T090407.jar
String bridgeArtifactId = compilerBridgeArtifactId(scalaVersion.toString());

if (secondaryCacheDir == null) {
secondaryCacheDir = DEFAULT_SECONDARY_CACHE_DIR;
}
secondaryCacheDir.mkdirs();

return scalaVersion.major == 3
? getScala3CompilerBridgeJar(scalaVersion, bridgeArtifactId, resolver)
: getScala2CompilerBridgeJar(
scalaInstance,
scalaVersion,
bridgeArtifactId,
resolver,
secondaryCacheDir,
mavenLogger);
}

private static String compilerBridgeArtifactId(String scalaVersion) {
if (scalaVersion.startsWith("2.10.")) {
return "compiler-bridge_2.10";
} else if (scalaVersion.startsWith("2.11.")) {
return "compiler-bridge_2.11";
} else if (scalaVersion.startsWith("2.12.") || scalaVersion.equals("2.13.0-M1")) {
return "compiler-bridge_2.12";
} else if (scalaVersion.startsWith("2.13.")) {
return "compiler-bridge_2.13";
} else {
return "scala3-sbt-bridge";
}
}

private static File getScala3CompilerBridgeJar(
VersionNumber scalaVersion, String bridgeArtifactId, MavenArtifactResolver resolver) {
return resolver
.getJar(SBT_GROUP_ID_SCALA3, bridgeArtifactId, scalaVersion.toString(), "")
.getFile();
}

private static File getScala2CompilerBridgeJar(
ScalaInstance scalaInstance,
VersionNumber scalaVersion,
String bridgeArtifactId,
MavenArtifactResolver resolver,
File secondaryCacheDir,
Log mavenLogger)
throws IOException {
// this file is localed in compiler-interface
Properties properties = new Properties();
try (InputStream is =
CompilerBridgeFactory.class
.getClassLoader()
.getResourceAsStream("incrementalcompiler.version.properties")) {
properties.load(is);
}

String zincVersion = properties.getProperty("version");
String timestamp = properties.getProperty("timestamp");

String cacheFileName =
SBT_GROUP_ID
+ '-'
+ bridgeArtifactId
+ '-'
+ zincVersion
+ "-bin_"
+ scalaVersion
+ "__"
+ JAVA_CLASS_VERSION
+ '-'
+ zincVersion
+ '_'
+ timestamp
+ ".jar";

File cachedCompiledBridgeJar = new File(secondaryCacheDir, cacheFileName);

if (mavenLogger.isInfoEnabled()) {
mavenLogger.info("Compiler bridge file: " + cachedCompiledBridgeJar);
}

if (!cachedCompiledBridgeJar.exists()) {
mavenLogger.info("Compiler bridge file is not installed yet");
// compile and install
RawCompiler rawCompiler =
new RawCompiler(
scalaInstance, ClasspathOptionsUtil.auto(), new MavenLoggerSbtAdapter(mavenLogger));

File bridgeSources =
resolver.getJar(SBT_GROUP_ID, bridgeArtifactId, zincVersion, "sources").getFile();

Set<Path> bridgeSourcesDependencies =
resolver.getJarAndDependencies(SBT_GROUP_ID, bridgeArtifactId, zincVersion, "sources")
.stream()
.filter(
artifact ->
artifact.getScope() != null && !artifact.getScope().equals("provided"))
.map(Artifact::getFile)
.map(File::toPath)
.collect(Collectors.toSet());

bridgeSourcesDependencies.addAll(
Arrays.stream(scalaInstance.allJars())
.sequential()
.map(File::toPath)
.collect(Collectors.toList()));

Path sourcesDir = Files.createTempDirectory("scala-maven-plugin-compiler-bridge-sources");
Path classesDir = Files.createTempDirectory("scala-maven-plugin-compiler-bridge-classes");

IO.unzip(bridgeSources, sourcesDir.toFile(), AllPassFilter$.MODULE$, true);

List<Path> bridgeSourcesScalaFiles =
FileUtils.listDirectoryContent(
sourcesDir,
file ->
Files.isRegularFile(file) && file.getFileName().toString().endsWith(".scala"));
List<Path> bridgeSourcesNonScalaFiles =
FileUtils.listDirectoryContent(
sourcesDir,
file ->
Files.isRegularFile(file)
&& !file.getFileName().toString().endsWith(".scala")
&& !file.getFileName().toString().equals("MANIFEST.MF"));

try {
rawCompiler.apply(
IterableHasAsScala(bridgeSourcesScalaFiles).asScala().toSeq(), // sources:Seq[File]
IterableHasAsScala(bridgeSourcesDependencies).asScala().toSeq(), // classpath:Seq[File],
classesDir, // outputDirectory:Path,
IterableHasAsScala(Collections.<String>emptyList())
.asScala()
.toSeq() // options:Seq[String]
);

Manifest manifest = new Manifest();
Path sourcesManifestFile = sourcesDir.resolve("META-INF").resolve("MANIFEST.MF");
try (InputStream is = Files.newInputStream(sourcesManifestFile)) {
manifest.read(is);
}

List<Tuple2<File, String>> scalaCompiledClasses =
computeZipEntries(FileUtils.listDirectoryContent(classesDir, file -> true), classesDir);
List<Tuple2<File, String>> resources =
computeZipEntries(bridgeSourcesNonScalaFiles, sourcesDir);
List<Tuple2<File, String>> allZipEntries = new ArrayList<>();
allZipEntries.addAll(scalaCompiledClasses);
allZipEntries.addAll(resources);

IO.jar(
IterableHasAsScala(
allZipEntries.stream()
.map(x -> scala.Tuple2.apply(x._1, x._2))
.collect(Collectors.toList()))
.asScala(),
cachedCompiledBridgeJar,
manifest);

mavenLogger.info("Compiler bridge installed");

} finally {
FileUtils.deleteDirectory(sourcesDir);
FileUtils.deleteDirectory(classesDir);
}
}

return cachedCompiledBridgeJar;
}

private static List<Tuple2<File, String>> computeZipEntries(List<Path> paths, Path rootDir) {
int rootDirLength = rootDir.toString().length();
Stream<Tuple2<File, String>> stream =
paths.stream()
.map(
path -> {
String zipPath =
path.toString().substring(rootDirLength + 1).replace(File.separator, "/");
if (Files.isDirectory(path)) {
zipPath = zipPath + "/";
}
return new Tuple2<>(path.toFile(), zipPath);
});
return stream.collect(Collectors.toList());
}
}
Loading