# Cannot apply plugin by id in init.gradle script

**URL:** <https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [January 30, 2019, 1:17pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377 "2019-01-30T13:17:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cellebyte](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Cellebyte](https://discuss.gradle.org/u/Cellebyte)\
**Post date:** [January 30, 2019, 1:17pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/1 "2019-01-30T13:17:43Z")

</div>

## Example

```gradle
//Snippet
settingsEvaluated { settings ->
    settings.pluginManagement {
        repositories {
            maven {
                credentials {
                    username "username"
                    password "password"
                }
                url "https://nexus.example.com"
                
            }
        }
    }
}
initscript {
    repositories {
        maven {
            credentials {
                username "username"
                password "password"
            }
            url "https://nexus.example.com"
            
        }
    }
    dependencies {
        classpath "com.netflix.nebula:gradle-ospackage-plugin:5.1.0"
        classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4"
        classpath "gradle.plugin.com.selesse:gradle-git-changelog:0.3.0"
    }
}
allprojects {
    apply plugin: 'com.netflix.gradle.plugins.rpm.RpmPlugin'
    apply plugin: 'com.github.jengelman.gradle.plugins.shadow.ShadowPlugin'
    apply plugin: 'com.selesse.gradle.git.changelog.GitLogPlugin'
}
//...

```

Am I doing something wrong here.  
Stacktrace is not very helpfull either.

## Error Message

```gradle
FAILURE: Build failed with an exception.

* Where:
Initialization script '/home/$USER/.gradle/init.gradle' line: 37

* What went wrong:
Plugin with id 'com.netflix.gradle.plugins.rpm.RpmPlugin' not found.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin with id 'com.netflix.gradle.plugins.rpm.RpmPlugin' not found.
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:131)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:120)

```

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [January 30, 2019, 4:35pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/2 "2019-01-30T16:35:08Z")

</div>

You are using the implementation class of the plugins (ex: `com.netflix.gradle.plugins.rpm.RpmPlugin`) as the ID. The ID of that particular plugin is `nebula.rpm`.

However, you do need to use the implementation class, not the ID, in an init script. In order to do that, you should remove the quotes around the implementation classes:

```groovy
allprojects {
    apply plugin: com.netflix.gradle.plugins.rpm.RpmPlugin
    apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
    apply plugin: com.selesse.gradle.git.changelog.GitLogPlugin
}

```

---

<div class="post-metadata">

**Author:** ![Cellebyte](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Cellebyte](https://discuss.gradle.org/u/Cellebyte)\
**Post date:** [February 4, 2019, 10:36am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/3 "2019-02-04T10:36:17Z")

</div>

Got it working thanks!

---

<div class="post-metadata">

**Author:** ![user3477071](https://avatars.discourse-cdn.com/v4/letter/u/6a8cbe/32.png) [@user3477071](https://discuss.gradle.org/u/user3477071)\
**Post date:** [January 2, 2020, 3:15am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/4 "2020-01-02T03:15:25Z")

</div>

Including

> allprojects {  
> apply plugin: com.netflix.gradle.plugins.rpm.RpmPlugin  
> }

in init.gradle produces this error

> Could not get unknown property ‘com’ for root project ‘sftp-client’ of type org.gradle.api.Project.

in gradle 6.0.1

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [January 2, 2020, 4:30am UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/5 "2020-01-02T04:30:22Z")

</div>

If you try to reference a class in an init script without adding it to the classpath, that error will occur in any version of Gradle. The line you copied from the thread isn’t stand-alone. It’s within the context of the larger file posted by the original poster.

---

<div class="post-metadata">

**Author:** ![calvin](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@calvin](https://discuss.gradle.org/u/calvin)\
**Post date:** [August 11, 2021, 2:11pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/6 "2021-08-11T14:11:17Z")

</div>

> [@jjustinic](#):
>
> ebula.rpm

I too am getting the error “…unknown property ‘com’”

I have a project that creates a custom wrapper which includes a script in init.d named artifactory.gradle

```gradle
initscript{
	Properties properties = new Properties()
	properties.load(new File(getGradleUserHomeDir(), 'gradle.properties').newDataInputStream())

	repositories {
		maven {
			url properties.artifactory_contextUrl + '/gradle-plugins-virtual'
			credentials {
				username = properties.artifactory_user
				password = properties.artifactory_password
			}
		}
	}
	dependencies {
		classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.17.2"
	}
}

apply plugin: com.jfrog.artifactory //unknown property com
// apply plugin: 'com.jfrog.artifactory' //gives plugin not found error

println "artifactory.gradle - called"

```

when I run a project configured to use this wrapper I get the errors indicated here.

Any help appreciated. How do I verify my classpath?  
[[Build Scan® | Gradle Cloud Services](https://scans.gradle.com/s/53i7kib32qwry)]([https://build](https://build) scan)

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [August 12, 2021, 8:35pm UTC](https://discuss.gradle.org/t/cannot-apply-plugin-by-id-in-init-gradle-script/30377/7 "2021-08-12T20:35:13Z")

</div>

`com.jfrog.artifactory` does not look like a class name!
