Skip to content

Commit

Permalink
Pr/plugins 4430 fixed groovy version compatibility issues (#8)
Browse files Browse the repository at this point in the history
* Added support for Groovy 3 version and Added github workflows for CI & CD and Modified readme file

* Plugin version is now version id plus short hash
  • Loading branch information
AnilSetty authored Nov 19, 2024
1 parent 53b484a commit 8d95b5e
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 44 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/gradle-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Gradle CD

on:
push:
branches: [ "master" ]

jobs:

create-release:

permissions: write-all
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt-openj9'

- name: Set up Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Determine plugin version
id: getPluginVersion
run: |
# Get version from plugin.xml
pluginXmlVersion=$(grep -oP '<identifier .* version="\K[^"]+' src/main/zip/plugin.xml)
echo "pluginXmlVersion is $pluginXmlVersion"
# Get the latest short hash
latestShortHash=$(git rev-parse --short $GITHUB_SHA)
echo "latest short hash is $latestShortHash"
echo "value=$pluginXmlVersion.$latestShortHash" >> $GITHUB_OUTPUT
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Create plugin zip
run: ./gradlew "-PpluginVersion=${{ steps.getPluginVersion.outputs.value }}"

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.getPluginVersion.outputs.value }}
files: "build/distributions/*.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Gradle Project

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build-gradle-project:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt-openj9'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Run build
run: ./gradlew build

- name: Run tests
run: ./gradlew test
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip
The packaged zip is located in the releases folder. No special steps are required for installation. See Installing plug-ins in UrbanCode Deploy. Download this zip file if you wish to skip the manual build step. Otherwise, download the entire Ansible-Toolkit-UCD project and run the `gradle` command in the top level folder. This should compile the code and create a new distributable zip within the `build/distributions` folder. Use this command if you wish to make your own changes to the plugin.

### History
Version 54
- Added support for Groovy 3 version
Version 53
- The Ansible Toolkit is now built through Gradle. All Ant and Ivy build pieces have been removed.
Version 52
Expand All @@ -21,5 +23,5 @@ This plugin is protected under the [Eclipse Public 1.0 License](http://www.eclip
### How to build the plugin from command line:

1. Navigate to the base folder of the project through command line.
2. Make sure that there is a build.gradle file in the root directory and execute the 'gradle' command.
2. Make sure that there is a build.gradle file in the root directory and execute the 'gradlew' command.
3. The built plugin is located at `build/distributions/Ansible-Toolkit-UCD-vdev.zip`
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@
import org.apache.tools.ant.filters.ReplaceTokens

def pluginName="Ansible-Toolkit-UCD"
def pluginVersion = project.hasProperty('pluginVersion') ? project.getProperty('pluginVersion') : 'dev'

String pluginVersion
if (project.hasProperty('pluginVersion')) {
pluginVersion = project.getProperty('pluginVersion')
} else {
def pluginNode = new XmlParser().parse(new File('src/main/zip/plugin.xml'))
pluginVersion = "${pluginNode.header.identifier.@version[0]}.dev"
}

apply plugin: 'groovy'

defaultTasks 'distPlugin'
defaultTasks("dist")

def buildLocaleDir = 'build/locale'
def buildUtilDir = 'build/util'
Expand Down Expand Up @@ -131,7 +138,7 @@ task copyi18n(type: Copy) {
into outputDir
}

task distPlugin(type: Zip, dependsOn: ['compileGroovy', 'gatherI18n']) {
task dist(type: Zip, dependsOn: ['compileGroovy', 'gatherI18n']) {
from(sourceSets.zip.groovy.srcDirs) {
filter(ReplaceTokens, tokens: [RELEASE_VERSION: pluginVersion])
}
Expand Down
69 changes: 69 additions & 0 deletions src/main/groovy/com/urbancode/air/plugin/tool/AirPluginTool.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
package com.urbancode.air.plugin.tool

class AirPluginTool {

//**************************************************************************
// CLASS
//**************************************************************************
//**************************************************************************
// INSTANCE
//**************************************************************************
final public def isWindows = (System.getProperty('os.name') =~ /(?i)windows/).find()
def out = System.out;
def err = System.err;
private def inPropsFile;
private def outPropsFile;
def outProps;
public AirPluginTool(def inFile, def outFile){
inPropsFile = inFile;
outPropsFile = outFile;
outProps = new Properties();
}
public Properties getStepProperties() {
def props = new Properties();
def inputPropsFile = this.inPropsFile;
def inputPropsStream = null;
try {
inputPropsStream = new FileInputStream(inputPropsFile);
props.load(inputPropsStream);
}
catch (IOException e) {
throw new RuntimeException(e);
}
finally {
inputPropsStream.close();
}
return props;
}
public void setOutputProperty(String name, String value) {
this.outProps.setProperty(name, value);
}
public void setOutputProperties() {
OutputStream outputPropsStream = null;
try {
outputPropsStream = new FileOutputStream(this.outPropsFile);
outProps.store(outputPropsStream, "");
}
finally {
if (outputPropsStream != null) {
outputPropsStream.close();
}
}
}
public String getAuthToken() {
String authToken = System.getenv("AUTH_TOKEN");
return "{\"token\" : \"" + authToken + "\"}";
}
public String getAuthTokenUsername() {
return "PasswordIsAuthToken";
}
public void storeOutputProperties() {
setOutputProperties();
}
}
5 changes: 2 additions & 3 deletions src/main/zip/apt.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/apt_key.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/ashell.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/command.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/copy.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/file.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/getBuiltinAnsibleProperties.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/get_url.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
3 changes: 3 additions & 0 deletions src/main/zip/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,8 @@
<release-note plugin-version="53">
The Ansible Toolkit is now built through Gradle. All Ant and Ivy build pieces have been removed.
</release-note>
<release-note plugin-version="54">
Added support for Groovy 3 version
</release-note>
</release-notes>
</pluginInfo>
5 changes: 2 additions & 3 deletions src/main/zip/lineinfile.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/pip.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
2 changes: 1 addition & 1 deletion src/main/zip/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<identifier id="com.urbancode.air.plugin.AnsibleToolkit" name="AnsibleToolkit" version="53"/>
<identifier id="com.urbancode.air.plugin.AnsibleToolkit" name="AnsibleToolkit" version="54"/>
<description>
This plug-in includes steps that integrate with Ansible.
</description>
Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/service.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
5 changes: 2 additions & 3 deletions src/main/zip/shell.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* © Copyright IBM Corporation 2016, 2017.
* © Copyright IBM Corporation 2016, 2024.
* This is licensed under the following license.
* The Eclipse Public 1.0 License (http://www.eclipse.org/legal/epl-v10.html)
* U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

import com.urbancode.air.AirPluginTool;
import com.urbancode.air.plugin.tool.AirPluginTool

def apTool = new AirPluginTool(this.args[0], this.args[1]) //assuming that args[0] is input props file and args[1] is output props file

Expand Down
Loading

0 comments on commit 8d95b5e

Please sign in to comment.