-
-
Notifications
You must be signed in to change notification settings - Fork 156
Replayed relevant changes from scaladoc3. #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3977d6b
fe64f7b
a2289db
589f8b4
22d453d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=clean package |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>it.scala-maven-plugin</groupId> | ||
<artifactId>scaladoc-jar-test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>${project.artifactId}</name> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
<encoding>UTF-8</encoding> | ||
<scala-maven-plugin.version>4.6.3-EXPERIMENTAL</scala-maven-plugin.version> | ||
<displayCmd>false</displayCmd> | ||
</properties> | ||
|
||
<build> | ||
<sourceDirectory>src/main/scala</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>de.christofreichardt</groupId> | ||
<artifactId>tracelogger</artifactId> | ||
<version>1.9.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>scala3</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>Scalac</id> | ||
<goals> | ||
<goal>compile</goal> | ||
<goal>testCompile</goal> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<args> | ||
<arg>-deprecation</arg> | ||
<arg>-release:11</arg> | ||
<arg>-encoding</arg> | ||
<arg>utf-8</arg> | ||
</args> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>Scaladoc-jar</id> | ||
<goals> | ||
<goal>doc-jar</goal> | ||
</goals> | ||
<phase>package</phase> | ||
<configuration> | ||
<displayCmd>true</displayCmd> | ||
<jvmArgs> | ||
<jvmArg>-Xms64m</jvmArg> | ||
<jvmArg>-Xmx1024m</jvmArg> | ||
</jvmArgs> | ||
<args> | ||
<arg>-doc-footer</arg> | ||
<arg>Scala Maven Plugin - Scaladoc for Scala 3</arg> | ||
<arg>-doc-title</arg> | ||
<arg>scaladoc-jar-test</arg> | ||
<arg>-doc-version</arg> | ||
<arg>${project.version}</arg> | ||
<arg>-author</arg> | ||
</args> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala3-library_3</artifactId> | ||
<version>3.1.2</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This is free and unencumbered software released into the public domain. | ||
* See UNLICENSE. | ||
*/ | ||
package xyz.diagnosis | ||
|
||
import de.christofreichardt.diagnosis.TracerFactory | ||
import de.christofreichardt.diagnosis.AbstractTracer | ||
|
||
/** | ||
* Contains some add-ons for the <a href="http://www.christofreichardt.de/Projektstudien/TraceLogger/index.html">TraceLogger</a> library. | ||
* | ||
* @author Christof Reichardt | ||
*/ | ||
trait Tracing { | ||
/** | ||
* Custom control structure for tracing of embraced code blocks. | ||
* | ||
* @param resultType denotes the return type | ||
* @param callee the call site | ||
* @param method denotes the method signature | ||
* @param block the embraced code block | ||
* @tparam T the actual type of the embraced code block | ||
* @return returns whatever block returns | ||
*/ | ||
def withTracer[T](resultType: String, callee: AnyRef, method: String)(block: => T): T = { | ||
val tracer = getCurrentTracer() | ||
tracer.entry(resultType, callee, method) | ||
try { | ||
block | ||
} | ||
finally { | ||
tracer.wayout() | ||
} | ||
} | ||
|
||
/** | ||
* Returns the present tracer for this object. | ||
* | ||
* @return the current tracer, by default the NullTracer | ||
*/ | ||
def getCurrentTracer(): AbstractTracer = TracerFactory.getInstance().getDefaultTracer() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* This is free and unencumbered software released into the public domain. | ||
* See UNLICENSE. | ||
*/ | ||
package xyz | ||
|
||
/** | ||
* Contains an utility useful for debugging and diagnosis. | ||
*/ | ||
package object diagnosis { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This is free and unencumbered software released into the public domain. | ||
* See UNLICENSE. | ||
*/ | ||
package xyz.math | ||
|
||
import de.christofreichardt.diagnosis.{AbstractTracer, TracerFactory} | ||
import xyz.diagnosis.Tracing | ||
|
||
/** | ||
* Defines a polynomial in its canonical form. | ||
* | ||
* @author Christof Reichardt | ||
* | ||
* @constructor | ||
* @param coefficients the polynoms coefficients | ||
* @param prime the prime modulus | ||
*/ | ||
class Polynomial( | ||
val coefficients: IndexedSeq[BigInt], | ||
val prime: BigInt) | ||
extends Tracing { | ||
|
||
require(prime.isProbablePrime(100)) | ||
|
||
/** the remaining coefficients while dropping leading zeros */ | ||
val a: Seq[BigInt] = coefficients.dropWhile(c => c == BigInt(0)) | ||
/** the degree of the polynomial */ | ||
val degree: Int = a.length - 1 | ||
/** indicates the zero polynomial */ | ||
val isZero: Boolean = degree == -1 | ||
|
||
/** | ||
* Computes y = P(x). | ||
* | ||
* @param x the x value | ||
* @return the y value | ||
*/ | ||
def evaluateAt(x: BigInt): BigInt = { | ||
withTracer("BigInt", this, "evaluateAt(x: BigInt)") { | ||
val tracer = getCurrentTracer() | ||
tracer.out().printfIndentln("x = %s", x) | ||
if (isZero) BigInt(0) | ||
else { | ||
Range.inclusive(0, degree) | ||
.map(i => { | ||
tracer.out().printfIndentln("a(%d) = %s", degree - i: Integer, a(i)) | ||
(a(i) * x.modPow(degree - i, prime)).mod(prime) | ||
}) | ||
.foldLeft(BigInt(0))((t0, t1) => (t0 + t1).mod(prime)) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns a string representation of the Polynomial. | ||
* | ||
* @return the string representation of the Polynomial | ||
*/ | ||
override def toString = String.format("Polynomial[a=(%s), degree=%d, isZero=%b, prime=%s]", a.mkString(","), degree: Integer, isZero: java.lang.Boolean, prime) | ||
|
||
override def getCurrentTracer(): AbstractTracer = TracerFactory.getInstance().getDefaultTracer | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
try { | ||
def file = new File(basedir, 'target/scaladoc-jar-test-1.0-SNAPSHOT-javadoc.jar') | ||
assert file.exists() | ||
|
||
return true | ||
|
||
} catch(Throwable e) { | ||
e.printStackTrace() | ||
return false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
import java.io.File; | ||
import java.util.*; | ||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.plugins.annotations.Execute; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
|
@@ -17,6 +18,7 @@ | |
import org.codehaus.plexus.util.StringUtils; | ||
import scala_maven_dependency.Context; | ||
import scala_maven_executions.JavaMainCaller; | ||
import scala_maven_executions.ScalaDoc3Caller; | ||
import util.FileUtils; | ||
|
||
/** Produces Scala API documentation. */ | ||
|
@@ -149,11 +151,25 @@ public void doExecute() throws Exception { | |
generate(null, Locale.getDefault()); | ||
} | ||
|
||
void addScalaDocToClasspath(Set<File> classpath) throws Exception { | ||
Context sc = findScalaContext(); | ||
for (Artifact dep : sc.findScalaDocAndDependencies()) { | ||
classpath.add(dep.getFile()); | ||
} | ||
} | ||
|
||
protected JavaMainCaller getScalaCommand() throws Exception { | ||
// This ensures we have a valid scala version... | ||
checkScalaVersion(); | ||
Context sc = findScalaContext(); | ||
JavaMainCaller jcmd = getEmptyScalaCommand(sc.apidocMainClassName(scaladocClassName)); | ||
String apidocMainClassName = sc.apidocMainClassName(scaladocClassName); | ||
JavaMainCaller jcmd; | ||
if (sc.version().major < 3) { | ||
jcmd = getEmptyScalaCommand(apidocMainClassName); | ||
} else { | ||
String targetClassesDir = project.getModel().getBuild().getOutputDirectory(); | ||
jcmd = new ScalaDoc3Caller(this, apidocMainClassName, targetClassesDir); | ||
} | ||
Comment on lines
+165
to
+172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original purpose of Context (and findScalaContext) is to avoid / to remove every There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to used getEmptyScalaCommand() but I couldn't get it working. In this case, the invocation of
I tried to shift things from the bootclasspath to the normal classpath and some other things but without success. IMHO you should consider the removal of the Apache Commons Exec library in favor of The error above can be reproduced with the branch Since we are raising external processes the outcome depends very much on how well the environment has been prepared. But, I don't think the classloader issue has something to do with the environment since the I have used the interface |
||
jcmd.addArgs(args); | ||
jcmd.addJvmArgs(jvmArgs); | ||
addCompilerPluginOptions(jcmd); | ||
|
@@ -171,7 +187,11 @@ protected JavaMainCaller getScalaCommand() throws Exception { | |
.getOutputDirectory())); // remove output to avoid "error for" : error: XXX is | ||
// already defined as package XXX ... object XXX { | ||
addAdditionalDependencies(paths); | ||
if (!paths.isEmpty()) jcmd.addOption("-classpath", FileUtils.toMultiPath(paths)); | ||
addScalaDocToClasspath(paths); | ||
|
||
if (!paths.isEmpty()) { | ||
jcmd.addOption("-classpath", FileUtils.toMultiPath(paths)); | ||
} | ||
// jcmd.addOption("-sourcepath", sourceDir.getAbsolutePath()); | ||
|
||
jcmd.addArgs("-doc-format:html"); | ||
|
@@ -196,8 +216,10 @@ public void generate(Sink sink, Locale locale) throws MavenReportException { | |
if (sources.size() > 0) { | ||
JavaMainCaller jcmd = getScalaCommand(); | ||
jcmd.addOption("-d", reportOutputDir.getAbsolutePath()); | ||
for (File x : sources) { | ||
jcmd.addArgs(FileUtils.pathOf(x, useCanonicalPath)); | ||
if (this.scalaContext.version().major < 3) { | ||
for (File x : sources) { | ||
jcmd.addArgs(FileUtils.pathOf(x, useCanonicalPath)); | ||
} | ||
} | ||
jcmd.run(displayCmd); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.