Skip to content

Commit ace4f08

Browse files
committed
Merge pull request #86 from prezi/a-new-package
A new package
2 parents fa8cc61 + 18d1e8e commit ace4f08

File tree

196 files changed

+5725
-2419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5725
-2419
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ temp
99
*.iml
1010
*.ipr
1111
*.iws
12-
out
12+
out/
13+
gen/
14+
classes/
1315

1416
.gradle/
1517
build/

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ You then implement the generated interfaces, and compile your code into a JavaSc
6060
```haxe
6161
package com.example.module;
6262
63-
// Spaghetti looks for a class called "<ModuleName>Impl"
64-
class MyModuleImpl implements MyModule {
63+
// Spaghetti looks for a class called "<ModuleName>" that implements the interface called "I<ModuleName>"
64+
class MyModule implements IMyModule {
6565
public function createGreeter():Greeter {
6666
return new DefaultGreeter();
6767
}

build.gradle

+11-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ allprojects {
1616
group = 'com.prezi.spaghetti'
1717
version = gitVersion
1818
apply plugin: 'idea'
19+
20+
tasks.withType(Upload).all { dependsOn "check" }
1921
}
2022

2123
subprojects { subproject ->
@@ -141,16 +143,22 @@ subprojects { subproject ->
141143
}
142144
}
143145

146+
project(":spaghetti-core") {
147+
dependencies {
148+
compile "com.google.javascript:closure-compiler:v20131014"
149+
}
150+
}
151+
144152
configure(subprojects.findAll { it.name ==~ /spaghetti-.*-support/ }) {
145153
dependencies {
146154
compile project(path: ":spaghetti-core")
155+
testCompile project(path: ":spaghetti-core", configuration: "testCompile")
147156
}
148157
}
149158

150159
project(":gradle-spaghetti-plugin") {
151160
dependencies {
152161
compile gradleApi()
153-
compile "com.google.javascript:closure-compiler:v20131014"
154162
compile project(path: ":spaghetti-core")
155163
// Add all support projects
156164
rootProject.subprojects.findAll { it.name ==~ /spaghetti-.*-support/ }.each { supportProject ->
@@ -177,12 +185,12 @@ configure(subprojects.findAll { it.name ==~ /gradle-spaghetti-.*-plugin/}) {
177185
}
178186
project(":gradle-spaghetti-haxe-plugin") {
179187
dependencies {
180-
compile "com.prezi.haxe:gradle-haxe-plugin:3.0"
188+
compile "com.prezi.haxe:gradle-haxe-plugin:3.1"
181189
compile "org.webjars:requirejs:2.1.8"
182190
}
183191
}
184192
project(":gradle-spaghetti-typescript-plugin") {
185193
dependencies {
186-
compile "com.prezi.typescript:gradle-typescript-plugin:1.1.1"
194+
compile "com.prezi.typescript:gradle-typescript-plugin:1.1.2"
187195
}
188196
}
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,28 @@
11
package com.prezi.spaghetti.haxe.gradle
22

3-
import com.prezi.haxe.gradle.HaxeBinary
4-
import com.prezi.spaghetti.gradle.SpaghettiCompatibleBinaryNamingScheme
5-
import org.gradle.language.base.internal.AbstractBuildableModelElement
6-
import org.gradle.language.base.internal.BinaryInternal
7-
import org.gradle.language.base.internal.BinaryNamingScheme
3+
import com.prezi.haxe.gradle.HaxeBinaryBase
4+
import com.prezi.spaghetti.gradle.AbstractSpaghettiCompatibleJavaScriptBinary
85

96
/**
107
* Created by lptr on 09/02/14.
118
*/
129
class DefaultHaxeCompiledSpaghettiCompatibleJavaScriptBinary
13-
extends AbstractBuildableModelElement implements HaxeCompiledSpaghettiCompatibleJavaScriptBinary, BinaryInternal {
14-
private final BinaryNamingScheme namingScheme
15-
private final HaxeBinary binary
10+
extends AbstractSpaghettiCompatibleJavaScriptBinary
11+
implements HaxeCompiledSpaghettiCompatibleJavaScriptBinary {
12+
private final HaxeBinaryBase original
1613

17-
public DefaultHaxeCompiledSpaghettiCompatibleJavaScriptBinary(HaxeBinary binary) {
18-
this.namingScheme = new SpaghettiCompatibleBinaryNamingScheme(binary.name)
19-
this.binary = binary
14+
public DefaultHaxeCompiledSpaghettiCompatibleJavaScriptBinary(HaxeBinaryBase original, boolean testing) {
15+
super(original.name, testing)
16+
this.original = original
2017
}
2118

2219
@Override
23-
File getJavaScriptFile() {
24-
return binary.getCompileTask().getOutputFile()
25-
}
26-
27-
@Override
28-
File getSourceMapFile() {
29-
def outputFile = binary.getCompileTask().getOutputFile()
30-
def sourceMapFile = new File(outputFile.parentFile, outputFile.name + ".map")
31-
return sourceMapFile.exists() ? sourceMapFile : null
32-
}
33-
34-
@Override
35-
BinaryNamingScheme getNamingScheme() {
36-
return namingScheme
20+
HaxeBinaryBase getOriginal() {
21+
return original
3722
}
3823

3924
@Override
40-
String getDisplayName() {
41-
return namingScheme.description
42-
}
43-
44-
@Override
45-
String getName() {
46-
return namingScheme.lifecycleTaskName
47-
}
48-
49-
@Override
50-
String toString() {
51-
return "${name} JS binary"
25+
File getJavaScriptFile() {
26+
return original.getCompileTask().getOutputFile()
5227
}
5328
}

gradle-spaghetti-haxe-plugin/src/main/groovy/com/prezi/spaghetti/haxe/gradle/HaxeCommandUtils.groovy

-28
This file was deleted.

gradle-spaghetti-haxe-plugin/src/main/groovy/com/prezi/spaghetti/haxe/gradle/HaxeCompileWithSpaghetti.groovy

-36
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.prezi.spaghetti.haxe.gradle
22

3+
import com.prezi.haxe.gradle.HaxeBinaryBase
34
import com.prezi.spaghetti.gradle.SpaghettiCompatibleJavaScriptBinary
45

56
/**
67
* Created by lptr on 15/02/14.
78
*/
89
public interface HaxeCompiledSpaghettiCompatibleJavaScriptBinary
910
extends SpaghettiCompatibleJavaScriptBinary {
11+
HaxeBinaryBase getOriginal()
1012
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.prezi.spaghetti.haxe.gradle
2+
3+
import com.prezi.haxe.gradle.HaxeCommandBuilder
4+
import com.prezi.haxe.gradle.HaxeTestCompile
5+
import com.prezi.spaghetti.ReservedWords
6+
import com.prezi.spaghetti.haxe.HaxeGenerator
7+
import groovy.text.SimpleTemplateEngine
8+
import org.gradle.api.DomainObjectSet
9+
import org.gradle.language.base.LanguageSourceSet
10+
11+
/**
12+
* Created by lptr on 20/05/14.
13+
*/
14+
class HaxeTestCompileWithSpaghetti extends HaxeTestCompile {
15+
@Override
16+
protected HaxeCommandBuilder configureHaxeCommandBuilder(File output, DomainObjectSet<LanguageSourceSet> sources) {
17+
def builder = super.configureHaxeCommandBuilder(output, sources)
18+
19+
def engine = new SimpleTemplateEngine()
20+
def template = engine.createTemplate(HaxeTestCompileWithSpaghetti.class.getResource("/SpaghettiTest.hx"))
21+
new File(getTestsDirectory(), "SpaghettiTest.hx") << template.make(
22+
config: ReservedWords.CONFIG,
23+
haxeModule: HaxeGenerator.HAXE_MODULE_VAR,
24+
module: ReservedWords.INSTANCE,
25+
modules: ReservedWords.MODULES,
26+
)
27+
28+
return builder
29+
}
30+
}

gradle-spaghetti-haxe-plugin/src/main/groovy/com/prezi/spaghetti/haxe/gradle/MUnitWithSpaghetti.groovy

+28-49
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,46 @@
11
package com.prezi.spaghetti.haxe.gradle
22

3-
import com.prezi.haxe.gradle.HaxeCommandBuilder
4-
import com.prezi.haxe.gradle.HaxeSourceSet
53
import com.prezi.haxe.gradle.MUnit
6-
import com.prezi.spaghetti.ModuleBundle
7-
import org.gradle.api.DomainObjectSet
8-
import org.gradle.api.artifacts.Configuration
9-
import org.gradle.api.internal.DefaultDomainObjectSet
10-
import org.gradle.language.base.LanguageSourceSet
4+
import org.gradle.api.tasks.Input
5+
import org.gradle.api.tasks.InputDirectory
6+
import org.gradle.api.tasks.Optional
117

128
/**
13-
* Created by lptr on 27/04/14.
9+
* Created by lptr on 20/05/14.
1410
*/
1511
class MUnitWithSpaghetti extends MUnit {
1612

17-
final LinkedHashSet<Object> spaghettiResources = []
18-
public void spaghettiResources(Object... resources) {
19-
this.spaghettiResources.addAll(resources)
20-
}
21-
protected DomainObjectSet<LanguageSourceSet> getSpaghettiResourceSets() {
22-
def spaghettiResourceSets = spaghettiResources.collectMany { notationParser.parseNotation(it) }
23-
return new DefaultDomainObjectSet<LanguageSourceSet>(LanguageSourceSet, spaghettiResourceSets)
24-
}
25-
2613
@Override
27-
protected HaxeCommandBuilder configureHaxeCommandLine(File output, File workDir, DomainObjectSet<LanguageSourceSet> sources, Set<LanguageSourceSet> testSources, Map<String, File> allResources) {
28-
def builder = super.configureHaxeCommandLine(output, workDir, sources, testSources, allResources)
29-
30-
if (getTargetPlatform().name == "js") {
31-
// Extract Require JS
32-
def requireJsProps = new Properties()
33-
requireJsProps.load(this.class.getResourceAsStream("/META-INF/maven/org.webjars/requirejs/pom.properties"))
34-
def requireJsVersion = requireJsProps.getProperty("version")
35-
def requireJsFile = new File(workDir, "require.js")
36-
requireJsFile.delete()
37-
requireJsFile << this.class.getResourceAsStream("/META-INF/resources/webjars/requirejs/${requireJsVersion}/require.js")
14+
@Optional
15+
File getInputFile() {
16+
return super.getInputFile()
17+
}
3818

39-
// Collect all classpath configurations
40-
Set<Configuration> allClassPaths = []
41-
[sources, testSources].collectMany(allClassPaths) { DomainObjectSet<LanguageSourceSet> sourceSet ->
42-
def classPaths = sourceSet.withType(HaxeSourceSet).collect(new LinkedHashSet<Configuration>()) { HaxeSourceSet haxeSourceSet ->
43-
haxeSourceSet.compileClassPath
44-
}
45-
return classPaths
46-
}
19+
@InputDirectory
20+
File testApplication
4721

48-
// Copy current module's Spaghetti resources
49-
logger.debug "Copying spaghetti resources: {} into {}", getSpaghettiResourceSets()*.source*.srcDirs, workDir
50-
project.copy {
51-
from getSpaghettiResourceSets()*.source*.srcDirs
52-
into workDir
53-
}
22+
@Input
23+
String testApplicationName
5424

55-
// Append module locations
56-
def bundlerCommand = HaxeCommandUtils.spaghettiBundlerCommand("module", output, project.buildDir, allClassPaths, { ModuleBundle bundle ->
57-
bundle.extract(new File(workDir, bundle.name))
58-
return bundle.name + "/" + bundle.name
59-
})
60-
builder.append("-cmd", "haxe ${bundlerCommand.join(" ")}", )
25+
@Override
26+
protected String copyCompiledTest(File workDir) {
27+
// Extract Require JS
28+
def requireJsProps = new Properties()
29+
requireJsProps.load(this.class.getResourceAsStream("/META-INF/maven/org.webjars/requirejs/pom.properties"))
30+
def requireJsVersion = requireJsProps.getProperty("version")
31+
def requireJsFile = new File(workDir, "require.js")
32+
requireJsFile.delete()
33+
requireJsFile << this.class.getResourceAsStream("/META-INF/resources/webjars/requirejs/${requireJsVersion}/require.js")
34+
35+
logger.debug "Copying test application from {} to {}", getTestApplication(), workDir
36+
project.copy {
37+
from getTestApplication()
38+
into workDir
6139
}
62-
return builder
40+
return getTestApplicationName()
6341
}
6442

43+
@Override
6544
protected InputStream getMUnitJsHtmlTemplate() {
6645
return this.class.getResourceAsStream("/js_runner-html-with-require.mtt")
6746
}

0 commit comments

Comments
 (0)