Skip to content

Commit

Permalink
Fix math package with 0.981.0 ballerina version
Browse files Browse the repository at this point in the history
  • Loading branch information
lankavitharana committed Aug 27, 2018
1 parent 33ea628 commit b446ce9
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 277 deletions.
35 changes: 35 additions & 0 deletions assembly/balo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
~ /*
~ * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ *
~ * 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.
~ */
-->
<assembly>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>/</baseDirectory>
<id>ballerina-binary-repo</id>
<formats>
<format>zip</format>
</formats>

<fileSets>
<fileSet>
<directory>${project.build.directory}/generated-balo</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
223 changes: 148 additions & 75 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,96 +18,115 @@

<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/maven-v4_0_0.xsd">

<parent>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-parent</artifactId>
<version>0.89</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.wso2.ballerinalang</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>ballerina-math</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<version>0.981.0-SNAPSHOT</version>
<name>Ballerina - Native Implementation</name>
<url>http://ballerinalang.org</url>


<repositories>
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>

<repository>
<id>wso2.releases</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>

<pluginRepositories>

<pluginRepository>
<id>wso2.releases</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</pluginRepository>

<pluginRepository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</pluginRepository>

</pluginRepositories>


<dependencies>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-core</artifactId>
<version>0.89</version>
<version>${ballerina.version}</version>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>annotation-processor</artifactId>
<version>0.89</version>
<artifactId>ballerina-builtin</artifactId>
<version>${ballerina.version}</version>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-native</artifactId>
<version>0.89</version>
<artifactId>ballerina-builtin</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
<version>${ballerina.version}</version>
</dependency>
<dependency>
<groupId>org.ballerinalang</groupId>
<artifactId>ballerina-runtime</artifactId>
<type>zip</type>
<classifier>ballerina-binary-repo</classifier>
<version>${ballerina.version}</version>
</dependency>

<!--<dependency>-->
<!--<groupId>org.ballerinalang</groupId>-->
<!--<artifactId>ballerina-logging</artifactId>-->
<!--</dependency>-->
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>ballerina/**</exclude>
</excludes>
</resource>

<!-- copy built-in ballerina sources to the jar -->
<resource>
<directory>${generated.ballerina.source.directory}</directory>
<targetPath>META-INF/natives</targetPath>
</resource>
</resources>
<plugins>
<!-- For ballerina natives processing/validation -->
<!--<plugin>-->
<!--<groupId>org.codehaus.mojo</groupId>-->
<!--<artifactId>exec-maven-plugin</artifactId>-->
<!--<version>1.1.1</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>process-classes</phase>-->
<!--<goals>-->
<!--<goal>java</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<mainClass>org.ballerinalang.natives.annotation.processor.BuiltinPackageValidator</mainClass>-->
<!--<arguments>-->
<!--<argument>${generated.ballerina.source.directory}</argument>-->
<!--</arguments>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${wso2.maven.compiler.source}</source>
<target>${wso2.maven.compiler.target}</target>
</configuration>
</plugin>
<!-- For ballerina annotation processing -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<configuration>
<processors>
<processor>org.ballerinalang.natives.annotation.processor.BallerinaAnnotationProcessor</processor>
<processor>org.ballerinalang.codegen.BallerinaAnnotationProcessor</processor>
</processors>
<options>
<packageName>${native.constructs.provider.package1}</packageName>
<className>${native.constructs.provider.class1}</className>
<srcDir>${ballerina.source.directory}</srcDir>
<targetDir>${generated.ballerina.source.directory}</targetDir>
<pkgRepositoryClass>${package.repository.provider.class}</pkgRepositoryClass>
<isSystemPkgRepository>${ballerina.system.package.repository}</isSystemPkgRepository>
<nativeEntityProviderPackage>org.wso2.samplecon.generated.providers</nativeEntityProviderPackage>
<nativeEntityProviderClass>StandardNativeElementProvider</nativeEntityProviderClass>
</options>
</configuration>
<executions>
Expand All @@ -120,24 +139,78 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<inherited>false</inherited>
<executions>
<!-- Following execution unpacks balo dependencies (ballerina-binary-repo) -->
<execution>
<id>unpack-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeClassifiers>ballerina-binary-repo</includeClassifiers>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<!-- Following execution generates balo for mongodb package -->
<execution>
<id>gen-balo</id>
<goals>
<goal>java</goal>
</goals>
<phase>compile</phase>
<configuration>
<systemProperties>
<systemProperty>
<key>BALLERINA_DEV_MODE_COMPILE</key>
<value>true</value>
</systemProperty>
</systemProperties>
<arguments>
<argument>false</argument>
<argument>${basedir}/src/main/ballerina/</argument>
<argument>${project.build.directory}/generated-balo/repo/wso2</argument>
<argument>${project.build.directory}</argument>
<argument>${project.version}</argument>
</arguments>
<mainClass>org.ballerinalang.stdlib.utils.GenerateBalo</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distribution</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<configuration>
<descriptorSourceDirectory>assembly</descriptorSourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<properties>
<!-- Path to the ballerina source directory -->
<ballerina.source.directory>${project.build.directory}/../src/main/ballerina</ballerina.source.directory>
<package.repository.provider.class>org.wso2.ballerina.math.repository.BallerinaBuiltinPackageRepository
</package.repository.provider.class>
<ballerina.system.package.repository>false</ballerina.system.package.repository>

<native.constructs.provider.package1>org.wso2.ballerina.math</native.constructs.provider.package1>
<native.constructs.provider.class1>MathNativeConstructsProvider</native.constructs.provider.class1>
<ballerina.package.repository.provider.class>BallerinaBuiltinPackageRepository
</ballerina.package.repository.provider.class>

<!-- Path to the generated natives ballerina files temp directory -->
<!--<generated.ballerina.source.directory>${project.build.directory}/natives</generated.ballerina.source.directory>-->
<generated.ballerina.source.directory>${project.build.directory}/../src/main/ballerina</generated.ballerina.source.directory>
<ballerina.version>0.981.0</ballerina.version>
<maven.compiler.plugin.version>3.5.1</maven.compiler.plugin.version>
<wso2.maven.compiler.source>1.8</wso2.maven.compiler.source>
<wso2.maven.compiler.target>1.8</wso2.maven.compiler.target>
</properties>
</project>
3 changes: 3 additions & 0 deletions src/main/ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[project]
org-name="wso2"
version="0.0.0"
9 changes: 9 additions & 0 deletions src/main/ballerina/math/natives.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

documentation {
Add two integers and return the value.

P{{a}} Value to be added
P{{b}} Value to be added
R{{}} Added value
}
public extern function addInt(int a, int b) returns int;
20 changes: 0 additions & 20 deletions src/main/ballerina/wso2/ballerina/math/natives.bal

This file was deleted.

50 changes: 50 additions & 0 deletions src/main/java/org/wso2/ballerina/math/AddInt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.wso2.ballerina.math;

import org.ballerinalang.bre.Context;
import org.ballerinalang.bre.bvm.BlockingNativeCallableUnit;
import org.ballerinalang.model.types.TypeKind;
import org.ballerinalang.model.values.BInteger;
import org.ballerinalang.natives.annotations.Argument;
import org.ballerinalang.natives.annotations.BallerinaFunction;
import org.ballerinalang.natives.annotations.ReturnType;

/**
* Native function wso2.ballerina.math:addInt.
*/
@BallerinaFunction(
orgName = "wso2",
packageName = "math:0.0.0",
functionName = "addInt",
args = {@Argument(name = "a", type = TypeKind.INT),
@Argument(name = "b", type = TypeKind.INT)},
returnType = {@ReturnType(type = TypeKind.INT)},
isPublic = true
)
public class AddInt extends BlockingNativeCallableUnit {

@Override
public void execute(Context context) {
System.out.println("**** Method addInt called ****");
long a = context.getIntArgument(0);
long b = context.getIntArgument(1);
BInteger result = new BInteger(a + b);
context.setReturnValues(result);
}
}
Loading

0 comments on commit b446ce9

Please sign in to comment.