-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gradle init script for JFrog CLI
- Loading branch information
1 parent
5ad5ff9
commit e2c8c10
Showing
2 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,38 @@ | ||
import org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin | ||
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask | ||
|
||
initscript { | ||
dependencies { | ||
classpath fileTree('${pluginLibDir}') | ||
} | ||
} | ||
|
||
addListener(new BuildInfoPluginListener()) | ||
|
||
class BuildInfoPluginListener extends BuildAdapter { | ||
|
||
def void projectsLoaded(Gradle gradle) { | ||
Map<String, String> projectProperties = new HashMap<String, String>(gradle.startParameter.getProjectProperties()) | ||
projectProperties.put("build.start", Long.toString(System.currentTimeMillis())) | ||
gradle.startParameter.setProjectProperties(projectProperties) | ||
Project root = gradle.getRootProject() | ||
root.logger.debug("Artifactory plugin: projectsEvaluated: ${root.name}") | ||
if (!"buildSrc".equals(root.name)) { | ||
root.allprojects { | ||
apply { | ||
apply plugin: ArtifactoryPlugin | ||
} | ||
} | ||
} | ||
|
||
// Set the "mavenJava" and "ivyJava" publications or | ||
// "archives" configuration to all Artifactory tasks. | ||
for (Project p : root.getAllprojects()) { | ||
Task t = p.getTasks().findByName(ArtifactoryTask.ARTIFACTORY_PUBLISH_TASK_NAME) | ||
if (t != null) { | ||
ArtifactoryTask task = (ArtifactoryTask) t | ||
task.setCiServerBuild() | ||
} | ||
} | ||
} | ||
} |