Skip to content
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
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build
on:
push:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
architecture: x64
- name: Maven Build
run: mvn clean install

4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 8 (Corretto)
- name: Set up JDK (Corretto)
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build with Maven
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Pull Request

on:
pull_request:
branches:
- main
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, windows]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
- name: Maven Build
run: mvn clean install
106 changes: 106 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Release

on:
workflow_dispatch:
inputs:
releaseVersion:
description: Release Version
required: true
default: 3.0.0
snapshotVersion:
description: Snapshot Version
required: true
default: 3.0.1-SNAPSHOT

run-name: 'version set to ${{ github.event.inputs.releaseVersion }} for release'

jobs:
release-project:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Set up JDK Corretto
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
architecture: x64

- name: "Configure Git"
run: |
git fetch
git checkout ${{ github.event.inputs.branch }}
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: "Maven: Set Release Version"
run: mvn versions:set -DnewVersion=${{ github.event.inputs.releaseVersion }}

- name: Setup Maven settings.xml
uses: whelk-io/maven-settings-xml-action@v11
with:
servers:
'[
{
"id": "github",
"username": "${env.GITHUB_USERNAME}",
"password": "${env.GITHUB_TOKEN}"
}
]'

- name: Build Project
run: mvn clean install

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
BUILD_ENV: 'github-actions'

- name: "Git: Commit Release Version"
run: |
git add '**pom.xml'
git commit -m "version set to ${{ github.event.inputs.releaseVersion }} for release"

- name: "Maven: Set Snapshot Version"
run: mvn versions:set -DnewVersion=${{ github.event.inputs.snapshotVersion }}

- name: "Git: Commit Snapshot Version"
run: |
git add '**pom.xml'
git commit -m "version set to ${{ github.event.inputs.snapshotVersion }} for development"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.event.inputs.releaseVersion }}
release_name: Release ${{ github.event.inputs.releaseVersion }}
body: |
Changes in this Release:
- First Change
- Second Change
draft: false
prerelease: false

- name: "Git: Push Changes"
run: |
git checkout -B ${{ github.event.inputs.releaseVersion }}
git push --set-upstream origin ${{ github.event.inputs.releaseVersion }}
git checkout -B master
git push --set-upstream origin master
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ classes
.DS_Store
nb-configuration.xml
context.xml
*.versionsBackup
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
<version>2.0.13</version>
<version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
<version>2.0.13</version>
<version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
4 changes: 1 addition & 3 deletions odata2-annotation-processor/annotation-processor-ref/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor</artifactId>
<version>2.0.13</version>
<version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down Expand Up @@ -90,7 +90,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
Expand All @@ -102,7 +101,6 @@
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF 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.
*
* 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.apache.olingo.odata2.annotation.processor.ref.model;

Expand All @@ -23,74 +19,76 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

/**
*
*/
public class ResourceHelper {

public static byte[] loadAsByte(final String resource) {
return load(resource, new byte[0]);
}

public static byte[] load(final String resource, final byte[] defaultResult) {
InputStream instream = null;
try {
instream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
if (instream == null) {
return defaultResult;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int b = 0;
while ((b = instream.read()) != -1) {
stream.write(b);
}
public static byte[] loadAsByte(final String resource) {
return load(resource, new byte[0]);
}

return stream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (instream != null) {
public static byte[] load(final String resource, final byte[] defaultResult) {
InputStream instream = null;
try {
instream.close();
} catch (IOException ex) {}
}
instream = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(resource);
if (instream == null) {
return defaultResult;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int b = 0;
while ((b = instream.read()) != -1) {
stream.write(b);
}

return stream.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (instream != null) {
try {
instream.close();
} catch (IOException ex) {
}
}
}
}

public enum Format {
BMP, JPEG, PNG, GIF
}
}

public enum Format {
BMP, JPEG, PNG, GIF
};
public static byte[] generateImage() {
return generateImage(Format.PNG);
}

public static byte[] generateImage() {
return generateImage(Format.PNG);
}
public static byte[] generateImage(final Format format) {
try {
int width = 320;
int height = 320;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
WritableRaster raster = image.getRaster();

public static byte[] generateImage(final Format format) {
try {
int width = 320;
int height = 320;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
WritableRaster raster = image.getRaster();
int mod = format.ordinal() + 2;
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
if (((h / 32) + (w / 32)) % mod == 0) {
raster.setSample(w, h, 0, 0);
} else {
raster.setSample(w, h, 0, 1);
}
}
}

int mod = format.ordinal() + 2;
for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) {
if (((h / 32) + (w / 32)) % mod == 0) {
raster.setSample(w, h, 0, 0);
} else {
raster.setSample(w, h, 0, 1);
}
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ImageIO.write(image, format.name(), out);
return out.toByteArray();
} catch (IOException ex) {
return new byte[0];
}
}

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
ImageIO.write(image, format.name(), out);
return out.toByteArray();
} catch (IOException ex) {
return new byte[0];
}
}
}
Loading