Add new JS source map config options to Maven plugin

This commit is contained in:
Alexey Andreev
2017-06-13 15:05:10 +03:00
parent cfd3b137d8
commit 49b742ab3d
13 changed files with 123 additions and 27 deletions
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>org.jetbrains.kotlin</groupId>
<artifactId>test-js-sourceMap</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-js</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>js</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceMap>true</sourceMap>
<sourceMapPrefix>prefixprefix/</sourceMapPrefix>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains
fun bar() = "OK"
@@ -0,0 +1,3 @@
source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
assertFileContains("target/js/test-js-sourceMap.js.map", "\"prefixprefix/org/jetbrains/HelloWorld.kt\"")
@@ -1,6 +1,5 @@
String[] getBuildLogLines() {
File buildLog = new File(basedir, "build.log");
BufferedReader reader = new BufferedReader(new FileReader(buildLog));
String[] getFileLines(File file) {
BufferedReader reader = new BufferedReader(new FileReader(file));
List result = new ArrayList();
String line;
while ((line = reader.readLine()) != null){
@@ -11,8 +10,24 @@ String[] getBuildLogLines() {
return result.toArray(new String[0]);
}
String[] getBuildLogLines() {
return getFileLines(new File(basedir, "build.log"));
}
String[] buildLog = getBuildLogLines();
void assertFileContains(String relativePath, String content) {
File file = new File(basedir, relativePath);
if (!file.exists()) {
throw new Exception("File was not found: " + relativePath);
}
String[] lines = getFileLines(file);
int lineNumber = findLineThatContains(lines, content);
if (lineNumber < 0) {
throw new Exception("Expected file " + relativePath + " to contain: \"" + content + "\"");
}
}
void assertBuildLogHasLine(String expectedLine) {
for (int i = 0; i < buildLog.length; i++) {
@@ -40,8 +55,12 @@ void assertBuildLogHasNoLineThatContains(String content) {
}
int findBuildLogLineThatContains(String content) {
for (int i = 0; i < buildLog.length; i++) {
String line = buildLog[i];
return findLineThatContains(buildLog, content);
}
int findLineThatContains(String[] lines, String content) {
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
if (line.contains(content)) {
return i;
}