Skip to content
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

Produce independent mvn packages for java bindings #98

Merged
merged 16 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,276 changes: 638 additions & 638 deletions packages/codemaker/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/jsii-build-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fingerprint": "erGu0jB21wjK5tVE/Bxl3I0FHLhVRCdsAArpsGrQYQE=",
"fingerprint": "6QpycDQPS3xZIJX4/Y1LasffU7gz9N7tbFkH3hBTOVM=",
"name": "@scope/jsii-calc-base",
"schema": "jsii/1.0",
"targets": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"methods": [
{
"docs": {
"returns": "the name of the class (to verify native type names are created for derived classes)."
"return": "the name of the class (to verify native type names are created for derived classes)."
},
"name": "typeName",
"returns": {
Expand Down
4 changes: 2 additions & 2 deletions packages/jsii-calc-lib/test/assembly.jsii
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fingerprint": "iTJNVeXmbHGdxmTUBtoj+5KUK6isPr0eFtSbPL2963A=",
"fingerprint": "7As+xCfP2si1HVa+9kEPVWNjr8tSX6yChFrxTnmRnPY=",
"dependencies": {
"@scope/jsii-calc-base": {
"targets": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"methods": [
{
"docs": {
"returns": "the name of the class (to verify native type names are created for derived classes)."
"return": "the name of the class (to verify native type names are created for derived classes)."
},
"name": "typeName",
"returns": {
Expand Down
14 changes: 7 additions & 7 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fingerprint": "A9t4hQIy+Vmt9bbmqQm7+5Lq7PeGlj50VW4ndWt9Z+w=",
"fingerprint": "c2wkEzqW3dYGRkmS3ds0ZKdviGDUFxVQPNljR3TK2XU=",
"bundled": {
"jsii-calc-bundled": "^0.5.0-beta"
},
Expand Down Expand Up @@ -58,7 +58,7 @@
"methods": [
{
"docs": {
"returns": "the name of the class (to verify native type names are created for derived classes)."
"return": "the name of the class (to verify native type names are created for derived classes)."
},
"name": "typeName",
"returns": {
Expand Down Expand Up @@ -1190,7 +1190,7 @@
{
"docs": {
"comment": "Say goodbye.",
"returns": "A goodbye blessing."
"return": "A goodbye blessing."
},
"name": "goodbye",
"returns": {
Expand Down Expand Up @@ -1280,7 +1280,7 @@
{
"docs": {
"comment": "Returns another random number.",
"returns": "A random number."
"return": "A random number."
},
"name": "next",
"returns": {
Expand Down Expand Up @@ -1723,7 +1723,7 @@
{
"docs": {
"comment": "Reads a local resource file (resource.txt) asynchronously.",
"returns": "\"Hello, resource!\""
"return": "\"Hello, resource!\""
},
"name": "fsReadFile",
"returns": {
Expand All @@ -1734,7 +1734,7 @@
{
"docs": {
"comment": "Sync version of fsReadFile.",
"returns": "\"Hello, resource! SYNC!\""
"return": "\"Hello, resource! SYNC!\""
},
"name": "fsReadFileSync",
"returns": {
Expand All @@ -1744,7 +1744,7 @@
{
"docs": {
"comment": "Uses node.js \"crypto\" module to calculate sha256 of a string.",
"returns": "\"6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\""
"return": "\"6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50\""
},
"name": "cryptoSha256",
"returns": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void IgnoresReturns()
{
Docs docs = new Docs
{
{ "returns", "my comment" }
{ "return", "my comment" }
};

string actual = Render(docs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void IncludesReturns()
{
Docs docs = new Docs
{
{ "returns", "my comment" }
{ "return", "my comment" }
};

string actual = Render(docs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void IncludesReturns()
{
Docs docs = new Docs
{
{ "returns", "my comment" }
{ "return", "my comment" }
};

string actual = Render(docs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void IgnoresReturns()
{
Docs docs = new Docs
{
{ "returns", "my comment" }
{ "return", "my comment" }
};

string actual = Render(docs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class DocCommentGeneratorBase<T>
{
"comment",
"param",
"returns",
"return",
});

public DocCommentGeneratorBase(T documentable)
Expand Down Expand Up @@ -67,12 +67,12 @@ protected IEnumerable<XmlNodeSyntax> GetRemarksNodes()

protected IEnumerable<XmlNodeSyntax> GetReturnsNodes()
{
if (Documentable.Docs?.ContainsKey("returns") != true)
if (Documentable.Docs?.ContainsKey("return") != true)
{
yield break;
}

string text = Documentable.Docs["returns"];
string text = Documentable.Docs["return"];

yield return SF.XmlText(" ").WithLeadingTrivia(SF.DocumentationCommentExterior(" "));
yield return SF.XmlReturnsElement(GetXmlNodes(text).ToArray());
Expand Down
6 changes: 3 additions & 3 deletions packages/jsii-dotnet-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"devDependencies": {
"@scope/jsii-calc-lib": "^0.5.0-beta",
"jsii-calc": "^0.5.0-beta",
"jsii-pacmak": "^0.5.0-beta"
"jsii-pacmak": "^0.5.0-beta",
"jsii-runtime": "^0.5.0-beta"
},
"dependencies": {
"jsii-dotnet-jsonmodel": "^0.5.0-beta",
"jsii-runtime": "^0.5.0-beta"
"jsii-dotnet-jsonmodel": "^0.5.0-beta"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions packages/jsii-java-runtime-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
!*.js
maven-repo
test-maven-repo
conf
6 changes: 6 additions & 0 deletions packages/jsii-java-runtime-test/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.sh
*.t.js
project
test-project
test-maven-repo
conf
21 changes: 21 additions & 0 deletions packages/jsii-java-runtime-test/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail

# Generates the necessary files to test the JSII runtime
# * Java bindings for jsii-calc (and it's JSII dependencies)
# * A maven user settings file to allow maven to use local repositories appropriately
# * A POM file for the test project, that references the dependencies correctly
# Executing this script is required for the test-project to be buildable

mkdir -p conf
/usr/bin/env node ./user.xml.t.js > conf/user.xml

staging="maven-repo"
mkdir -p ${staging}
for ASSM in $(node toposort.js $(find ./node_modules/jsii-calc -follow -name .jsii)); do
echo "Generating java bindings for ${ASSM}"
jsii-pacmak --target java --outdir ${staging} $(dirname ${ASSM}) --mvn-settings=${PWD}/conf/user.xml
done

# generate pom.xml and JsiiVersion.java with version from package.json
/usr/bin/env node ./pom.xml.t.js > ./project/pom.xml
11 changes: 11 additions & 0 deletions packages/jsii-java-runtime-test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions packages/jsii-java-runtime-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "jsii-java-runtime-test",
"version": "0.5.0-beta",
"description": "Tests for the Java client for jsii runtime",
"private": true,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "/bin/bash ./generate.sh",
"test": "cd project && mvn test --settings=../conf/user.xml"
},
"devDependencies": {
"@types/node": "^9.6.18",
"jsii-calc": "^0.5.0-beta",
"jsii-java-runtime": "^0.5.0-beta",
"jsii-pacmak": "^0.5.0-beta"
},
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com"
},
"license": "LicenseRef-LICENSE",
"repository": {
"type": "git",
"url": "git://github.com/awslabs/jsii"
}
}
51 changes: 51 additions & 0 deletions packages/jsii-java-runtime-test/pom.xml.t.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { groupId, artifactId, version } = require('jsii-java-runtime').maven;

process.stdout.write(`<?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>

<!-- Generated by ${__filename} at ${new Date().toISOString()} -->

<groupId>${groupId}</groupId>
<artifactId>${artifactId}-test</artifactId>
<version>${version}</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.jsii.tests</groupId>
<artifactId>calculator</artifactId>
<version>[0.5.0-beta,)</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
`);
30 changes: 30 additions & 0 deletions packages/jsii-java-runtime-test/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
!index.js
.idea
pom.xml

.classpath
.project
.settings

# IntelliJ
*.iml

# Created by https://www.gitignore.io/api/maven

### Maven ###
target

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar


# End of https://www.gitignore.io/api/maven
41 changes: 41 additions & 0 deletions packages/jsii-java-runtime-test/toposort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This command takes a set of JSII module files as it's argument, and outputs
* the same file names after having topologically sorted them according to their
* declared dependencies.
*/

const fs = require('fs');

const modules = {};

for (const file of process.argv.slice(2)) {
const module = JSON.parse(fs.readFileSync(file, { encoding: 'utf-8' }));
modules[module.name] = {
file,
dependsOn: Object.keys(module.dependencies || {})
};
}

let sorted = [];
const roots = Object.keys(modules).filter(name => modules[name].dependsOn.length === 0);
while (roots.length != 0) {
const root = roots.pop();
sorted = sorted.concat(modules[root].file);
delete modules[root];
for (const name of Object.keys(modules)) {
const node = modules[name];
node.dependsOn = node.dependsOn.filter(n => n !== root);
if (node.dependsOn.length === 0) {
roots.push(name);
}
}
}

if (Object.keys(modules).length > 0) {
console.error(`There seems to be a cycle in the graph: ${JSON.stringify(modules, null, 2)}`);
exit(-1);
}

for (const file of sorted) {
console.log(file);
}
Loading