Skip to content

Commit

Permalink
Add CI and Update HttpResponseMessage API (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragnagopa committed Oct 22, 2018
1 parent 0770a58 commit 707c594
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -27,3 +27,7 @@ hs_err_pid*
/.classpath
/.settings/*
.project
/azure-maven-archetypes/
/azure-maven-plugins/
/ciTestDir/*
/target/
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,10 @@ This project contains the Java API for building functions for the Azure Function

* Java 8

## Parent POM

Please see for details on Parent POM https://github.com/Microsoft/maven-java-parent

## Summary

Azure Functions is capable of running Function Apps that may contain one or more functions grouped. A function should be a stateless method to process input and produce output. Although you are allowed to write instance methods, your function must not depend on any instance fields of the class. You need to make sure all the function methods are `public` accessible.
Expand Down
9 changes: 4 additions & 5 deletions appveyor.yml
Expand Up @@ -18,12 +18,11 @@ install:
- cmd: echo %JAVA_HOME%
- ps: Get-Command mvn
- cmd: mvn -v
- ps: Get-Command nuget

build_script:
- cmd: mvn clean package -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B
- ps: mkdir .pkg
- cmd: npm i -g azure-functions-core-tools

build_script:
- ps: '& .\build.ps1'

artifacts:
- path: 'azure-functions-java-library/target/**.jar'

Expand Down
62 changes: 62 additions & 0 deletions build.ps1
@@ -0,0 +1,62 @@
# A function that checks exit codes and fails script if an error is found
function StopOnFailedExecution {
if ($LastExitCode)
{
exit $LastExitCode
}
}

# Clone and install function maven archetype
git clone https://github.com/Microsoft/azure-maven-archetypes.git -b develop
Push-Location -Path "./azure-maven-archetypes/azure-functions-archetype" -StackName libraryDir
Write-Host "Build and install azure-maven-archetypes"
cmd.exe /c '.\..\..\mvnBuildSkipTests.bat'
StopOnFailedExecution
Pop-Location -StackName "libraryDir"
$archetypePom = Get-Content ".\azure-maven-archetypes\azure-functions-archetype\pom.xml" -Raw
$archetypePom -match "<version>(.*)</version>"
$atchetypeVersion = $matches[1]
Write-Host "atchetypeVersion: " $atchetypeVersion

# Clone and install function maven plugin
git clone https://github.com/Microsoft/azure-maven-plugins.git -b develop
Push-Location -Path "./azure-maven-plugins" -StackName libraryDir
Write-Host "Build and install azure-functions-maven-plugins"
cmd.exe /c '.\..\mvnBuildSkipTests.bat'
StopOnFailedExecution
Pop-Location -StackName "libraryDir"
#$pluginPom = Get-Content ".\azure-maven-plugins\azure-functions-maven-plugin\pom.xml" -Raw
#$pluginPom -match "<version>(.*)</version>"
$pluginVersion = "1.0.0-beta-8-SNAPSHOT"
Write-Host "pluginVersion: " $pluginVersion


# Get azure-functions-library
Write-Host "Build and install azure-functions-java-library"
cmd.exe /c '.\mvnBuild.bat'
$libraryPom = Get-Content "pom.xml" -Raw
$libraryPom -match "<version>(.*)</version>"
$libraryVersion = $matches[1]
Write-Host "libraryVersion: " $libraryVersion

# Generate HttpTrigger Function via archetype version built above
md -Name ciTestDir
Push-Location -Path "./ciTestDir" -StackName libraryDir
Write-Host "Generating project with archetype"
mvn archetype:generate -DarchetypeCatalog="local" -DarchetypeGroupId="com.microsoft.azure" -DarchetypeArtifactId="azure-functions-archetype" -DarchetypeVersion="$atchetypeVersion" -DgroupId="com.microsoft" -DartifactId="e2etestproject" -Dversion="1.0-SNAPSHOT" -Dpackage="com.microsoft" -DappRegion="westus" -DresourceGroup="e2etest-java-functions-group" -DappName="e2etest-java-functions" -B
StopOnFailedExecution
Pop-Location -StackName "libraryDir"

#Build HttpTrigger Function

Push-Location -Path "./ciTestDir/e2etestproject" -StackName libraryDir
Remove-Item -Recurse -Force "src/test" -ErrorAction Ignore
cmd.exe /c .\..\..\updateVersions.bat $libraryVersion $pluginVersion
StopOnFailedExecution
#Update versions in the HttpTrigger pom.xml
mvn clean package -DskipTests
StopOnFailedExecution
Pop-Location -StackName "libraryDir"



1 change: 1 addition & 0 deletions mvnBuild.bat
@@ -0,0 +1 @@
mvn clean install -U -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B -Dgpg.skip
1 change: 1 addition & 0 deletions mvnBuildSkipTests.bat
@@ -0,0 +1 @@
mvn clean install -Dmaven.javadoc.skip=true -Dmaven.test.skip -U -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B
Expand Up @@ -20,15 +20,15 @@ public interface HttpResponseMessage {
*
* @return the status code set on the HttpResponseMessage instance.
*/
HttpStatusType getHttpStatus();
HttpStatusType getStatus();

/**
* Returns the HTTP status code set on the HttpResponseMessage instance.
*
* @return the status code set on the HttpResponseMessage instance.
*/
default int getStatus() {
return getHttpStatus().value();
default int getStatusCode() {
return getStatus().value();
}

/**
Expand Down
8 changes: 8 additions & 0 deletions updateVersions.bat
@@ -0,0 +1,8 @@

set libraryVersion=%1

echo %libraryVersion%
set pluginVersion=%2
echo %pluginVersion%
call mvn versions:set-property -Dproperty=azure.functions.java.library.version -DnewVersion=%libraryVersion%
call mvn versions:set-property -Dproperty=azure.functions.maven.plugin.version -DnewVersion=%pluginVersion%

0 comments on commit 707c594

Please sign in to comment.