-
Notifications
You must be signed in to change notification settings - Fork 0
Init plugins #1
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
Open
lemonman96
wants to merge
2
commits into
main
Choose a base branch
from
init-plugins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Init plugins #1
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| .gradle | ||
| **/build/ | ||
| !**/src/**/build/ | ||
|
|
||
| # Ignore Gradle GUI config | ||
| gradle-app.setting | ||
|
|
||
| # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
| !gradle-wrapper.jar | ||
|
|
||
| # Avoid ignore Gradle wrappper properties | ||
| !gradle-wrapper.properties | ||
|
|
||
| # Cache of project | ||
| .gradletasknamecache | ||
|
|
||
| # Eclipse Gradle plugin generated files | ||
| # Eclipse Core | ||
| .project | ||
| # JDT-specific (Eclipse Java Development Tools) | ||
| .classpath | ||
|
|
||
| # Compiled class file | ||
| *.class | ||
|
|
||
| # Log file | ||
| *.log | ||
|
|
||
| # BlueJ files | ||
| *.ctxt | ||
|
|
||
| # Mobile Tools for Java (J2ME) | ||
| .mtj.tmp/ | ||
|
|
||
| # Package Files # | ||
| *.jar | ||
| *.war | ||
| *.nar | ||
| *.ear | ||
| *.zip | ||
| *.tar.gz | ||
| *.rar | ||
|
|
||
| # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
| hs_err_pid* | ||
| replay_pid* | ||
|
|
||
| .idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # OSH Gradle Plugins | ||
|
|
||
| Project containing common build files for osh projects, as well as a plugin containing common build tasks | ||
|
|
||
| ## Usage instructions | ||
|
|
||
| ### Common Build Files | ||
|
|
||
| Include this repository as a git submodule, and use | ||
| ``` | ||
| apply from: 'path_to_submodules/osh-gradle-plugins/common/common.gradle' | ||
| apply from: 'path_to_submodules/osh-gradle-plugins/common/release.gradle' | ||
| ``` | ||
|
|
||
| ### Plugin | ||
|
|
||
| If pulling in as a submodule, then use `includeBuild path_to_submodules/osh-gradle-plugins` in your `settings.gradle` and declare plugin normally: | ||
|
|
||
| ``` | ||
| plugins { | ||
| id 'org.sensorhub.osh-plugin' | ||
| } | ||
| ``` | ||
| or | ||
| `apply plugin: 'org.sensorhub.osh-plugin'` | ||
|
|
||
| If not pulling in as a submodule, and this plugin is hosted on the gradle plugin repository, then a simple plugin declaration will suffice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| plugins { | ||
| id 'com.gradle.plugin-publish' version '2.0.0' | ||
| id 'java-gradle-plugin' | ||
| id 'groovy' | ||
| } | ||
|
|
||
| group = 'org.sensorhub' | ||
| version = '1.0' | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| maven { | ||
| url "https://plugins.gradle.org/m2/" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation localGroovy() | ||
| implementation 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.1.0' | ||
| } | ||
|
|
||
| gradlePlugin { | ||
| website = 'https://opensensorhub.org/' | ||
| vcsUrl = 'https://github.com/opensensorhub/osh-gradle-plugins' | ||
| plugins { | ||
| register('osh-plugin') { | ||
| id = 'org.sensorhub.osh-plugin' | ||
| displayName = 'OSH Gradle Plugin' | ||
| description = 'Gradle tasks for building, publishing and releasing gradle based osh drivers' | ||
| tags.addAll('osh', 'opensensorhub') | ||
| implementationClass = 'org.sensorhub.OshPlugin' | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,239 @@ | ||
| import java.nio.file.*; | ||
|
|
||
| ext.oshCoreVersion = '2.0.0' | ||
|
|
||
|
|
||
| buildscript { | ||
| repositories { | ||
| maven { | ||
| url "https://plugins.gradle.org/m2/" | ||
| } | ||
| } | ||
| dependencies { | ||
| classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.1.0" | ||
| } | ||
| } | ||
|
|
||
|
|
||
| allprojects { | ||
| group = 'org.sensorhub' | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| // set build number to HEAD SHA-1 | ||
| def stdout = new ByteArrayOutputStream() | ||
| exec { | ||
| commandLine('git', 'rev-parse', '--short', 'HEAD') | ||
| standardOutput = stdout | ||
| // hide errors and don't throw exception if not a git repo | ||
| errorOutput = new ByteArrayOutputStream() | ||
| ignoreExitValue = true | ||
| } | ||
| ext.buildNumber = "$stdout".trim() | ||
|
|
||
| afterEvaluate { project -> | ||
| if (project.hasProperty('sourceCompatibility')) { | ||
| project.sourceCompatibility = 17 | ||
| project.targetCompatibility = 17 | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| subprojects { | ||
| apply plugin: 'java-library' | ||
| apply plugin: 'java-test-fixtures' | ||
| apply plugin: 'eclipse' | ||
| apply plugin: 'maven-publish' | ||
| apply plugin: 'org.sensorhub.osh-plugin' | ||
|
|
||
| ext.details = null | ||
| ext.pom = {} // pom data that subprojects can append to | ||
|
|
||
| tasks.withType(JavaCompile) { | ||
| options.encoding = 'UTF-8' | ||
| options.compilerArgs << "-Xlint:-options" | ||
| } | ||
|
|
||
| tasks.withType(Javadoc) { | ||
| options.encoding = 'UTF-8' | ||
| options.addStringOption('Xdoclint:none', '-quiet') | ||
| } | ||
|
|
||
| eclipse { | ||
| classpath { | ||
| downloadJavadoc = true | ||
| file.whenMerged { | ||
| entries.each { | ||
| if (it.hasProperty('exported')) | ||
| it.exported = true | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // custom dependency configurations for embedding jars in OSGi bundle | ||
| configurations { | ||
| embeddedApi | ||
| embeddedImpl | ||
| embedded | ||
| embedded.extendsFrom(embeddedApi, embeddedImpl) | ||
| api.extendsFrom(embeddedApi) | ||
| implementation.extendsFrom(embeddedImpl) | ||
| } | ||
|
|
||
| // default test dependencies | ||
| dependencies { | ||
| testImplementation 'junit:junit:4.13' | ||
| testImplementation 'xmlunit:xmlunit:1.6' | ||
| } | ||
|
|
||
| // print test names | ||
| test { | ||
| testLogging { | ||
| events 'PASSED', 'FAILED' | ||
| showCauses true | ||
| showStackTraces true | ||
| exceptionFormat 'full' | ||
| } | ||
| } | ||
|
|
||
| assemble.dependsOn osgi | ||
|
|
||
| // do stuff at the end in case subprojects add extra info | ||
| afterEvaluate { project -> | ||
|
|
||
| // set defaults for some OSGi manifest entries | ||
| project.osgi { | ||
| manifest { | ||
| // main info | ||
| attributes 'Bundle-SymbolicName': project.group + '.' + project.name | ||
| if (project.description != null && !attributes['Bundle-Name']) | ||
| attributes 'Bundle-Name': project.description | ||
| if (project.details != null && !attributes['Bundle-Description']) | ||
| attributes 'Bundle-Description': project.details | ||
| attributes 'Bundle-Version': project.version | ||
| if (project.buildNumber != null && !project.buildNumber.isEmpty()) | ||
| attributes 'Bundle-BuildNumber': project.buildNumber | ||
| if (!attributes['Bundle-License']) | ||
| attributes 'Bundle-License': 'MPL 2.0 (http://mozilla.org/MPL/2.0)' | ||
| if (!attributes['Bundle-Copyright'] && attributes['Bundle-Vendor']) | ||
| attributes 'Bundle-Copyright': 'Copyright (c) ' + attributes['Bundle-Vendor'] + '. All Rights Reserved' | ||
| } | ||
| } | ||
|
|
||
| // also use osgi headers in JAR manifest | ||
| project.jar { | ||
| manifest { | ||
| from project.osgi.manifest | ||
| } | ||
| } | ||
|
|
||
| // maven artifact content | ||
| project.publishing { | ||
|
|
||
| publications { | ||
| mavenJava(MavenPublication) { | ||
| from components.java | ||
| pom.withXml { | ||
| asNode().get('version') + ({ | ||
| resolveStrategy = Closure.DELEGATE_FIRST | ||
| name project.description | ||
| if (project.details != null) | ||
| description project.details | ||
| url 'http://www.opensensorhub.org' | ||
| licenses { | ||
| license { | ||
| name 'Mozilla Public License Version 2.0' | ||
| url 'http://www.mozilla.org/MPL/2.0' | ||
| distribution 'repo' | ||
| } | ||
| } | ||
| def repoName = projectDir.parentFile.name | ||
| scm { | ||
| url 'https://github.com/opensensorhub/' + repoName + '/tree/master/' + project.name | ||
| connection 'scm:git:git://github.com/opensensorhub/' + repoName + '.git' | ||
| } | ||
| issueManagement { | ||
| url 'https://github.com/opensensorhub/' + repoName + '/issues' | ||
| system 'GitHub Issues' | ||
| } | ||
| } >> project.pom) | ||
| } | ||
| } | ||
| } | ||
| repositories { | ||
| maven { | ||
| name = "GitHubPackages" | ||
| url = "https://maven.pkg.github.com/opensensorhub/osh-core" | ||
| credentials { | ||
| username = System.getenv("GITHUB_ACTOR") | ||
| password = System.getenv("GITHUB_TOKEN") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| project.tasks.named("generateMetadataFileForMavenJavaPublication") { | ||
| doFirst { | ||
| if (System.getenv("GITHUB_ACTOR") == null) { | ||
| throw new Exception("Environment variable GITHUB_ACTOR not set. Please set to your github username.") | ||
| } | ||
|
|
||
| if (System.getenv("GITHUB_TOKEN") == null) { | ||
| throw new Exception("Environment variable GITHUB_TOKEN not set. Please generate and set to your personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| project.tasks.named("publishMavenJavaPublicationToGitHubPackagesRepository") { | ||
| onlyIf { | ||
| // | ||
| MavenArtifactRepository repo = repository as MavenArtifactRepository; | ||
| MavenPublication pub = publication as MavenPublication; | ||
|
|
||
| HttpURLConnection connection = new URL("$repo.url/${pub.groupId.replace('.', '/')}/$pub.artifactId/$pub.version/$pub.artifactId-${pub.version}.jar").openConnection(); | ||
| connection.setRequestMethod("GET"); | ||
| connection.setRequestProperty("Authorization", "Basic ${new String(Base64.getEncoder().encode("$repo.credentials.username:$repo.credentials.password".bytes))}"); | ||
| connection.connect(); | ||
| return connection.responseCode == 404; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // disable jar task if no source is included | ||
| if (!new File(project.projectDir, 'src').exists()) { | ||
| tasks.osgi.enabled = false | ||
| tasks.jar.enabled = false | ||
| } | ||
|
|
||
| // custom task to install in local maven repo | ||
| task install | ||
| install.dependsOn(build) | ||
| install.dependsOn(publishToMavenLocal) | ||
| } | ||
|
|
||
|
|
||
| // distribution zip files | ||
| apply plugin: 'java-library' | ||
| apply plugin: 'distribution' | ||
|
|
||
| tasks.jar.enabled = false | ||
| afterEvaluate { // disable all distTar tasks | ||
| tasks.each { | ||
| if (it.name.endsWith('istTar')) | ||
| it.enabled = false | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // collect all configured repositories in parent build | ||
| gradle.projectsEvaluated { g -> | ||
| if (gradle.parent != null) { | ||
| gradle.parent.rootProject { | ||
| repositories.addAll(g.rootProject.repositories) | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not seeing the publication of OSGi Bundles - in order to accomplish this automatically this needs to be added